	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function msdc_tune_together
_msdc_tune_together:                    ## @msdc_tune_together
	.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
	movl	%esi, %r14d
	movq	%rdi, %r15
	callq	_mmc_priv
	movq	%rax, %r12
	movq	_MSDC_PATCH_BIT@GOTPCREL(%rip), %rax
	movq	(%rax), %rdi
	addq	8(%r12), %rdi
	movq	_MSDC_INT_DAT_LATCH_CK_SEL@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	16(%r12), %edx
	callq	_sdr_set_field
	movq	_MSDC_IOCON@GOTPCREL(%rip), %rbx
	movq	(%rbx), %rdi
	addq	8(%r12), %rdi
	movq	_MSDC_IOCON_RSPL@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_sdr_clr_bits
	movq	(%rbx), %rdi
	addq	8(%r12), %rdi
	movq	_MSDC_IOCON_DSPL@GOTPCREL(%rip), %rax
	movq	_MSDC_IOCON_W_DSPL@GOTPCREL(%rip), %rcx
	movl	(%rcx), %esi
	orl	(%rax), %esi
	callq	_sdr_clr_bits
	movq	_PAD_DELAY_MAX@GOTPCREL(%rip), %rax
	cmpl	$0, (%rax)
	movl	$0, %r13d
	jle	LBB0_5
## %bb.1:
	xorl	%ebx, %ebx
	xorl	%r13d, %r13d
	jmp	LBB0_2
	.p2align	4, 0x90
LBB0_4:                                 ##   in Loop: Header=BB0_2 Depth=1
	orl	%edx, %r13d
	incl	%ebx
	movq	_PAD_DELAY_MAX@GOTPCREL(%rip), %rax
	cmpl	(%rax), %ebx
	jge	LBB0_5
LBB0_2:                                 ## =>This Inner Loop Header: Depth=1
	movq	%r12, %rdi
	movl	%ebx, %esi
	callq	_msdc_set_cmd_delay
	movq	%r12, %rdi
	movl	%ebx, %esi
	callq	_msdc_set_data_delay
	movq	%r15, %rdi
	movl	%r14d, %esi
	xorl	%edx, %edx
	callq	_mmc_send_tuning
	movl	$1, %edx
	movl	%ebx, %ecx
	shll	%cl, %edx
	testl	%eax, %eax
	je	LBB0_4
## %bb.3:                               ##   in Loop: Header=BB0_2 Depth=1
	xorl	%edx, %edx
	jmp	LBB0_4
LBB0_5:
	leaq	-72(%rbp), %rdi
	movq	%r12, %rsi
	movl	%r13d, %edx
	callq	_get_best_delay
	movl	-72(%rbp), %ecx
	movl	-56(%rbp), %eax
	cmpl	$11, %ecx
	movl	%eax, -48(%rbp)                 ## 4-byte Spill
	jle	LBB0_7
## %bb.6:
	xorl	%eax, %eax
	movq	_MSDC_IOCON@GOTPCREL(%rip), %r13
	xorl	%esi, %esi
	jmp	LBB0_16
LBB0_7:
	cmpq	$0, -64(%rbp)
	movq	_MSDC_IOCON@GOTPCREL(%rip), %r13
	movl	$0, %esi
	jne	LBB0_9
## %bb.8:
	movl	$0, %eax
	cmpl	$3, %ecx
	jg	LBB0_16
LBB0_9:
	movl	%ecx, -44(%rbp)                 ## 4-byte Spill
	movq	(%r13), %rdi
	addq	8(%r12), %rdi
	movq	_MSDC_IOCON_RSPL@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_sdr_set_bits
	movq	(%r13), %rdi
	addq	8(%r12), %rdi
	movq	_MSDC_IOCON_W_DSPL@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_MSDC_IOCON_DSPL@GOTPCREL(%rip), %rax
	orl	(%rax), %esi
	callq	_sdr_set_bits
	movq	_PAD_DELAY_MAX@GOTPCREL(%rip), %rax
	cmpl	$0, (%rax)
	jle	LBB0_10
## %bb.11:
	xorl	%r13d, %r13d
	xorl	%ebx, %ebx
	jmp	LBB0_12
	.p2align	4, 0x90
LBB0_14:                                ##   in Loop: Header=BB0_12 Depth=1
	orl	%edx, %ebx
	incl	%r13d
	movq	_PAD_DELAY_MAX@GOTPCREL(%rip), %rax
	cmpl	(%rax), %r13d
	jge	LBB0_15
LBB0_12:                                ## =>This Inner Loop Header: Depth=1
	movq	%r12, %rdi
	movl	%r13d, %esi
	callq	_msdc_set_cmd_delay
	movq	%r12, %rdi
	movl	%r13d, %esi
	callq	_msdc_set_data_delay
	movq	%r15, %rdi
	movl	%r14d, %esi
	xorl	%edx, %edx
	callq	_mmc_send_tuning
	movl	$1, %edx
	movl	%r13d, %ecx
	shll	%cl, %edx
	testl	%eax, %eax
	je	LBB0_14
## %bb.13:                              ##   in Loop: Header=BB0_12 Depth=1
	xorl	%edx, %edx
	jmp	LBB0_14
LBB0_10:
	xorl	%ebx, %ebx
LBB0_15:
	leaq	-72(%rbp), %rdi
	movq	%r12, %rsi
	movl	%ebx, %edx
	callq	_get_best_delay
	movl	-72(%rbp), %esi
	movl	-56(%rbp), %eax
	movq	_MSDC_IOCON@GOTPCREL(%rip), %r13
	movl	-44(%rbp), %ecx                 ## 4-byte Reload
LBB0_16:
	movl	%eax, %r14d
	movl	%ecx, %ebx
	movl	%ecx, %edi
	callq	_max
	movq	(%r13), %rdi
	addq	8(%r12), %rdi
	movq	_MSDC_IOCON_RSPL@GOTPCREL(%rip), %rcx
	movl	(%rcx), %esi
	cmpl	%ebx, %eax
	jne	LBB0_18
## %bb.17:
	callq	_sdr_clr_bits
	movq	(%r13), %rdi
	addq	8(%r12), %rdi
	movq	_MSDC_IOCON_W_DSPL@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_MSDC_IOCON_DSPL@GOTPCREL(%rip), %rax
	orl	(%rax), %esi
	callq	_sdr_clr_bits
	movl	-48(%rbp), %r13d                ## 4-byte Reload
	jmp	LBB0_19
LBB0_18:
	callq	_sdr_set_bits
	movq	(%r13), %rdi
	addq	8(%r12), %rdi
	movq	_MSDC_IOCON_W_DSPL@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_MSDC_IOCON_DSPL@GOTPCREL(%rip), %rax
	orl	(%rax), %esi
	callq	_sdr_set_bits
	movl	%r14d, %r13d
LBB0_19:
	movq	%r12, %rdi
	movl	%r13d, %esi
	callq	_msdc_set_cmd_delay
	movq	%r12, %rdi
	movl	%r13d, %esi
	callq	_msdc_set_data_delay
	movl	(%r12), %edi
	leaq	L_.str(%rip), %rsi
	movl	%r13d, %edx
	callq	_dev_dbg
	movq	_EIO@GOTPCREL(%rip), %rcx
	xorl	%eax, %eax
	subl	(%rcx), %eax
	xorl	%ecx, %ecx
	cmpl	$255, %r13d
	cmovnel	%ecx, %eax
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_MSDC_PATCH_BIT,8,3             ## @MSDC_PATCH_BIT
	.comm	_MSDC_INT_DAT_LATCH_CK_SEL,4,2  ## @MSDC_INT_DAT_LATCH_CK_SEL
	.comm	_MSDC_IOCON,8,3                 ## @MSDC_IOCON
	.comm	_MSDC_IOCON_RSPL,4,2            ## @MSDC_IOCON_RSPL
	.comm	_MSDC_IOCON_DSPL,4,2            ## @MSDC_IOCON_DSPL
	.comm	_MSDC_IOCON_W_DSPL,4,2          ## @MSDC_IOCON_W_DSPL
	.comm	_PAD_DELAY_MAX,4,2              ## @PAD_DELAY_MAX
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Final pad delay: %x\n"

	.comm	_EIO,4,2                        ## @EIO
	.no_dead_strip	_msdc_tune_together
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function msdc_tune_together
_msdc_tune_together:                    ; @msdc_tune_together
	.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, x1
	mov	x21, x0
	bl	_mmc_priv
	mov	x19, x0
	ldr	x8, [x0, #8]
Lloh0:
	adrp	x9, _MSDC_PATCH_BIT@GOTPAGE
Lloh1:
	ldr	x9, [x9, _MSDC_PATCH_BIT@GOTPAGEOFF]
Lloh2:
	ldr	x9, [x9]
	add	x0, x9, x8
Lloh3:
	adrp	x8, _MSDC_INT_DAT_LATCH_CK_SEL@GOTPAGE
Lloh4:
	ldr	x8, [x8, _MSDC_INT_DAT_LATCH_CK_SEL@GOTPAGEOFF]
Lloh5:
	ldr	w1, [x8]
	ldr	w2, [x19, #16]
	bl	_sdr_set_field
Lloh6:
	adrp	x25, _MSDC_IOCON@GOTPAGE
Lloh7:
	ldr	x25, [x25, _MSDC_IOCON@GOTPAGEOFF]
	ldr	x8, [x19, #8]
	ldr	x9, [x25]
	add	x0, x9, x8
Lloh8:
	adrp	x8, _MSDC_IOCON_RSPL@GOTPAGE
Lloh9:
	ldr	x8, [x8, _MSDC_IOCON_RSPL@GOTPAGEOFF]
Lloh10:
	ldr	w1, [x8]
	bl	_sdr_clr_bits
	ldr	x8, [x19, #8]
	ldr	x9, [x25]
Lloh11:
	adrp	x28, _MSDC_IOCON_DSPL@GOTPAGE
Lloh12:
	ldr	x28, [x28, _MSDC_IOCON_DSPL@GOTPAGEOFF]
	add	x0, x9, x8
	ldr	w8, [x28]
Lloh13:
	adrp	x9, _MSDC_IOCON_W_DSPL@GOTPAGE
Lloh14:
	ldr	x9, [x9, _MSDC_IOCON_W_DSPL@GOTPAGEOFF]
Lloh15:
	ldr	w9, [x9]
	orr	w1, w9, w8
	bl	_sdr_clr_bits
Lloh16:
	adrp	x27, _PAD_DELAY_MAX@GOTPAGE
Lloh17:
	ldr	x27, [x27, _PAD_DELAY_MAX@GOTPAGEOFF]
	ldr	w8, [x27]
	cmp	w8, #1
	b.lt	LBB0_3
; %bb.1:
	mov	w23, #0
	mov	w22, #0
	mov	w24, #1
LBB0_2:                                 ; =>This Inner Loop Header: Depth=1
	mov	x0, x19
	mov	x1, x23
	bl	_msdc_set_cmd_delay
	mov	x0, x19
	mov	x1, x23
	bl	_msdc_set_data_delay
	mov	x0, x21
	mov	x1, x20
	mov	x2, #0
	bl	_mmc_send_tuning
	lsl	w8, w24, w23
	cmp	w0, #0
	csel	w8, w8, wzr, eq
	orr	w22, w8, w22
	add	w23, w23, #1
	ldr	w8, [x27]
	cmp	w23, w8
	b.lt	LBB0_2
	b	LBB0_4
LBB0_3:
	mov	w22, #0
LBB0_4:
	add	x8, sp, #8
	mov	x0, x19
	mov	x1, x22
	bl	_get_best_delay
	ldr	w22, [sp, #8]
	ldr	w26, [sp, #24]
	cmp	w22, #11
	b.gt	LBB0_7
; %bb.5:
	ldr	x8, [sp, #16]
	cbnz	x8, LBB0_8
; %bb.6:
	cmp	w22, #3
	b.le	LBB0_8
LBB0_7:
	mov	w1, #0
	mov	w20, #0
	b	LBB0_13
LBB0_8:
	ldr	x8, [x19, #8]
	ldr	x9, [x25]
	add	x0, x9, x8
Lloh18:
	adrp	x8, _MSDC_IOCON_RSPL@GOTPAGE
Lloh19:
	ldr	x8, [x8, _MSDC_IOCON_RSPL@GOTPAGEOFF]
Lloh20:
	ldr	w1, [x8]
	bl	_sdr_set_bits
	ldr	x8, [x19, #8]
	ldr	x9, [x25]
	add	x0, x9, x8
	ldr	w8, [x28]
Lloh21:
	adrp	x9, _MSDC_IOCON_W_DSPL@GOTPAGE
Lloh22:
	ldr	x9, [x9, _MSDC_IOCON_W_DSPL@GOTPAGEOFF]
Lloh23:
	ldr	w9, [x9]
	orr	w1, w9, w8
	bl	_sdr_set_bits
	ldr	w8, [x27]
	cmp	w8, #1
	b.lt	LBB0_11
; %bb.9:
	mov	w24, #0
	mov	w23, #0
	mov	w28, #1
LBB0_10:                                ; =>This Inner Loop Header: Depth=1
	mov	x0, x19
	mov	x1, x24
	bl	_msdc_set_cmd_delay
	mov	x0, x19
	mov	x1, x24
	bl	_msdc_set_data_delay
	mov	x0, x21
	mov	x1, x20
	mov	x2, #0
	bl	_mmc_send_tuning
	lsl	w8, w28, w24
	cmp	w0, #0
	csel	w8, w8, wzr, eq
	orr	w23, w8, w23
	add	w24, w24, #1
	ldr	w8, [x27]
	cmp	w24, w8
	b.lt	LBB0_10
	b	LBB0_12
LBB0_11:
	mov	w23, #0
LBB0_12:
	add	x8, sp, #8
	mov	x0, x19
	mov	x1, x23
	bl	_get_best_delay
	ldr	w1, [sp, #8]
	ldr	w20, [sp, #24]
Lloh24:
	adrp	x28, _MSDC_IOCON_DSPL@GOTPAGE
Lloh25:
	ldr	x28, [x28, _MSDC_IOCON_DSPL@GOTPAGEOFF]
LBB0_13:
	mov	x0, x22
	bl	_max
	mov	x8, x0
	ldr	x9, [x19, #8]
	ldr	x10, [x25]
	add	x0, x10, x9
Lloh26:
	adrp	x9, _MSDC_IOCON_RSPL@GOTPAGE
Lloh27:
	ldr	x9, [x9, _MSDC_IOCON_RSPL@GOTPAGEOFF]
Lloh28:
	ldr	w1, [x9]
	cmp	w8, w22
	b.ne	LBB0_15
; %bb.14:
	bl	_sdr_clr_bits
	ldr	x8, [x19, #8]
	ldr	x9, [x25]
	add	x0, x9, x8
	ldr	w8, [x28]
Lloh29:
	adrp	x9, _MSDC_IOCON_W_DSPL@GOTPAGE
Lloh30:
	ldr	x9, [x9, _MSDC_IOCON_W_DSPL@GOTPAGEOFF]
Lloh31:
	ldr	w9, [x9]
	orr	w1, w9, w8
	bl	_sdr_clr_bits
	mov	x20, x26
	b	LBB0_16
LBB0_15:
	bl	_sdr_set_bits
	ldr	x8, [x19, #8]
	ldr	x9, [x25]
	add	x0, x9, x8
	ldr	w8, [x28]
Lloh32:
	adrp	x9, _MSDC_IOCON_W_DSPL@GOTPAGE
Lloh33:
	ldr	x9, [x9, _MSDC_IOCON_W_DSPL@GOTPAGEOFF]
Lloh34:
	ldr	w9, [x9]
	orr	w1, w9, w8
	bl	_sdr_set_bits
LBB0_16:
	mov	x0, x19
	mov	x1, x20
	bl	_msdc_set_cmd_delay
	mov	x0, x19
	mov	x1, x20
	bl	_msdc_set_data_delay
	ldr	w0, [x19]
Lloh35:
	adrp	x1, l_.str@PAGE
Lloh36:
	add	x1, x1, l_.str@PAGEOFF
	mov	x2, x20
	bl	_dev_dbg
Lloh37:
	adrp	x8, _EIO@GOTPAGE
Lloh38:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
Lloh39:
	ldr	w8, [x8]
	cmp	w20, #255
	csneg	w0, wzr, w8, ne
	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
	.loh AdrpLdrGot	Lloh16, Lloh17
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGot	Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpLdrGot	Lloh24, Lloh25
	.loh AdrpLdrGotLdr	Lloh26, Lloh27, Lloh28
	.loh AdrpLdrGotLdr	Lloh29, Lloh30, Lloh31
	.loh AdrpLdrGotLdr	Lloh32, Lloh33, Lloh34
	.loh AdrpLdrGotLdr	Lloh37, Lloh38, Lloh39
	.loh AdrpAdd	Lloh35, Lloh36
	.cfi_endproc
                                        ; -- End function
	.comm	_MSDC_PATCH_BIT,8,3             ; @MSDC_PATCH_BIT
	.comm	_MSDC_INT_DAT_LATCH_CK_SEL,4,2  ; @MSDC_INT_DAT_LATCH_CK_SEL
	.comm	_MSDC_IOCON,8,3                 ; @MSDC_IOCON
	.comm	_MSDC_IOCON_RSPL,4,2            ; @MSDC_IOCON_RSPL
	.comm	_MSDC_IOCON_DSPL,4,2            ; @MSDC_IOCON_DSPL
	.comm	_MSDC_IOCON_W_DSPL,4,2          ; @MSDC_IOCON_W_DSPL
	.comm	_PAD_DELAY_MAX,4,2              ; @PAD_DELAY_MAX
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Final pad delay: %x\n"

	.comm	_EIO,4,2                        ; @EIO
	.no_dead_strip	_msdc_tune_together
.subsections_via_symbols
