	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function stu300_xfer_msg
_stu300_xfer_msg:                       ## @stu300_xfer_msg
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%edx, -44(%rbp)                 ## 4-byte Spill
	movq	%rsi, %r15
	callq	_i2c_get_adapdata
	movq	%rax, %r12
	movl	(%rax), %edi
	callq	_clk_enable
	cmpl	$0, (%r15)
	je	LBB0_21
## %bb.1:
	xorl	%r13d, %r13d
	jmp	LBB0_3
	.p2align	4, 0x90
LBB0_2:                                 ##   in Loop: Header=BB0_3 Depth=1
	incl	%r13d
	movq	16(%r12), %rdi
	movl	28(%r12), %ecx
	movl	24(%r12), %r8d
	leaq	L_.str.4(%rip), %rsi
	movl	%r13d, %edx
	xorl	%eax, %eax
	callq	_dev_dbg
	movq	_NUM_ADDR_RESEND_ATTEMPTS@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	cmpl	%edx, %r13d
	jge	LBB0_28
LBB0_3:                                 ## =>This Inner Loop Header: Depth=1
	testl	%r13d, %r13d
	je	LBB0_6
## %bb.4:                               ##   in Loop: Header=BB0_3 Depth=1
	movq	16(%r12), %rdi
	leaq	L_.str(%rip), %rsi
	xorl	%eax, %eax
	callq	_dev_dbg
	movq	%r12, %rdi
	callq	_stu300_wait_while_busy
	testl	%eax, %eax
	jne	LBB0_23
## %bb.5:                               ##   in Loop: Header=BB0_3 Depth=1
	movq	16(%r12), %rdi
	leaq	L_.str.1(%rip), %rsi
	xorl	%eax, %eax
	callq	_dev_dbg
	jmp	LBB0_7
	.p2align	4, 0x90
LBB0_6:                                 ##   in Loop: Header=BB0_3 Depth=1
	movq	%r12, %rdi
	callq	_stu300_wait_while_busy
	testl	%eax, %eax
	jne	LBB0_23
LBB0_7:                                 ##   in Loop: Header=BB0_3 Depth=1
	movq	%r12, %rdi
	callq	_stu300_init_hw
	testl	%eax, %eax
	jne	LBB0_23
## %bb.8:                               ##   in Loop: Header=BB0_3 Depth=1
	movl	4(%r15), %eax
	movq	_I2C_M_NOSTART@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	xorl	%r14d, %r14d
	testl	%eax, %ecx
	jne	LBB0_10
## %bb.9:                               ##   in Loop: Header=BB0_3 Depth=1
	movq	_I2C_CR_START_ENABLE@GOTPCREL(%rip), %rdx
	movl	(%rdx), %r14d
LBB0_10:                                ##   in Loop: Header=BB0_3 Depth=1
	movq	_I2C_CR_PERIPHERAL_ENABLE@GOTPCREL(%rip), %rdx
	orl	(%rdx), %r14d
	movq	_I2C_M_RD@GOTPCREL(%rip), %rdx
	testl	%eax, (%rdx)
	je	LBB0_13
## %bb.11:                              ##   in Loop: Header=BB0_3 Depth=1
	cmpl	$2, (%r15)
	jl	LBB0_13
## %bb.12:                              ##   in Loop: Header=BB0_3 Depth=1
	movq	_I2C_CR_ACK_ENABLE@GOTPCREL(%rip), %rdx
	orl	(%rdx), %r14d
LBB0_13:                                ##   in Loop: Header=BB0_3 Depth=1
	xorl	%ebx, %ebx
	testl	%eax, %ecx
	je	LBB0_18
## %bb.14:                              ##   in Loop: Header=BB0_3 Depth=1
	testl	%r13d, %r13d
	je	LBB0_16
LBB0_15:                                ##   in Loop: Header=BB0_3 Depth=1
	movq	16(%r12), %rdi
	leaq	L_.str.3(%rip), %rsi
	xorl	%eax, %eax
	callq	_dev_dbg
LBB0_16:                                ##   in Loop: Header=BB0_3 Depth=1
	testl	%ebx, %ebx
	jne	LBB0_2
## %bb.17:                              ##   in Loop: Header=BB0_3 Depth=1
	xorl	%edx, %edx
	testl	%r13d, %r13d
	setne	%dl
	movq	%r12, %rdi
	movq	%r15, %rsi
	callq	_stu300_send_address
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_2
	jmp	LBB0_25
	.p2align	4, 0x90
LBB0_18:                                ##   in Loop: Header=BB0_3 Depth=1
	testl	%r13d, %r13d
	je	LBB0_20
## %bb.19:                              ##   in Loop: Header=BB0_3 Depth=1
	movq	16(%r12), %rdi
	leaq	L_.str.2(%rip), %rsi
	xorl	%eax, %eax
	callq	_dev_dbg
LBB0_20:                                ##   in Loop: Header=BB0_3 Depth=1
	movq	_STU300_EVENT_5@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r12, %rdi
	movl	%r14d, %esi
	callq	_stu300_start_and_await_event
	movl	%eax, %ebx
	testl	%r13d, %r13d
	jne	LBB0_15
	jmp	LBB0_16
LBB0_21:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
LBB0_54:
	subl	(%rax), %ebx
	jmp	LBB0_55
LBB0_25:
	movq	_NUM_ADDR_RESEND_ATTEMPTS@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	xorl	%ebx, %ebx
	cmpl	%edx, %r13d
	jge	LBB0_28
## %bb.26:
	testl	%r13d, %r13d
	je	LBB0_28
## %bb.27:
	movq	16(%r12), %rdi
	leaq	L_.str.5(%rip), %rsi
	movl	%r13d, %edx
	xorl	%eax, %eax
	callq	_dev_dbg
	jmp	LBB0_30
LBB0_28:
	cmpl	%edx, %r13d
	jne	LBB0_30
## %bb.29:
	movq	16(%r12), %rdi
	leaq	L_.str.6(%rip), %rsi
	xorl	%eax, %eax
	callq	_dev_dbg
	jmp	LBB0_55
LBB0_30:
	movl	(%r15), %eax
	movl	4(%r15), %ecx
	movq	_I2C_M_RD@GOTPCREL(%rip), %rdx
	testl	%ecx, (%rdx)
	je	LBB0_39
## %bb.31:
	testl	%eax, %eax
	jle	LBB0_47
## %bb.32:
	xorl	%r14d, %r14d
	movq	_STU300_EVENT_7@GOTPCREL(%rip), %r13
	.p2align	4, 0x90
LBB0_33:                                ## =>This Inner Loop Header: Depth=1
	decl	%eax
	cmpq	%rax, %r14
	jne	LBB0_37
## %bb.34:                              ##   in Loop: Header=BB0_33 Depth=1
	movl	-44(%rbp), %eax                 ## 4-byte Reload
	movl	%eax, %edi
	testl	%eax, %eax
	je	LBB0_36
## %bb.35:                              ##   in Loop: Header=BB0_33 Depth=1
	movq	_I2C_CR_STOP_ENABLE@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
LBB0_36:                                ##   in Loop: Header=BB0_33 Depth=1
	movq	_I2C_CR_PERIPHERAL_ENABLE@GOTPCREL(%rip), %rax
	orl	(%rax), %edi
	movq	_I2C_CR@GOTPCREL(%rip), %rax
	movq	(%rax), %rsi
	addq	8(%r12), %rsi
	callq	_stu300_wr8
LBB0_37:                                ##   in Loop: Header=BB0_33 Depth=1
	movl	(%r13), %esi
	movq	%r12, %rdi
	callq	_stu300_await_event
	testl	%eax, %eax
	jne	LBB0_23
## %bb.38:                              ##   in Loop: Header=BB0_33 Depth=1
	movq	_I2C_DR@GOTPCREL(%rip), %rax
	movq	(%rax), %rdi
	addq	8(%r12), %rdi
	callq	_stu300_r8
	movq	8(%r15), %rcx
	movl	%eax, (%rcx,%r14,4)
	incq	%r14
	movslq	(%r15), %rax
	cmpq	%rax, %r14
	jl	LBB0_33
	jmp	LBB0_47
LBB0_23:
	movl	%eax, %ebx
LBB0_55:
	movq	_I2C_CR@GOTPCREL(%rip), %rax
	movq	(%rax), %rsi
	addq	8(%r12), %rsi
	xorl	%edi, %edi
	callq	_stu300_wr8
	movl	(%r12), %edi
	callq	_clk_disable
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_39:
	testl	%eax, %eax
	jle	LBB0_44
## %bb.40:
	xorl	%r14d, %r14d
	movq	_STU300_EVENT_8@GOTPCREL(%rip), %r13
	.p2align	4, 0x90
LBB0_41:                                ## =>This Inner Loop Header: Depth=1
	movq	8(%r15), %rax
	movl	(%rax,%r14,4), %edi
	movq	_I2C_DR@GOTPCREL(%rip), %rax
	movq	(%rax), %rsi
	addq	8(%r12), %rsi
	callq	_stu300_wr8
	movl	(%r13), %esi
	movq	%r12, %rdi
	callq	_stu300_await_event
	testl	%eax, %eax
	jne	LBB0_51
## %bb.42:                              ##   in Loop: Header=BB0_41 Depth=1
	incq	%r14
	movslq	(%r15), %rax
	cmpq	%rax, %r14
	jl	LBB0_41
## %bb.43:
	movl	4(%r15), %ecx
LBB0_44:
	movq	_I2C_M_IGNORE_NAK@GOTPCREL(%rip), %rax
	testl	%ecx, (%rax)
	je	LBB0_52
LBB0_45:
	cmpl	$0, -44(%rbp)                   ## 4-byte Folded Reload
	je	LBB0_47
## %bb.46:
	movq	_I2C_CR_STOP_ENABLE@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	_I2C_CR_PERIPHERAL_ENABLE@GOTPCREL(%rip), %rax
	orl	(%rax), %edi
	movq	_I2C_CR@GOTPCREL(%rip), %rax
	movq	(%rax), %rsi
	addq	8(%r12), %rsi
	callq	_stu300_wr8
LBB0_47:
	movq	%r12, %rdi
	callq	_stu300_wait_while_busy
	testl	%eax, %eax
	je	LBB0_49
## %bb.48:
	movl	%eax, %ebx
	movq	16(%r12), %rdi
	leaq	L_.str.9(%rip), %rsi
	xorl	%eax, %eax
	callq	_dev_err
	jmp	LBB0_55
LBB0_49:
	movq	_I2C_SR2@GOTPCREL(%rip), %rax
	movq	(%rax), %rdi
	addq	8(%r12), %rdi
	callq	_stu300_r8
	movq	_I2C_SR1@GOTPCREL(%rip), %rax
	movq	(%rax), %rdi
	addq	8(%r12), %rdi
	callq	_stu300_r8
	xorl	%ebx, %ebx
	jmp	LBB0_55
LBB0_51:
	movl	%eax, %ebx
	movq	16(%r12), %rdi
	leaq	L_.str.7(%rip), %rsi
	movl	%eax, %edx
	xorl	%eax, %eax
	callq	_dev_err
	jmp	LBB0_55
LBB0_52:
	movq	_I2C_SR2@GOTPCREL(%rip), %rax
	movq	(%rax), %rdi
	addq	8(%r12), %rdi
	callq	_stu300_r8
	movq	_I2C_SR2_AF_IND@GOTPCREL(%rip), %rcx
	testl	%eax, (%rcx)
	je	LBB0_45
## %bb.53:
	movq	16(%r12), %rdi
	leaq	L_.str.8(%rip), %rsi
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_dev_err
	movq	_EIO@GOTPCREL(%rip), %rax
	jmp	LBB0_54
	.cfi_endproc
                                        ## -- End function
	.comm	_EINVAL,4,2                     ## @EINVAL
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"wait while busy\n"

L_.str.1:                               ## @.str.1
	.asciz	"re-int hw\n"

	.comm	_I2C_CR_PERIPHERAL_ENABLE,4,2   ## @I2C_CR_PERIPHERAL_ENABLE
	.comm	_I2C_M_NOSTART,4,2              ## @I2C_M_NOSTART
	.comm	_I2C_CR_START_ENABLE,4,2        ## @I2C_CR_START_ENABLE
	.comm	_I2C_M_RD,4,2                   ## @I2C_M_RD
	.comm	_I2C_CR_ACK_ENABLE,4,2          ## @I2C_CR_ACK_ENABLE
L_.str.2:                               ## @.str.2
	.asciz	"send start event\n"

	.comm	_STU300_EVENT_5,4,2             ## @STU300_EVENT_5
L_.str.3:                               ## @.str.3
	.asciz	"send address\n"

L_.str.4:                               ## @.str.4
	.asciz	"failed sending address, retrying. Attempt: %d msg_index: %d/%d\n"

	.comm	_NUM_ADDR_RESEND_ATTEMPTS,4,2   ## @NUM_ADDR_RESEND_ATTEMPTS
L_.str.5:                               ## @.str.5
	.asciz	"managed to get address through after %d attempts\n"

L_.str.6:                               ## @.str.6
	.asciz	"I give up, tried %d times to resend address.\n"

	.comm	_I2C_CR_STOP_ENABLE,4,2         ## @I2C_CR_STOP_ENABLE
	.comm	_I2C_CR,8,3                     ## @I2C_CR
	.comm	_STU300_EVENT_7,4,2             ## @STU300_EVENT_7
	.comm	_I2C_DR,8,3                     ## @I2C_DR
	.comm	_STU300_EVENT_8,4,2             ## @STU300_EVENT_8
L_.str.7:                               ## @.str.7
	.asciz	"error awaiting event 8 (%d)\n"

	.comm	_I2C_M_IGNORE_NAK,4,2           ## @I2C_M_IGNORE_NAK
	.comm	_I2C_SR2,8,3                    ## @I2C_SR2
	.comm	_I2C_SR2_AF_IND,4,2             ## @I2C_SR2_AF_IND
L_.str.8:                               ## @.str.8
	.asciz	"I2C payload send returned NAK!\n"

	.comm	_EIO,4,2                        ## @EIO
L_.str.9:                               ## @.str.9
	.asciz	"timout waiting for transfer to commence.\n"

	.comm	_I2C_SR1,8,3                    ## @I2C_SR1
	.no_dead_strip	_stu300_xfer_msg
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function stu300_xfer_msg
_stu300_xfer_msg:                       ; @stu300_xfer_msg
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #128
	.cfi_def_cfa_offset 128
	stp	x28, x27, [sp, #32]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #48]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #64]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #80]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #96]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #112]            ; 16-byte Folded Spill
	add	x29, sp, #112
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	.cfi_offset w21, -40
	.cfi_offset w22, -48
	.cfi_offset w23, -56
	.cfi_offset w24, -64
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	.cfi_offset w27, -88
	.cfi_offset w28, -96
	mov	x20, x2
	mov	x21, x1
	bl	_i2c_get_adapdata
	mov	x19, x0
	ldr	w0, [x0]
	bl	_clk_enable
	ldr	w8, [x21]
Lloh0:
	adrp	x26, _I2C_CR@GOTPAGE
Lloh1:
	ldr	x26, [x26, _I2C_CR@GOTPAGEOFF]
	cbz	w8, LBB0_20
; %bb.1:
	str	w20, [sp, #28]                  ; 4-byte Folded Spill
	mov	w25, #0
Lloh2:
	adrp	x23, l_.str@PAGE
Lloh3:
	add	x23, x23, l_.str@PAGEOFF
Lloh4:
	adrp	x28, _I2C_M_NOSTART@GOTPAGE
Lloh5:
	ldr	x28, [x28, _I2C_M_NOSTART@GOTPAGEOFF]
Lloh6:
	adrp	x24, _I2C_CR_START_ENABLE@GOTPAGE
Lloh7:
	ldr	x24, [x24, _I2C_CR_START_ENABLE@GOTPAGEOFF]
Lloh8:
	adrp	x20, _I2C_M_RD@GOTPAGE
Lloh9:
	ldr	x20, [x20, _I2C_M_RD@GOTPAGEOFF]
Lloh10:
	adrp	x26, _NUM_ADDR_RESEND_ATTEMPTS@GOTPAGE
Lloh11:
	ldr	x26, [x26, _NUM_ADDR_RESEND_ATTEMPTS@GOTPAGEOFF]
Lloh12:
	adrp	x27, l_.str.4@PAGE
Lloh13:
	add	x27, x27, l_.str.4@PAGEOFF
	b	LBB0_3
LBB0_2:                                 ;   in Loop: Header=BB0_3 Depth=1
	add	w25, w25, #1
	ldr	x0, [x19, #16]
	ldp	w9, w8, [x19, #24]
	stp	x8, x9, [sp, #8]
	str	x25, [sp]
	mov	x1, x27
	bl	_dev_dbg
	ldr	w8, [x26]
	cmp	w25, w8
	b.ge	LBB0_25
LBB0_3:                                 ; =>This Inner Loop Header: Depth=1
	cbz	w25, LBB0_6
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=1
	ldr	x0, [x19, #16]
	mov	x1, x23
	bl	_dev_dbg
	mov	x0, x19
	bl	_stu300_wait_while_busy
	cbnz	w0, LBB0_19
; %bb.5:                                ;   in Loop: Header=BB0_3 Depth=1
	ldr	x0, [x19, #16]
Lloh14:
	adrp	x1, l_.str.1@PAGE
Lloh15:
	add	x1, x1, l_.str.1@PAGEOFF
	bl	_dev_dbg
	b	LBB0_7
LBB0_6:                                 ;   in Loop: Header=BB0_3 Depth=1
	mov	x0, x19
	bl	_stu300_wait_while_busy
	cbnz	w0, LBB0_19
LBB0_7:                                 ;   in Loop: Header=BB0_3 Depth=1
	mov	x0, x19
	bl	_stu300_init_hw
	cbnz	w0, LBB0_19
; %bb.8:                                ;   in Loop: Header=BB0_3 Depth=1
Lloh16:
	adrp	x8, _I2C_CR_PERIPHERAL_ENABLE@GOTPAGE
Lloh17:
	ldr	x8, [x8, _I2C_CR_PERIPHERAL_ENABLE@GOTPAGEOFF]
Lloh18:
	ldr	w9, [x8]
	ldr	w10, [x21, #4]
	ldr	w8, [x28]
	ands	w8, w8, w10
	ldr	w11, [x24]
	csel	w11, w11, wzr, eq
	orr	w22, w11, w9
	ldr	w9, [x20]
	tst	w9, w10
	b.eq	LBB0_11
; %bb.9:                                ;   in Loop: Header=BB0_3 Depth=1
	ldr	w9, [x21]
	cmp	w9, #2
	b.lt	LBB0_11
; %bb.10:                               ;   in Loop: Header=BB0_3 Depth=1
Lloh19:
	adrp	x9, _I2C_CR_ACK_ENABLE@GOTPAGE
Lloh20:
	ldr	x9, [x9, _I2C_CR_ACK_ENABLE@GOTPAGEOFF]
Lloh21:
	ldr	w9, [x9]
	orr	w22, w9, w22
LBB0_11:                                ;   in Loop: Header=BB0_3 Depth=1
	cbz	w8, LBB0_16
; %bb.12:                               ;   in Loop: Header=BB0_3 Depth=1
	mov	w22, #0
	cbz	w25, LBB0_14
LBB0_13:                                ;   in Loop: Header=BB0_3 Depth=1
	ldr	x0, [x19, #16]
Lloh22:
	adrp	x1, l_.str.3@PAGE
Lloh23:
	add	x1, x1, l_.str.3@PAGEOFF
	bl	_dev_dbg
LBB0_14:                                ;   in Loop: Header=BB0_3 Depth=1
	cbnz	w22, LBB0_2
; %bb.15:                               ;   in Loop: Header=BB0_3 Depth=1
	cmp	w25, #0
	cset	w2, ne
	mov	x0, x19
	mov	x1, x21
	bl	_stu300_send_address
	mov	x22, x0
	cbnz	w0, LBB0_2
	b	LBB0_22
LBB0_16:                                ;   in Loop: Header=BB0_3 Depth=1
	cbz	w25, LBB0_18
; %bb.17:                               ;   in Loop: Header=BB0_3 Depth=1
	ldr	x0, [x19, #16]
Lloh24:
	adrp	x1, l_.str.2@PAGE
Lloh25:
	add	x1, x1, l_.str.2@PAGEOFF
	bl	_dev_dbg
LBB0_18:                                ;   in Loop: Header=BB0_3 Depth=1
Lloh26:
	adrp	x8, _STU300_EVENT_5@GOTPAGE
Lloh27:
	ldr	x8, [x8, _STU300_EVENT_5@GOTPAGEOFF]
Lloh28:
	ldr	w2, [x8]
	mov	x0, x19
	mov	x1, x22
	bl	_stu300_start_and_await_event
	mov	x22, x0
	cbnz	w25, LBB0_13
	b	LBB0_14
LBB0_19:
	mov	x22, x0
Lloh29:
	adrp	x26, _I2C_CR@GOTPAGE
Lloh30:
	ldr	x26, [x26, _I2C_CR@GOTPAGEOFF]
	b	LBB0_49
LBB0_20:
Lloh31:
	adrp	x8, _EINVAL@GOTPAGE
Lloh32:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
LBB0_21:
	ldr	w8, [x8]
	neg	w22, w8
	b	LBB0_49
LBB0_22:
	ldr	w8, [x26]
	cmp	w25, w8
	b.ge	LBB0_25
; %bb.23:
Lloh33:
	adrp	x26, _I2C_CR@GOTPAGE
Lloh34:
	ldr	x26, [x26, _I2C_CR@GOTPAGEOFF]
	ldr	w27, [sp, #28]                  ; 4-byte Folded Reload
	cbz	w25, LBB0_26
; %bb.24:
	ldr	x0, [x19, #16]
                                        ; kill: def $w25 killed $w25 killed $x25 def $x25
	str	x25, [sp]
Lloh35:
	adrp	x1, l_.str.5@PAGE
Lloh36:
	add	x1, x1, l_.str.5@PAGEOFF
	bl	_dev_dbg
	b	LBB0_28
LBB0_25:
Lloh37:
	adrp	x26, _I2C_CR@GOTPAGE
Lloh38:
	ldr	x26, [x26, _I2C_CR@GOTPAGEOFF]
	ldr	w27, [sp, #28]                  ; 4-byte Folded Reload
LBB0_26:
	cmp	w25, w8
	b.ne	LBB0_28
; %bb.27:
	ldr	x0, [x19, #16]
	str	x8, [sp]
Lloh39:
	adrp	x1, l_.str.6@PAGE
Lloh40:
	add	x1, x1, l_.str.6@PAGEOFF
	bl	_dev_dbg
	b	LBB0_49
LBB0_28:
	ldr	w10, [x20]
	ldp	w8, w9, [x21]
	tst	w10, w9
	b.eq	LBB0_35
; %bb.29:
	cmp	w8, #1
	b.lt	LBB0_43
; %bb.30:
	mov	x20, #0
Lloh41:
	adrp	x23, _I2C_CR_STOP_ENABLE@GOTPAGE
Lloh42:
	ldr	x23, [x23, _I2C_CR_STOP_ENABLE@GOTPAGEOFF]
Lloh43:
	adrp	x24, _STU300_EVENT_7@GOTPAGE
Lloh44:
	ldr	x24, [x24, _STU300_EVENT_7@GOTPAGEOFF]
Lloh45:
	adrp	x25, _I2C_DR@GOTPAGE
Lloh46:
	ldr	x25, [x25, _I2C_DR@GOTPAGEOFF]
LBB0_31:                                ; =>This Inner Loop Header: Depth=1
	sub	w8, w8, #1
	cmp	x20, x8
	b.ne	LBB0_33
; %bb.32:                               ;   in Loop: Header=BB0_31 Depth=1
Lloh47:
	adrp	x8, _I2C_CR_PERIPHERAL_ENABLE@GOTPAGE
Lloh48:
	ldr	x8, [x8, _I2C_CR_PERIPHERAL_ENABLE@GOTPAGEOFF]
Lloh49:
	ldr	w8, [x8]
	ldr	w9, [x23]
	cmp	w27, #0
	csel	w9, wzr, w9, eq
	orr	w0, w9, w8
	ldr	x8, [x19, #8]
	ldr	x9, [x26]
	add	x1, x9, x8
	bl	_stu300_wr8
LBB0_33:                                ;   in Loop: Header=BB0_31 Depth=1
	ldr	w1, [x24]
	mov	x0, x19
	bl	_stu300_await_event
	cbnz	w0, LBB0_46
; %bb.34:                               ;   in Loop: Header=BB0_31 Depth=1
	ldr	x8, [x19, #8]
	ldr	x9, [x25]
	add	x0, x9, x8
	bl	_stu300_r8
	ldr	x8, [x21, #8]
	str	w0, [x8, x20, lsl #2]
	add	x20, x20, #1
	ldrsw	x8, [x21]
	cmp	x20, x8
	b.lt	LBB0_31
	b	LBB0_43
LBB0_35:
	cmp	w8, #1
	b.lt	LBB0_40
; %bb.36:
	mov	x20, #0
Lloh50:
	adrp	x23, _I2C_DR@GOTPAGE
Lloh51:
	ldr	x23, [x23, _I2C_DR@GOTPAGEOFF]
Lloh52:
	adrp	x24, _STU300_EVENT_8@GOTPAGE
Lloh53:
	ldr	x24, [x24, _STU300_EVENT_8@GOTPAGEOFF]
LBB0_37:                                ; =>This Inner Loop Header: Depth=1
	ldr	x8, [x21, #8]
	ldr	w0, [x8, x20, lsl #2]
	ldr	x8, [x19, #8]
	ldr	x9, [x23]
	add	x1, x9, x8
	bl	_stu300_wr8
	ldr	w1, [x24]
	mov	x0, x19
	bl	_stu300_await_event
	cbnz	w0, LBB0_47
; %bb.38:                               ;   in Loop: Header=BB0_37 Depth=1
	add	x20, x20, #1
	ldrsw	x8, [x21]
	cmp	x20, x8
	b.lt	LBB0_37
; %bb.39:
	ldr	w9, [x21, #4]
LBB0_40:
Lloh54:
	adrp	x8, _I2C_M_IGNORE_NAK@GOTPAGE
Lloh55:
	ldr	x8, [x8, _I2C_M_IGNORE_NAK@GOTPAGEOFF]
Lloh56:
	ldr	w8, [x8]
	tst	w8, w9
	b.eq	LBB0_50
LBB0_41:
	cbz	w27, LBB0_43
; %bb.42:
Lloh57:
	adrp	x8, _I2C_CR_STOP_ENABLE@GOTPAGE
Lloh58:
	ldr	x8, [x8, _I2C_CR_STOP_ENABLE@GOTPAGEOFF]
Lloh59:
	adrp	x9, _I2C_CR_PERIPHERAL_ENABLE@GOTPAGE
Lloh60:
	ldr	x9, [x9, _I2C_CR_PERIPHERAL_ENABLE@GOTPAGEOFF]
Lloh61:
	ldr	w9, [x9]
Lloh62:
	ldr	w8, [x8]
	orr	w0, w8, w9
	ldr	x8, [x19, #8]
	ldr	x9, [x26]
	add	x1, x9, x8
	bl	_stu300_wr8
LBB0_43:
	mov	x0, x19
	bl	_stu300_wait_while_busy
	mov	x22, x0
	cbz	w0, LBB0_45
; %bb.44:
	ldr	x0, [x19, #16]
Lloh63:
	adrp	x1, l_.str.9@PAGE
Lloh64:
	add	x1, x1, l_.str.9@PAGEOFF
	b	LBB0_48
LBB0_45:
	ldr	x8, [x19, #8]
Lloh65:
	adrp	x9, _I2C_SR2@GOTPAGE
Lloh66:
	ldr	x9, [x9, _I2C_SR2@GOTPAGEOFF]
Lloh67:
	ldr	x9, [x9]
	add	x0, x9, x8
	bl	_stu300_r8
	ldr	x8, [x19, #8]
Lloh68:
	adrp	x9, _I2C_SR1@GOTPAGE
Lloh69:
	ldr	x9, [x9, _I2C_SR1@GOTPAGEOFF]
Lloh70:
	ldr	x9, [x9]
	add	x0, x9, x8
	bl	_stu300_r8
	b	LBB0_49
LBB0_46:
	mov	x22, x0
	b	LBB0_49
LBB0_47:
	mov	x22, x0
	ldr	x0, [x19, #16]
	str	x22, [sp]
Lloh71:
	adrp	x1, l_.str.7@PAGE
Lloh72:
	add	x1, x1, l_.str.7@PAGEOFF
LBB0_48:
	bl	_dev_err
LBB0_49:
	ldr	x8, [x19, #8]
	ldr	x9, [x26]
	add	x1, x9, x8
	mov	w0, #0
	bl	_stu300_wr8
	ldr	w0, [x19]
	bl	_clk_disable
	mov	x0, x22
	ldp	x29, x30, [sp, #112]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #96]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #80]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #64]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #48]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #32]             ; 16-byte Folded Reload
	add	sp, sp, #128
	ret
LBB0_50:
	ldr	x8, [x19, #8]
Lloh73:
	adrp	x9, _I2C_SR2@GOTPAGE
Lloh74:
	ldr	x9, [x9, _I2C_SR2@GOTPAGEOFF]
Lloh75:
	ldr	x9, [x9]
	add	x0, x9, x8
	bl	_stu300_r8
Lloh76:
	adrp	x8, _I2C_SR2_AF_IND@GOTPAGE
Lloh77:
	ldr	x8, [x8, _I2C_SR2_AF_IND@GOTPAGEOFF]
Lloh78:
	ldr	w8, [x8]
	tst	w8, w0
	b.eq	LBB0_41
; %bb.51:
	ldr	x0, [x19, #16]
Lloh79:
	adrp	x1, l_.str.8@PAGE
Lloh80:
	add	x1, x1, l_.str.8@PAGEOFF
	bl	_dev_err
Lloh81:
	adrp	x8, _EIO@GOTPAGE
Lloh82:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
	b	LBB0_21
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpAdd	Lloh12, Lloh13
	.loh AdrpLdrGot	Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpAdd	Lloh2, Lloh3
	.loh AdrpAdd	Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.loh AdrpAdd	Lloh22, Lloh23
	.loh AdrpAdd	Lloh24, Lloh25
	.loh AdrpLdrGotLdr	Lloh26, Lloh27, Lloh28
	.loh AdrpLdrGot	Lloh29, Lloh30
	.loh AdrpLdrGot	Lloh31, Lloh32
	.loh AdrpLdrGot	Lloh33, Lloh34
	.loh AdrpAdd	Lloh35, Lloh36
	.loh AdrpLdrGot	Lloh37, Lloh38
	.loh AdrpAdd	Lloh39, Lloh40
	.loh AdrpLdrGot	Lloh45, Lloh46
	.loh AdrpLdrGot	Lloh43, Lloh44
	.loh AdrpLdrGot	Lloh41, Lloh42
	.loh AdrpLdrGotLdr	Lloh47, Lloh48, Lloh49
	.loh AdrpLdrGot	Lloh52, Lloh53
	.loh AdrpLdrGot	Lloh50, Lloh51
	.loh AdrpLdrGotLdr	Lloh54, Lloh55, Lloh56
	.loh AdrpLdrGotLdr	Lloh59, Lloh60, Lloh61
	.loh AdrpLdrGotLdr	Lloh57, Lloh58, Lloh62
	.loh AdrpAdd	Lloh63, Lloh64
	.loh AdrpLdrGotLdr	Lloh68, Lloh69, Lloh70
	.loh AdrpLdrGotLdr	Lloh65, Lloh66, Lloh67
	.loh AdrpAdd	Lloh71, Lloh72
	.loh AdrpLdrGotLdr	Lloh76, Lloh77, Lloh78
	.loh AdrpLdrGotLdr	Lloh73, Lloh74, Lloh75
	.loh AdrpLdrGot	Lloh81, Lloh82
	.loh AdrpAdd	Lloh79, Lloh80
	.cfi_endproc
                                        ; -- End function
	.comm	_EINVAL,4,2                     ; @EINVAL
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"wait while busy\n"

l_.str.1:                               ; @.str.1
	.asciz	"re-int hw\n"

	.comm	_I2C_CR_PERIPHERAL_ENABLE,4,2   ; @I2C_CR_PERIPHERAL_ENABLE
	.comm	_I2C_M_NOSTART,4,2              ; @I2C_M_NOSTART
	.comm	_I2C_CR_START_ENABLE,4,2        ; @I2C_CR_START_ENABLE
	.comm	_I2C_M_RD,4,2                   ; @I2C_M_RD
	.comm	_I2C_CR_ACK_ENABLE,4,2          ; @I2C_CR_ACK_ENABLE
l_.str.2:                               ; @.str.2
	.asciz	"send start event\n"

	.comm	_STU300_EVENT_5,4,2             ; @STU300_EVENT_5
l_.str.3:                               ; @.str.3
	.asciz	"send address\n"

l_.str.4:                               ; @.str.4
	.asciz	"failed sending address, retrying. Attempt: %d msg_index: %d/%d\n"

	.comm	_NUM_ADDR_RESEND_ATTEMPTS,4,2   ; @NUM_ADDR_RESEND_ATTEMPTS
l_.str.5:                               ; @.str.5
	.asciz	"managed to get address through after %d attempts\n"

l_.str.6:                               ; @.str.6
	.asciz	"I give up, tried %d times to resend address.\n"

	.comm	_I2C_CR_STOP_ENABLE,4,2         ; @I2C_CR_STOP_ENABLE
	.comm	_I2C_CR,8,3                     ; @I2C_CR
	.comm	_STU300_EVENT_7,4,2             ; @STU300_EVENT_7
	.comm	_I2C_DR,8,3                     ; @I2C_DR
	.comm	_STU300_EVENT_8,4,2             ; @STU300_EVENT_8
l_.str.7:                               ; @.str.7
	.asciz	"error awaiting event 8 (%d)\n"

	.comm	_I2C_M_IGNORE_NAK,4,2           ; @I2C_M_IGNORE_NAK
	.comm	_I2C_SR2,8,3                    ; @I2C_SR2
	.comm	_I2C_SR2_AF_IND,4,2             ; @I2C_SR2_AF_IND
l_.str.8:                               ; @.str.8
	.asciz	"I2C payload send returned NAK!\n"

	.comm	_EIO,4,2                        ; @EIO
l_.str.9:                               ; @.str.9
	.asciz	"timout waiting for transfer to commence.\n"

	.comm	_I2C_SR1,8,3                    ; @I2C_SR1
	.no_dead_strip	_stu300_xfer_msg
.subsections_via_symbols
