	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mtk_i2c_transfer
_mtk_i2c_transfer:                      ## @mtk_i2c_transfer
	.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, %r14d
	movq	%rsi, %rbx
	callq	_i2c_get_adapdata
	movq	%rax, %r15
	movq	%rax, %rdi
	callq	_mtk_i2c_clock_enable
	testl	%eax, %eax
	jne	LBB0_26
## %bb.1:
	movq	32(%r15), %rax
	movq	(%rax), %rax
	movq	%rax, 16(%r15)
	cmpl	$2, %r14d
	jne	LBB0_7
## %bb.2:
	testq	%rax, %rax
	je	LBB0_7
## %bb.3:
	movq	_I2C_M_RD@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movl	$1, %eax
	testl	%ecx, (%rbx)
	je	LBB0_4
LBB0_7:
	cmpl	$2, %r14d
	setge	%r13b
	jl	LBB0_13
## %bb.8:
	testq	%rax, %rax
	je	LBB0_13
## %bb.9:
	movq	(%r15), %rcx
	movq	_MAX_FS_MODE_SPEED@GOTPCREL(%rip), %rdx
	movl	$1, %eax
	cmpq	(%rdx), %rcx
	jle	LBB0_10
	jmp	LBB0_11
LBB0_13:
	movl	$0, 8(%r15)
	testl	%r14d, %r14d
	jne	LBB0_12
## %bb.14:
	xorl	%r14d, %r14d
	jmp	LBB0_25
LBB0_4:
	testl	%ecx, 24(%rbx)
	je	LBB0_7
## %bb.5:
	movq	8(%rbx), %rcx
	cmpq	32(%rbx), %rcx
	jne	LBB0_7
## %bb.6:
	movq	$0, 16(%r15)
LBB0_10:
	xorl	%eax, %eax
LBB0_11:
	movl	%eax, 8(%r15)
	movb	$1, %r13b
LBB0_12:
	xorb	$1, %r13b
	movl	%r14d, %r12d
	.p2align	4, 0x90
LBB0_16:                                ## =>This Inner Loop Header: Depth=1
	cmpl	$0, 16(%rbx)
	je	LBB0_17
## %bb.18:                              ##   in Loop: Header=BB0_16 Depth=1
	movq	_I2C_M_RD@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movq	_I2C_MASTER_RD@GOTPCREL(%rip), %rax
	andl	(%rbx), %ecx
	jne	LBB0_20
## %bb.19:                              ##   in Loop: Header=BB0_16 Depth=1
	movq	_I2C_MASTER_WR@GOTPCREL(%rip), %rax
LBB0_20:                                ##   in Loop: Header=BB0_16 Depth=1
	movl	(%rax), %eax
	movl	%eax, 12(%r15)
	cmpq	$0, 16(%r15)
	setne	%al
	orb	%r13b, %al
	jne	LBB0_21
## %bb.22:                              ##   in Loop: Header=BB0_16 Depth=1
	movq	_I2C_MASTER_WRRD@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 12(%r15)
	addl	$-2, %r12d
	jmp	LBB0_23
	.p2align	4, 0x90
LBB0_21:                                ##   in Loop: Header=BB0_16 Depth=1
	decl	%r12d
LBB0_23:                                ##   in Loop: Header=BB0_16 Depth=1
	movq	%r15, %rdi
	movq	%rbx, %rsi
	movl	%r14d, %edx
	movl	%r12d, %ecx
	callq	_mtk_i2c_do_transfer
	testl	%eax, %eax
	js	LBB0_24
## %bb.15:                              ##   in Loop: Header=BB0_16 Depth=1
	addq	$24, %rbx
	testl	%r12d, %r12d
	jne	LBB0_16
	jmp	LBB0_25
LBB0_17:
	movl	24(%r15), %edi
	leaq	L_.str(%rip), %rsi
	callq	_dev_dbg
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%r14d, %r14d
	subl	(%rax), %r14d
	jmp	LBB0_25
LBB0_24:
	movl	%eax, %r14d
LBB0_25:
	movq	%r15, %rdi
	callq	_mtk_i2c_clock_disable
	movl	%r14d, %eax
LBB0_26:
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_I2C_M_RD,4,2                   ## @I2C_M_RD
	.comm	_MAX_FS_MODE_SPEED,8,3          ## @MAX_FS_MODE_SPEED
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"data buffer is NULL.\n"

	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_I2C_MASTER_RD,4,2              ## @I2C_MASTER_RD
	.comm	_I2C_MASTER_WR,4,2              ## @I2C_MASTER_WR
	.comm	_I2C_MASTER_WRRD,4,2            ## @I2C_MASTER_WRRD
	.no_dead_strip	_mtk_i2c_transfer
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mtk_i2c_transfer
_mtk_i2c_transfer:                      ; @mtk_i2c_transfer
	.cfi_startproc
; %bb.0:
	stp	x28, x27, [sp, #-96]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 96
	stp	x26, x25, [sp, #16]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #32]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #48]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #64]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #80]             ; 16-byte Folded Spill
	add	x29, sp, #80
	.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
	bl	_mtk_i2c_clock_enable
	cbnz	w0, LBB0_25
; %bb.1:
	ldr	x8, [x19, #32]
	ldr	x8, [x8]
	str	x8, [x19, #16]
Lloh0:
	adrp	x23, _I2C_M_RD@GOTPAGE
Lloh1:
	ldr	x23, [x23, _I2C_M_RD@GOTPAGEOFF]
	cmp	w20, #2
	b.ne	LBB0_5
; %bb.2:
	cbz	x8, LBB0_5
; %bb.3:
	ldr	w9, [x21]
	ldr	w8, [x23]
	tst	w8, w9
	b.eq	LBB0_10
LBB0_4:
	mov	w8, #1
LBB0_5:
	cmp	w20, #1
	cset	w9, gt
	cmp	w20, #2
	b.lt	LBB0_9
; %bb.6:
	cbz	x8, LBB0_9
; %bb.7:
	ldr	x8, [x19]
Lloh2:
	adrp	x9, _MAX_FS_MODE_SPEED@GOTPAGE
Lloh3:
	ldr	x9, [x9, _MAX_FS_MODE_SPEED@GOTPAGEOFF]
Lloh4:
	ldr	x9, [x9]
	cmp	x8, x9
	b.le	LBB0_13
; %bb.8:
	mov	w8, #1
	b	LBB0_14
LBB0_9:
	str	wzr, [x19, #8]
	cbnz	w20, LBB0_15
	b	LBB0_24
LBB0_10:
	ldr	w9, [x21, #24]
	tst	w9, w8
	b.eq	LBB0_4
; %bb.11:
	ldr	x8, [x21, #8]
	ldr	x9, [x21, #32]
	cmp	x8, x9
	b.ne	LBB0_4
; %bb.12:
	str	xzr, [x19, #16]
LBB0_13:
	mov	w8, #0
LBB0_14:
	str	w8, [x19, #8]
	mov	w9, #1
LBB0_15:
Lloh5:
	adrp	x24, _I2C_MASTER_WR@GOTPAGE
Lloh6:
	ldr	x24, [x24, _I2C_MASTER_WR@GOTPAGEOFF]
Lloh7:
	adrp	x25, _I2C_MASTER_RD@GOTPAGE
Lloh8:
	ldr	x25, [x25, _I2C_MASTER_RD@GOTPAGEOFF]
	eor	w26, w9, #0x1
	mov	x22, x20
Lloh9:
	adrp	x27, _I2C_MASTER_WRRD@GOTPAGE
Lloh10:
	ldr	x27, [x27, _I2C_MASTER_WRRD@GOTPAGEOFF]
LBB0_16:                                ; =>This Inner Loop Header: Depth=1
	ldr	w8, [x21, #16]
	cbz	w8, LBB0_22
; %bb.17:                               ;   in Loop: Header=BB0_16 Depth=1
	ldr	w8, [x21]
	ldr	w9, [x23]
	tst	w9, w8
	csel	x8, x24, x25, eq
	ldr	w8, [x8]
	str	w8, [x19, #12]
	ldr	x8, [x19, #16]
	cmp	x8, #0
	cset	w8, ne
	orr	w8, w26, w8
	tbnz	w8, #0, LBB0_19
; %bb.18:                               ;   in Loop: Header=BB0_16 Depth=1
	ldr	w8, [x27]
	str	w8, [x19, #12]
	sub	w22, w22, #2
	b	LBB0_20
LBB0_19:                                ;   in Loop: Header=BB0_16 Depth=1
	sub	w22, w22, #1
LBB0_20:                                ;   in Loop: Header=BB0_16 Depth=1
	mov	x0, x19
	mov	x1, x21
	mov	x2, x20
	mov	x3, x22
	bl	_mtk_i2c_do_transfer
	tbnz	w0, #31, LBB0_23
; %bb.21:                               ;   in Loop: Header=BB0_16 Depth=1
	add	x21, x21, #24
	cbnz	w22, LBB0_16
	b	LBB0_24
LBB0_22:
	ldr	w0, [x19, #24]
Lloh11:
	adrp	x1, l_.str@PAGE
Lloh12:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_dbg
Lloh13:
	adrp	x8, _EINVAL@GOTPAGE
Lloh14:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh15:
	ldr	w8, [x8]
	neg	w20, w8
	b	LBB0_24
LBB0_23:
	mov	x20, x0
LBB0_24:
	mov	x0, x19
	bl	_mtk_i2c_clock_disable
	mov	x0, x20
LBB0_25:
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp], #96             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh9, Lloh10
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpAdd	Lloh11, Lloh12
	.cfi_endproc
                                        ; -- End function
	.comm	_I2C_M_RD,4,2                   ; @I2C_M_RD
	.comm	_MAX_FS_MODE_SPEED,8,3          ; @MAX_FS_MODE_SPEED
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"data buffer is NULL.\n"

	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_I2C_MASTER_RD,4,2              ; @I2C_MASTER_RD
	.comm	_I2C_MASTER_WR,4,2              ; @I2C_MASTER_WR
	.comm	_I2C_MASTER_WRRD,4,2            ; @I2C_MASTER_WRRD
	.no_dead_strip	_mtk_i2c_transfer
.subsections_via_symbols
