	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function renesas_sdhi_select_tuning
_renesas_sdhi_select_tuning:            ## @renesas_sdhi_select_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, %r12
	callq	_host_to_priv
	movq	%rax, %rsi
	movq	_SH_MOBILE_SDHI_SCC_RVSREQ@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	xorl	%r13d, %r13d
	movq	%r12, %rdi
	movq	%rsi, -56(%rbp)                 ## 8-byte Spill
	xorl	%ecx, %ecx
	callq	_sd_scc_write32
	movl	(%r12), %r14d
	testl	%r14d, %r14d
	je	LBB0_1
## %bb.4:
	xorl	%ebx, %ebx
	jmp	LBB0_5
	.p2align	4, 0x90
LBB0_7:                                 ##   in Loop: Header=BB0_5 Depth=1
	incq	%rbx
	movslq	(%r12), %r14
	movq	%r14, %rax
	addq	%r14, %rax
	cmpq	%rax, %rbx
	jae	LBB0_2
LBB0_5:                                 ## =>This Inner Loop Header: Depth=1
	movl	16(%r12), %esi
	movq	%rbx, %rdi
	callq	_test_bit
	testq	%rax, %rax
	jne	LBB0_7
## %bb.6:                               ##   in Loop: Header=BB0_5 Depth=1
	movslq	%r14d, %rax
	movl	%eax, %ecx
	negl	%ecx
	cmpq	%rax, %rbx
	cmovbl	%eax, %ecx
	movslq	%ecx, %rdi
	addq	%rbx, %rdi
	movl	16(%r12), %esi
	callq	_clear_bit
	jmp	LBB0_7
LBB0_2:
	testl	%r14d, %r14d
	je	LBB0_3
## %bb.8:
	xorl	%ebx, %ebx
	xorl	%r14d, %r14d
	xorl	%eax, %eax
	movq	%rax, -48(%rbp)                 ## 8-byte Spill
	xorl	%r15d, %r15d
	xorl	%r13d, %r13d
	jmp	LBB0_9
	.p2align	4, 0x90
LBB0_11:                                ##   in Loop: Header=BB0_9 Depth=1
	movq	%rbx, %rax
	subq	%r14, %rax
	cmpq	%r13, %r14
	cmovaq	%r14, %r13
	leaq	-1(%rbx), %rcx
	cmovaq	%rax, %r15
	movq	-48(%rbp), %rax                 ## 8-byte Reload
	cmovaq	%rcx, %rax
	movq	%rax, -48(%rbp)                 ## 8-byte Spill
	xorl	%r14d, %r14d
LBB0_12:                                ##   in Loop: Header=BB0_9 Depth=1
	incq	%rbx
	movslq	(%r12), %rcx
	leaq	(%rcx,%rcx), %rax
	cmpq	%rax, %rbx
	jae	LBB0_13
LBB0_9:                                 ## =>This Inner Loop Header: Depth=1
	movl	16(%r12), %esi
	movq	%rbx, %rdi
	callq	_test_bit
	testq	%rax, %rax
	je	LBB0_11
## %bb.10:                              ##   in Loop: Header=BB0_9 Depth=1
	incq	%r14
	jmp	LBB0_12
LBB0_3:
	xorl	%r13d, %r13d
LBB0_1:
	xorl	%r15d, %r15d
	xorl	%eax, %eax
	movq	%rax, -48(%rbp)                 ## 8-byte Spill
	xorl	%r14d, %r14d
	xorl	%ebx, %ebx
	xorl	%ecx, %ecx
LBB0_13:
	cmpq	%r13, %r14
	movq	%r13, %rax
	cmovaq	%r14, %rax
	movq	_SH_MOBILE_SDHI_MAX_TAP@GOTPCREL(%rip), %rdx
	cmpq	(%rdx), %rax
	jae	LBB0_14
## %bb.18:
	movq	_EIO@GOTPCREL(%rip), %rcx
	xorl	%eax, %eax
	subl	(%rcx), %eax
	jmp	LBB0_19
LBB0_14:
	leaq	-1(%rbx), %rax
	subq	%r14, %rbx
	cmpq	%r13, %r14
	movq	-48(%rbp), %rdx                 ## 8-byte Reload
	cmovaq	%rax, %rdx
	cmovaq	%rbx, %r15
	addq	%rdx, %r15
	shrq	%r15
	movq	%r15, %rax
	orq	%rcx, %rax
	shrq	$32, %rax
	je	LBB0_15
## %bb.16:
	movq	%r15, %rax
	xorl	%edx, %edx
	divq	%rcx
	movq	%rdx, %rcx
	jmp	LBB0_17
LBB0_15:
	movl	%r15d, %eax
	xorl	%edx, %edx
	divl	%ecx
	movl	%edx, %ecx
LBB0_17:
	movq	%rcx, 8(%r12)
	movq	_SH_MOBILE_SDHI_SCC_TAPSET@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r12, %rdi
	movq	-56(%rbp), %r14                 ## 8-byte Reload
	movq	%r14, %rsi
                                        ## kill: def $ecx killed $ecx killed $rcx
	callq	_sd_scc_write32
	movq	_SH_MOBILE_SDHI_SCC_RVSCNTL@GOTPCREL(%rip), %rax
	movl	(%rax), %r15d
	movq	_SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	movq	%r12, %rdi
	movq	%r14, %rsi
	movl	%r15d, %edx
	callq	_sd_scc_read32
	orl	%eax, %ebx
	movq	%r12, %rdi
	movq	%r14, %rsi
	movl	%r15d, %edx
	movl	%ebx, %ecx
	callq	_sd_scc_write32
	xorl	%eax, %eax
LBB0_19:
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_SH_MOBILE_SDHI_SCC_RVSREQ,4,2  ## @SH_MOBILE_SDHI_SCC_RVSREQ
	.comm	_SH_MOBILE_SDHI_MAX_TAP,8,3     ## @SH_MOBILE_SDHI_MAX_TAP
	.comm	_EIO,4,2                        ## @EIO
	.comm	_SH_MOBILE_SDHI_SCC_TAPSET,4,2  ## @SH_MOBILE_SDHI_SCC_TAPSET
	.comm	_SH_MOBILE_SDHI_SCC_RVSCNTL,4,2 ## @SH_MOBILE_SDHI_SCC_RVSCNTL
	.comm	_SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN,4,2 ## @SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN
	.no_dead_strip	_renesas_sdhi_select_tuning
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function renesas_sdhi_select_tuning
_renesas_sdhi_select_tuning:            ; @renesas_sdhi_select_tuning
	.cfi_startproc
; %bb.0:
	stp	x26, x25, [sp, #-80]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.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
	mov	x19, x0
	bl	_host_to_priv
	mov	x20, x0
Lloh0:
	adrp	x8, _SH_MOBILE_SDHI_SCC_RVSREQ@GOTPAGE
Lloh1:
	ldr	x8, [x8, _SH_MOBILE_SDHI_SCC_RVSREQ@GOTPAGEOFF]
Lloh2:
	ldr	w2, [x8]
	mov	x0, x19
	mov	x1, x20
	mov	w3, #0
	bl	_sd_scc_write32
	ldr	w22, [x19]
	cbz	w22, LBB0_8
; %bb.1:
	mov	x21, #0
	b	LBB0_3
LBB0_2:                                 ;   in Loop: Header=BB0_3 Depth=1
	add	x21, x21, #1
	ldrsw	x22, [x19]
	cmp	x21, x22, lsl #1
	b.hs	LBB0_5
LBB0_3:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w1, [x19, #16]
	mov	x0, x21
	bl	_test_bit
	cbnz	x0, LBB0_2
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=1
	cmp	x21, w22, sxtw
	cneg	w8, w22, hs
	add	x0, x21, w8, sxtw
	ldr	w1, [x19, #16]
	bl	_clear_bit
	b	LBB0_2
LBB0_5:
	cbz	w22, LBB0_8
; %bb.6:
	mov	x21, #0
	mov	x25, #0
	mov	x24, #0
	mov	x22, #0
	mov	x23, #0
LBB0_7:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w1, [x19, #16]
	mov	x0, x21
	bl	_test_bit
	sub	x8, x21, x25
	sub	x9, x21, #1
	cmp	x25, x23
	csel	x10, x25, x23, hi
	csel	x8, x8, x22, hi
	csel	x9, x9, x24, hi
	cmp	x0, #0
	csel	x23, x10, x23, eq
	csel	x22, x8, x22, eq
	csel	x24, x9, x24, eq
	csinc	x25, xzr, x25, eq
	add	x21, x21, #1
	ldrsw	x8, [x19]
	cmp	x21, x8, lsl #1
	b.lo	LBB0_7
	b	LBB0_9
LBB0_8:
	mov	x23, #0
	mov	x22, #0
	mov	x24, #0
	mov	x25, #0
	mov	x21, #0
	mov	x8, #0
LBB0_9:
	cmp	x25, x23
	csel	x9, x25, x23, hi
Lloh3:
	adrp	x10, _SH_MOBILE_SDHI_MAX_TAP@GOTPAGE
Lloh4:
	ldr	x10, [x10, _SH_MOBILE_SDHI_MAX_TAP@GOTPAGEOFF]
Lloh5:
	ldr	x10, [x10]
	cmp	x9, x10
	b.hs	LBB0_11
; %bb.10:
Lloh6:
	adrp	x8, _EIO@GOTPAGE
Lloh7:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
Lloh8:
	ldr	w8, [x8]
	neg	w0, w8
	b	LBB0_12
LBB0_11:
	sub	x9, x21, #1
	sub	x10, x21, x25
	cmp	x25, x23
	csel	x9, x9, x24, hi
	csel	x10, x10, x22, hi
	add	x9, x10, x9
	lsr	x9, x9, #1
	udiv	x10, x9, x8
	msub	x3, x10, x8, x9
	str	x3, [x19, #8]
Lloh9:
	adrp	x8, _SH_MOBILE_SDHI_SCC_TAPSET@GOTPAGE
Lloh10:
	ldr	x8, [x8, _SH_MOBILE_SDHI_SCC_TAPSET@GOTPAGEOFF]
Lloh11:
	ldr	w2, [x8]
	mov	x0, x19
	mov	x1, x20
                                        ; kill: def $w3 killed $w3 killed $x3
	bl	_sd_scc_write32
Lloh12:
	adrp	x8, _SH_MOBILE_SDHI_SCC_RVSCNTL@GOTPAGE
Lloh13:
	ldr	x8, [x8, _SH_MOBILE_SDHI_SCC_RVSCNTL@GOTPAGEOFF]
Lloh14:
	ldr	w21, [x8]
Lloh15:
	adrp	x8, _SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN@GOTPAGE
Lloh16:
	ldr	x8, [x8, _SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN@GOTPAGEOFF]
Lloh17:
	ldr	w22, [x8]
	mov	x0, x19
	mov	x1, x20
	mov	x2, x21
	bl	_sd_scc_read32
	orr	w3, w0, w22
	mov	x0, x19
	mov	x1, x20
	mov	x2, x21
	bl	_sd_scc_write32
	mov	w0, #0
LBB0_12:
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp], #80             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.cfi_endproc
                                        ; -- End function
	.comm	_SH_MOBILE_SDHI_SCC_RVSREQ,4,2  ; @SH_MOBILE_SDHI_SCC_RVSREQ
	.comm	_SH_MOBILE_SDHI_MAX_TAP,8,3     ; @SH_MOBILE_SDHI_MAX_TAP
	.comm	_EIO,4,2                        ; @EIO
	.comm	_SH_MOBILE_SDHI_SCC_TAPSET,4,2  ; @SH_MOBILE_SDHI_SCC_TAPSET
	.comm	_SH_MOBILE_SDHI_SCC_RVSCNTL,4,2 ; @SH_MOBILE_SDHI_SCC_RVSCNTL
	.comm	_SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN,4,2 ; @SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN
	.no_dead_strip	_renesas_sdhi_select_tuning
.subsections_via_symbols
