	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function dw_mci_hi3660_execute_tuning
_dw_mci_hi3660_execute_tuning:          ## @dw_mci_hi3660_execute_tuning
	.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	$24, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	(%rdi), %rax
	movq	%rax, -48(%rbp)                 ## 8-byte Spill
	movq	8(%rdi), %rax
	movq	_NUM_PHASES@GOTPCREL(%rip), %rcx
	cmpl	$0, (%rcx)
	movq	%rax, -64(%rbp)                 ## 8-byte Spill
	jle	LBB0_1
## %bb.2:
	xorl	%ebx, %ebx
	xorl	%r12d, %r12d
	xorl	%ecx, %ecx
	movl	%esi, -52(%rbp)                 ## 4-byte Spill
	movq	-64(%rbp), %r14                 ## 8-byte Reload
	.p2align	4, 0x90
LBB0_3:                                 ## =>This Inner Loop Header: Depth=1
	movl	%ecx, -56(%rbp)                 ## 4-byte Spill
	leal	31(%r12), %r15d
	testl	%r12d, %r12d
	cmovnsl	%r12d, %r15d
	andl	$-32, %r15d
	movl	%r12d, %r13d
	subl	%r15d, %r13d
	movq	_TMOUT@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r14, %rdi
	movl	$-1, %edx
	callq	_mci_writel
	movq	-48(%rbp), %rax                 ## 8-byte Reload
	movl	(%rax), %esi
	movq	%r14, %rdi
	movl	%r13d, %edx
	callq	_dw_mci_hs_set_timing
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	movl	-52(%rbp), %esi                 ## 4-byte Reload
	xorl	%edx, %edx
	callq	_mmc_send_tuning
	movl	%ebx, %ecx
	btrl	%r13d, %ecx
	btsl	%r13d, %ebx
	testl	%eax, %eax
	cmovnel	%ecx, %ebx
	movl	-56(%rbp), %ecx                 ## 4-byte Reload
	movq	_NUM_PHASES@GOTPCREL(%rip), %rax
	incl	%ecx
	negl	%r15d
	addl	%r15d, %r12d
	incl	%r12d
	cmpl	(%rax), %ecx
	jl	LBB0_3
	jmp	LBB0_4
LBB0_1:
	xorl	%ebx, %ebx
LBB0_4:
	movq	-64(%rbp), %r14                 ## 8-byte Reload
	movl	%ebx, %edi
	callq	_dw_mci_get_best_clksmpl
	testl	%eax, %eax
	js	LBB0_5
## %bb.6:
	movl	%eax, %r12d
	movq	-48(%rbp), %rax                 ## 8-byte Reload
	movl	(%rax), %esi
	movq	%r14, %rdi
	movl	%r12d, %edx
	callq	_dw_mci_hs_set_timing
	movl	(%r14), %edi
	leaq	L_.str.1(%rip), %rsi
	movl	%r12d, %edx
	movl	%ebx, %ecx
	callq	_dev_info
	xorl	%eax, %eax
	jmp	LBB0_7
LBB0_5:
	movl	(%r14), %edi
	leaq	L_.str(%rip), %rsi
	callq	_dev_err
	movq	_EIO@GOTPCREL(%rip), %rcx
	xorl	%eax, %eax
	subl	(%rcx), %eax
LBB0_7:
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_NUM_PHASES,4,2                 ## @NUM_PHASES
	.comm	_TMOUT,4,2                      ## @TMOUT
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"All phases bad!\n"

	.comm	_EIO,4,2                        ## @EIO
L_.str.1:                               ## @.str.1
	.asciz	"tuning ok best_clksmpl %u tuning_sample_flag %x\n"

	.no_dead_strip	_dw_mci_hi3660_execute_tuning
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function dw_mci_hi3660_execute_tuning
_dw_mci_hi3660_execute_tuning:          ; @dw_mci_hi3660_execute_tuning
	.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
	ldp	x21, x19, [x0]
Lloh0:
	adrp	x24, _NUM_PHASES@GOTPAGE
Lloh1:
	ldr	x24, [x24, _NUM_PHASES@GOTPAGEOFF]
	ldr	w8, [x24]
	cmp	w8, #1
	b.lt	LBB0_3
; %bb.1:
	mov	x22, x1
	mov	w20, #0
	mov	w8, #0
	mov	w25, #0
Lloh2:
	adrp	x26, _TMOUT@GOTPAGE
Lloh3:
	ldr	x26, [x26, _TMOUT@GOTPAGEOFF]
	mov	w27, #1
LBB0_2:                                 ; =>This Inner Loop Header: Depth=1
	negs	w9, w8
	and	w9, w9, #0x1f
	and	w8, w8, #0x1f
	csneg	w23, w8, w9, mi
	ldr	w1, [x26]
	mov	x0, x19
	mov	w2, #-1
	bl	_mci_writel
	ldr	w1, [x21]
	mov	x0, x19
	mov	x2, x23
	bl	_dw_mci_hs_set_timing
	mov	x0, x21
	mov	x1, x22
	mov	x2, #0
	bl	_mmc_send_tuning
	lsl	w8, w27, w23
	bic	w9, w20, w8
	orr	w8, w8, w20
	cmp	w0, #0
	csel	w20, w8, w9, eq
	add	w25, w25, #1
	add	w8, w23, #1
	ldr	w9, [x24]
	cmp	w25, w9
	b.lt	LBB0_2
	b	LBB0_4
LBB0_3:
	mov	w20, #0
LBB0_4:
	mov	x0, x20
	bl	_dw_mci_get_best_clksmpl
	tbnz	w0, #31, LBB0_6
; %bb.5:
	mov	x22, x0
	ldr	w1, [x21]
	mov	x0, x19
	mov	x2, x22
	bl	_dw_mci_hs_set_timing
	ldr	w0, [x19]
Lloh4:
	adrp	x1, l_.str.1@PAGE
Lloh5:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x2, x22
	mov	x3, x20
	bl	_dev_info
	mov	w0, #0
	b	LBB0_7
LBB0_6:
	ldr	w0, [x19]
Lloh6:
	adrp	x1, l_.str@PAGE
Lloh7:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_err
Lloh8:
	adrp	x8, _EIO@GOTPAGE
Lloh9:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
Lloh10:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_7:
	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 AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpAdd	Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpAdd	Lloh6, Lloh7
	.cfi_endproc
                                        ; -- End function
	.comm	_NUM_PHASES,4,2                 ; @NUM_PHASES
	.comm	_TMOUT,4,2                      ; @TMOUT
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"All phases bad!\n"

	.comm	_EIO,4,2                        ; @EIO
l_.str.1:                               ; @.str.1
	.asciz	"tuning ok best_clksmpl %u tuning_sample_flag %x\n"

	.no_dead_strip	_dw_mci_hi3660_execute_tuning
.subsections_via_symbols
