	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function sh_mmcif_clock_control
_sh_mmcif_clock_control:                ## @sh_mmcif_clock_control
	.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
	movl	%esi, %ebx
	movq	%rdi, %r14
	callq	_sh_mmcif_host_to_dev
	movq	(%rax), %rcx
	testq	%rcx, %rcx
	movq	%rax, -64(%rbp)                 ## 8-byte Spill
	je	LBB0_1
## %bb.2:
	movl	(%rcx), %r15d
	jmp	LBB0_3
LBB0_1:
	xorl	%r15d, %r15d
LBB0_3:
	movl	4(%r14), %edi
	callq	_clk_get_rate
	movl	%eax, %r12d
	movq	_MMCIF_CE_CLK_CTRL@GOTPCREL(%rip), %r13
	movl	(%r13), %esi
	movq	_CLK_ENABLE@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r14, %rdi
	callq	_sh_mmcif_bitclr
	movl	(%r13), %esi
	movq	_CLK_CLEAR@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r14, %rdi
	callq	_sh_mmcif_bitclr
	testl	%ebx, %ebx
	je	LBB0_17
## %bb.4:
	movl	(%r14), %eax
	testl	%eax, %eax
	je	LBB0_12
## %bb.5:
	movl	$-1, %r13d
	xorl	%ecx, %ecx
	movq	%rcx, -56(%rbp)                 ## 8-byte Spill
	movl	$31, %r12d
	movl	$0, -44(%rbp)                   ## 4-byte Folded Spill
	btl	%r12d, %eax
	jae	LBB0_9
	.p2align	4, 0x90
LBB0_7:
	movl	4(%r14), %edi
	leal	1(%r12), %r15d
	movl	%ebx, %esi
	movl	%r15d, %ecx
	shll	%cl, %esi
	callq	_clk_round_rate
	movl	%eax, %edx
	movl	%r15d, %ecx
	shrl	%cl, %edx
	movl	%ebx, %esi
	subl	%edx, %esi
	negl	%esi
	movl	%ebx, %ecx
	subl	%edx, %ecx
	cmovbl	%esi, %ecx
	cmpl	%r13d, %ecx
	ja	LBB0_9
## %bb.8:
	movl	%eax, -44(%rbp)                 ## 4-byte Spill
	movl	%ecx, %r13d
	movl	%r12d, %eax
	movq	%rax, -56(%rbp)                 ## 8-byte Spill
LBB0_9:                                 ## =>This Inner Loop Header: Depth=1
	subl	$1, %r12d
	jb	LBB0_11
## %bb.10:                              ##   in Loop: Header=BB0_9 Depth=1
	movl	(%r14), %eax
	btl	%r12d, %eax
	jb	LBB0_7
	jmp	LBB0_9
LBB0_11:
	movq	-56(%rbp), %r15                 ## 8-byte Reload
	leal	1(%r15), %ecx
	movl	-44(%rbp), %r12d                ## 4-byte Reload
	movl	%r12d, %edx
                                        ## kill: def $cl killed $cl killed $ecx
	shrl	%cl, %edx
	leaq	L_.str(%rip), %rsi
	movq	-64(%rbp), %rdi                 ## 8-byte Reload
	movl	%ebx, %ecx
	movl	%r12d, %r8d
	movl	%r15d, %r9d
	callq	_dev_dbg
	movl	4(%r14), %edi
	movl	%r12d, %esi
	callq	_clk_set_rate
	shll	$16, %r15d
	movq	_MMCIF_CE_CLK_CTRL@GOTPCREL(%rip), %r13
	jmp	LBB0_16
LBB0_17:
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_12:
	testl	%r15d, %r15d
	je	LBB0_15
## %bb.13:
	cmpl	%ebx, %r12d
	jne	LBB0_15
## %bb.14:
	movq	_CLK_SUP_PCLK@GOTPCREL(%rip), %rax
	movl	(%rax), %r15d
	jmp	LBB0_16
LBB0_15:
	movl	%r12d, %edi
	movl	%ebx, %esi
	callq	_DIV_ROUND_UP
	leaq	-1(%rax), %rdi
	callq	_fls
	movl	%eax, %r15d
	shll	$16, %r15d
	addl	$-65536, %r15d                  ## imm = 0xFFFF0000
LBB0_16:
	movl	(%r13), %esi
	movq	_CLK_CLEAR@GOTPCREL(%rip), %rax
	andl	(%rax), %r15d
	movq	%r14, %rdi
	movl	%r15d, %edx
	callq	_sh_mmcif_bitset
	movl	(%r13), %esi
	movq	_CLK_ENABLE@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r14, %rdi
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_sh_mmcif_bitset                ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.comm	_MMCIF_CE_CLK_CTRL,4,2          ## @MMCIF_CE_CLK_CTRL
	.comm	_CLK_ENABLE,4,2                 ## @CLK_ENABLE
	.comm	_CLK_CLEAR,4,2                  ## @CLK_CLEAR
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"clk %u/%u (%u, 0x%x)\n"

	.comm	_CLK_SUP_PCLK,4,2               ## @CLK_SUP_PCLK
	.no_dead_strip	_sh_mmcif_clock_control
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function sh_mmcif_clock_control
_sh_mmcif_clock_control:                ; @sh_mmcif_clock_control
	.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, x1
	mov	x19, x0
	bl	_sh_mmcif_host_to_dev
	mov	x21, x0
	ldr	x8, [x0]
	cbz	x8, LBB0_2
; %bb.1:
	ldr	w23, [x8]
	b	LBB0_3
LBB0_2:
	mov	w23, #0
LBB0_3:
	ldr	w0, [x19, #4]
	bl	_clk_get_rate
	mov	x22, x0
Lloh0:
	adrp	x24, _MMCIF_CE_CLK_CTRL@GOTPAGE
Lloh1:
	ldr	x24, [x24, _MMCIF_CE_CLK_CTRL@GOTPAGEOFF]
	ldr	w1, [x24]
Lloh2:
	adrp	x25, _CLK_ENABLE@GOTPAGE
Lloh3:
	ldr	x25, [x25, _CLK_ENABLE@GOTPAGEOFF]
	ldr	w2, [x25]
	mov	x0, x19
	bl	_sh_mmcif_bitclr
	ldr	w1, [x24]
Lloh4:
	adrp	x26, _CLK_CLEAR@GOTPAGE
Lloh5:
	ldr	x26, [x26, _CLK_CLEAR@GOTPAGEOFF]
	ldr	w2, [x26]
	mov	x0, x19
	bl	_sh_mmcif_bitclr
	cbz	w20, LBB0_11
; %bb.4:
	ldr	w8, [x19]
	cbz	w8, LBB0_12
; %bb.5:
	mov	w22, #0
	mov	w23, #0
	mov	w28, #-1
	mov	w27, #31
	lsr	w8, w8, w27
	tbz	w8, #0, LBB0_8
LBB0_6:
	add	w25, w27, #1
	ldr	w0, [x19, #4]
	lsl	w1, w20, w25
	bl	_clk_round_rate
	lsr	w8, w0, w25
	sub	w9, w20, w8
	subs	w8, w8, w20
	csel	w8, w8, w9, hi
	cmp	w8, w28
	b.hi	LBB0_8
; %bb.7:
	mov	x23, x0
	mov	x28, x8
	mov	x22, x27
LBB0_8:                                 ; =>This Inner Loop Header: Depth=1
	cbz	w27, LBB0_10
; %bb.9:                                ;   in Loop: Header=BB0_8 Depth=1
	sub	w27, w27, #1
	ldr	w8, [x19]
	lsr	w8, w8, w27
	tbnz	w8, #0, LBB0_6
	b	LBB0_8
LBB0_10:
	add	w8, w22, #1
	lsr	w2, w23, w8
Lloh6:
	adrp	x1, l_.str@PAGE
Lloh7:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x21
	mov	x3, x20
	mov	x4, x23
	mov	x5, x22
	bl	_dev_dbg
	ldr	w0, [x19, #4]
	mov	x1, x23
	bl	_clk_set_rate
	lsl	w8, w22, #16
Lloh8:
	adrp	x25, _CLK_ENABLE@GOTPAGE
Lloh9:
	ldr	x25, [x25, _CLK_ENABLE@GOTPAGEOFF]
	b	LBB0_16
LBB0_11:
	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
LBB0_12:
	cbz	w23, LBB0_15
; %bb.13:
	cmp	w22, w20
	b.ne	LBB0_15
; %bb.14:
Lloh10:
	adrp	x8, _CLK_SUP_PCLK@GOTPAGE
Lloh11:
	ldr	x8, [x8, _CLK_SUP_PCLK@GOTPAGEOFF]
Lloh12:
	ldr	w8, [x8]
	b	LBB0_16
LBB0_15:
	mov	x0, x22
	mov	x1, x20
	bl	_DIV_ROUND_UP
	sub	x0, x0, #1
	bl	_fls
	lsl	w8, w0, #16
	sub	w8, w8, #16, lsl #12            ; =65536
LBB0_16:
	ldr	w1, [x24]
	ldr	w9, [x26]
	and	w2, w9, w8
	mov	x0, x19
	bl	_sh_mmcif_bitset
	ldr	w1, [x24]
	ldr	w2, [x25]
	mov	x0, x19
	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
	b	_sh_mmcif_bitset
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpAdd	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.cfi_endproc
                                        ; -- End function
	.comm	_MMCIF_CE_CLK_CTRL,4,2          ; @MMCIF_CE_CLK_CTRL
	.comm	_CLK_ENABLE,4,2                 ; @CLK_ENABLE
	.comm	_CLK_CLEAR,4,2                  ; @CLK_CLEAR
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"clk %u/%u (%u, 0x%x)\n"

	.comm	_CLK_SUP_PCLK,4,2               ; @CLK_SUP_PCLK
	.no_dead_strip	_sh_mmcif_clock_control
.subsections_via_symbols
