	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mtk_i2c_calculate_speed
_mtk_i2c_calculate_speed:               ## @mtk_i2c_calculate_speed
	.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
	subq	$40, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%r8, %r15
	movq	%rcx, -72(%rbp)                 ## 8-byte Spill
	movl	%edx, %ebx
	movq	%rdi, -64(%rbp)                 ## 8-byte Spill
	movq	_MAX_HS_MODE_SPEED@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	cmpl	%edx, %eax
	cmovbl	%eax, %ebx
	movq	_MAX_FS_MODE_SPEED@GOTPCREL(%rip), %rax
	cmpl	(%rax), %ebx
	jbe	LBB0_1
## %bb.2:
	movq	_MAX_HS_STEP_CNT_DIV@GOTPCREL(%rip), %rax
	jmp	LBB0_3
LBB0_1:
	movq	_MAX_STEP_CNT_DIV@GOTPCREL(%rip), %rax
LBB0_3:
	movq	_MAX_SAMPLE_CNT_DIV@GOTPCREL(%rip), %r13
	movl	(%r13), %ecx
	movl	%ecx, -44(%rbp)                 ## 4-byte Spill
	movl	(%rax), %r12d
	movl	%esi, -48(%rbp)                 ## 4-byte Spill
	movl	%esi, %edi
	shrl	%edi
	movl	%ebx, %esi
	callq	_DIV_ROUND_UP
	movl	(%r13), %r13d
	testl	%r13d, %r13d
	movq	%r15, -80(%rbp)                 ## 8-byte Spill
	movl	%ebx, -52(%rbp)                 ## 4-byte Spill
	je	LBB0_4
## %bb.5:
	movl	%eax, %r14d
	imull	%r12d, %r13d
	movl	$1, %r15d
	movl	%r12d, %ebx
	jmp	LBB0_6
	.p2align	4, 0x90
LBB0_10:                                ##   in Loop: Header=BB0_6 Depth=1
	incl	%r15d
	movq	_MAX_SAMPLE_CNT_DIV@GOTPCREL(%rip), %rax
	cmpl	(%rax), %r15d
	ja	LBB0_11
LBB0_6:                                 ## =>This Inner Loop Header: Depth=1
	movl	%r14d, %edi
	movl	%r15d, %esi
	callq	_DIV_ROUND_UP
	cmpl	%r12d, %eax
	ja	LBB0_10
## %bb.7:                               ##   in Loop: Header=BB0_6 Depth=1
	movl	%eax, %ecx
	imull	%r15d, %ecx
	cmpl	%r13d, %ecx
	jae	LBB0_10
## %bb.8:                               ##   in Loop: Header=BB0_6 Depth=1
	movl	%r15d, -44(%rbp)                ## 4-byte Spill
	movl	%eax, %ebx
	movl	%ecx, %r13d
	cmpl	%r14d, %ecx
	jne	LBB0_10
## %bb.9:
	movl	%r15d, -44(%rbp)                ## 4-byte Spill
	movl	%eax, %ebx
	jmp	LBB0_11
LBB0_4:
	movl	%r12d, %ebx
LBB0_11:
	movl	-44(%rbp), %edi                 ## 4-byte Reload
	movl	%edi, %esi
	imull	%ebx, %esi
	addl	%esi, %esi
	xorl	%ecx, %ecx
	movl	-48(%rbp), %eax                 ## 4-byte Reload
	xorl	%edx, %edx
	divl	%esi
	movl	-52(%rbp), %edx                 ## 4-byte Reload
	cmpl	%edx, %eax
	jbe	LBB0_13
## %bb.12:
	movq	-64(%rbp), %rax                 ## 8-byte Reload
	movl	(%rax), %edi
	leaq	L_.str(%rip), %rsi
	callq	_dev_dbg
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%ecx, %ecx
	subl	(%rax), %ecx
	jmp	LBB0_14
LBB0_13:
	decl	%ebx
	movq	-72(%rbp), %rax                 ## 8-byte Reload
	movl	%ebx, (%rax)
	decl	%edi
	movq	-80(%rbp), %rax                 ## 8-byte Reload
	movl	%edi, (%rax)
LBB0_14:
	movl	%ecx, %eax
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_MAX_SAMPLE_CNT_DIV,4,2         ## @MAX_SAMPLE_CNT_DIV
	.comm	_MAX_HS_MODE_SPEED,4,2          ## @MAX_HS_MODE_SPEED
	.comm	_MAX_FS_MODE_SPEED,4,2          ## @MAX_FS_MODE_SPEED
	.comm	_MAX_HS_STEP_CNT_DIV,4,2        ## @MAX_HS_STEP_CNT_DIV
	.comm	_MAX_STEP_CNT_DIV,4,2           ## @MAX_STEP_CNT_DIV
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Unsupported speed (%uhz)\n"

	.comm	_EINVAL,4,2                     ## @EINVAL
	.no_dead_strip	_mtk_i2c_calculate_speed
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mtk_i2c_calculate_speed
_mtk_i2c_calculate_speed:               ; @mtk_i2c_calculate_speed
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x28, x27, [sp, #16]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.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, x4
	mov	x21, x3
	mov	x23, x1
	mov	x25, x0
	lsr	w0, w1, #1
Lloh0:
	adrp	x27, _MAX_SAMPLE_CNT_DIV@GOTPAGE
Lloh1:
	ldr	x27, [x27, _MAX_SAMPLE_CNT_DIV@GOTPAGEOFF]
	ldr	w26, [x27]
Lloh2:
	adrp	x8, _MAX_HS_MODE_SPEED@GOTPAGE
Lloh3:
	ldr	x8, [x8, _MAX_HS_MODE_SPEED@GOTPAGEOFF]
Lloh4:
	ldr	w8, [x8]
	cmp	w8, w2
	csel	w22, w8, w2, lo
Lloh5:
	adrp	x8, _MAX_FS_MODE_SPEED@GOTPAGE
Lloh6:
	ldr	x8, [x8, _MAX_FS_MODE_SPEED@GOTPAGEOFF]
Lloh7:
	adrp	x9, _MAX_HS_STEP_CNT_DIV@GOTPAGE
Lloh8:
	ldr	x9, [x9, _MAX_HS_STEP_CNT_DIV@GOTPAGEOFF]
Lloh9:
	ldr	w8, [x8]
	cmp	w22, w8
Lloh10:
	adrp	x8, _MAX_STEP_CNT_DIV@GOTPAGE
Lloh11:
	ldr	x8, [x8, _MAX_STEP_CNT_DIV@GOTPAGEOFF]
	csel	x8, x9, x8, hi
	ldr	w19, [x8]
	mov	x1, x22
	bl	_DIV_ROUND_UP
	ldr	w8, [x27]
	stp	x25, x20, [sp]                  ; 16-byte Folded Spill
	cbz	w8, LBB0_7
; %bb.1:
	mov	x24, x0
	mul	w20, w8, w19
	mov	w25, #1
	mov	x28, x19
	b	LBB0_3
LBB0_2:                                 ;   in Loop: Header=BB0_3 Depth=1
	add	w25, w25, #1
	ldr	w8, [x27]
	cmp	w25, w8
	b.hi	LBB0_8
LBB0_3:                                 ; =>This Inner Loop Header: Depth=1
	mov	x0, x24
	mov	x1, x25
	bl	_DIV_ROUND_UP
	cmp	w0, w19
	b.hi	LBB0_2
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=1
	mul	w8, w0, w25
	cmp	w8, w20
	b.hs	LBB0_2
; %bb.5:                                ;   in Loop: Header=BB0_3 Depth=1
	mov	x26, x25
	mov	x28, x0
	mov	x20, x8
	cmp	w8, w24
	b.ne	LBB0_2
; %bb.6:
	mov	x26, x25
	mov	x28, x0
	b	LBB0_8
LBB0_7:
	mov	x28, x19
LBB0_8:
	mul	w8, w26, w28
	lsl	w8, w8, #1
	udiv	w8, w23, w8
	cmp	w8, w22
	b.ls	LBB0_10
; %bb.9:
	ldr	x8, [sp]                        ; 8-byte Folded Reload
	ldr	w0, [x8]
Lloh12:
	adrp	x1, l_.str@PAGE
Lloh13:
	add	x1, x1, l_.str@PAGEOFF
	mov	x2, x22
	bl	_dev_dbg
Lloh14:
	adrp	x8, _EINVAL@GOTPAGE
Lloh15:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh16:
	ldr	w8, [x8]
	neg	w0, w8
	b	LBB0_11
LBB0_10:
	mov	w0, #0
	sub	w8, w28, #1
	str	w8, [x21]
	sub	w8, w26, #1
	ldr	x9, [sp, #8]                    ; 8-byte Folded Reload
	str	w8, [x9]
LBB0_11:
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
	.loh AdrpLdrGot	Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh9
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpAdd	Lloh12, Lloh13
	.cfi_endproc
                                        ; -- End function
	.comm	_MAX_SAMPLE_CNT_DIV,4,2         ; @MAX_SAMPLE_CNT_DIV
	.comm	_MAX_HS_MODE_SPEED,4,2          ; @MAX_HS_MODE_SPEED
	.comm	_MAX_FS_MODE_SPEED,4,2          ; @MAX_FS_MODE_SPEED
	.comm	_MAX_HS_STEP_CNT_DIV,4,2        ; @MAX_HS_STEP_CNT_DIV
	.comm	_MAX_STEP_CNT_DIV,4,2           ; @MAX_STEP_CNT_DIV
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Unsupported speed (%uhz)\n"

	.comm	_EINVAL,4,2                     ; @EINVAL
	.no_dead_strip	_mtk_i2c_calculate_speed
.subsections_via_symbols
