	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function pwm_freq_to_reg
_pwm_freq_to_reg:                       ## @pwm_freq_to_reg
	.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
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%esi, %r15d
	movq	%rdi, %r13
	movq	_pwm_freq_cksel0@GOTPCREL(%rip), %r12
	movq	(%r12), %rbx
	movq	%rbx, %rdi
	callq	_ARRAY_SIZE
	movq	%r13, %rdi
	movq	%rbx, %rsi
	movl	%eax, %edx
	callq	_find_closest_descending
	movq	%rax, %r14
	cmpq	$375, %r13                      ## imm = 0x177
	jb	LBB0_6
## %bb.1:
	movq	(%r12), %rax
	movq	(%rax,%r14,8), %rbx
	imull	$1000, %r15d, %eax              ## imm = 0x3E8
	xorl	%ecx, %ecx
	cmpl	$48000, %r15d                   ## imm = 0xBB80
	sete	%cl
	orl	$2, %ecx
	shll	$7, %ecx
	cltd
	idivl	%ecx
	movl	%eax, %r15d
	movslq	%eax, %r12
	movq	%r12, %rdi
	movq	%r13, %rsi
	callq	_DIV_ROUND_CLOSEST
	movl	%eax, %edi
	movl	$1, %esi
	movl	$128, %edx
	callq	_clamp_val
	movq	%rax, %rcx
	movq	%r12, %rax
	orq	%rcx, %rax
	shrq	$32, %rax
	je	LBB0_2
## %bb.3:
	movq	%r12, %rax
	xorl	%edx, %edx
	divq	%rcx
	jmp	LBB0_4
LBB0_2:
	movl	%r15d, %eax
	xorl	%edx, %edx
	divl	%ecx
                                        ## kill: def $eax killed $eax def $rax
LBB0_4:
	movq	%r13, %rdx
	subq	%rbx, %rdx
	movq	%rdx, %rsi
	negq	%rsi
	cmovsq	%rdx, %rsi
	subq	%rax, %r13
	movq	%r13, %rax
	negq	%rax
	cmovsq	%r13, %rax
	cmpq	%rax, %rsi
	jbe	LBB0_6
## %bb.5:
	decq	%rcx
	orq	$128, %rcx
	movq	%rcx, %r14
LBB0_6:
	movq	%r14, %rax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_pwm_freq_cksel0,8,3            ## @pwm_freq_cksel0
	.no_dead_strip	_pwm_freq_to_reg
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function pwm_freq_to_reg
_pwm_freq_to_reg:                       ; @pwm_freq_to_reg
	.cfi_startproc
; %bb.0:
	stp	x22, x21, [sp, #-48]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 48
	stp	x20, x19, [sp, #16]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #32]             ; 16-byte Folded Spill
	add	x29, sp, #32
	.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
	mov	x21, x1
	mov	x19, x0
Lloh0:
	adrp	x22, _pwm_freq_cksel0@GOTPAGE
Lloh1:
	ldr	x22, [x22, _pwm_freq_cksel0@GOTPAGEOFF]
	ldr	x20, [x22]
	mov	x0, x20
	bl	_ARRAY_SIZE
	mov	x2, x0
	mov	x0, x19
	mov	x1, x20
	bl	_find_closest_descending
	mov	x20, x0
	cmp	x19, #375
	b.lo	LBB0_3
; %bb.1:
	ldr	x8, [x22]
	ldr	x22, [x8, x20, lsl #3]
	mov	w8, #1000
	mul	w8, w21, w8
	mov	w9, #48000
	mov	w10, #256
	mov	w11, #384
	cmp	w21, w9
	csel	w9, w11, w10, eq
	sdiv	w8, w8, w9
	sxtw	x21, w8
	mov	x0, x21
	mov	x1, x19
	bl	_DIV_ROUND_CLOSEST
	mov	w1, #1
	mov	w2, #128
	bl	_clamp_val
	udiv	x8, x21, x0
	subs	x9, x19, x22
	cneg	x9, x9, mi
	subs	x8, x19, x8
	cneg	x8, x8, mi
	cmp	x9, x8
	b.ls	LBB0_3
; %bb.2:
	sub	x8, x0, #1
	orr	x20, x8, #0x80
LBB0_3:
	mov	x0, x20
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp], #48             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGot	Lloh0, Lloh1
	.cfi_endproc
                                        ; -- End function
	.comm	_pwm_freq_cksel0,8,3            ; @pwm_freq_cksel0
	.no_dead_strip	_pwm_freq_to_reg
.subsections_via_symbols
