	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function lapic_calibrate_initcount
_lapic_calibrate_initcount:             ## @lapic_calibrate_initcount
	.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
	movq	%rdi, %r14
	movq	_lapic_timer_divisor@GOTPCREL(%rip), %r15
	movl	$2, (%r15)
	movl	$2, %edi
	movq	_APIC_TIMER_MAX_COUNT@GOTPCREL(%rip), %r12
	movq	_LAPIC_CCR_TIMER@GOTPCREL(%rip), %r13
	.p2align	4, 0x90
LBB0_1:                                 ## =>This Inner Loop Header: Depth=1
	callq	_lapic_timer_set_divisor
	movq	(%r12), %rsi
	movq	%r14, %rdi
	callq	_lapic_timer_oneshot_nointr
	movl	$1000000, %edi                  ## imm = 0xF4240
	callq	_DELAY
	movq	(%r12), %rbx
	movl	(%r13), %edi
	callq	_lapic_read32
	subq	%rax, %rbx
	movl	(%r15), %edi
	cmpq	(%r12), %rbx
	jne	LBB0_3
## %bb.2:                               ##   in Loop: Header=BB0_1 Depth=1
	addl	%edi, %edi
	movl	%edi, (%r15)
	cmpl	$129, %edi
	jl	LBB0_1
	jmp	LBB0_4
LBB0_3:
	cmpl	$129, %edi
	jl	LBB0_5
LBB0_4:
	leaq	L_.str(%rip), %rdi
	callq	_panic
LBB0_5:
	movq	_bootverbose@GOTPCREL(%rip), %rax
	cmpq	$0, (%rax)
	je	LBB0_7
## %bb.6:
	movl	(%r15), %esi
	leaq	L_.str.1(%rip), %rdi
	movq	%rbx, %rdx
	callq	_printf
LBB0_7:
	movq	_count_freq@GOTPCREL(%rip), %rax
	movq	%rbx, (%rax)
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_lapic_timer_divisor,4,2        ## @lapic_timer_divisor
	.comm	_APIC_TIMER_MAX_COUNT,8,3       ## @APIC_TIMER_MAX_COUNT
	.comm	_LAPIC_CCR_TIMER,4,2            ## @LAPIC_CCR_TIMER
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"lapic: Divisor too big"

	.comm	_bootverbose,8,3                ## @bootverbose
L_.str.1:                               ## @.str.1
	.asciz	"lapic: Divisor %lu, Frequency %lu Hz\n"

	.comm	_count_freq,8,3                 ## @count_freq
	.no_dead_strip	_lapic_calibrate_initcount
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function lapic_calibrate_initcount
_lapic_calibrate_initcount:             ; @lapic_calibrate_initcount
	.cfi_startproc
; %bb.0:
	stp	x24, x23, [sp, #-64]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.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
	mov	x19, x0
Lloh0:
	adrp	x21, _lapic_timer_divisor@GOTPAGE
Lloh1:
	ldr	x21, [x21, _lapic_timer_divisor@GOTPAGEOFF]
	mov	w0, #2
	str	w0, [x21]
Lloh2:
	adrp	x22, _APIC_TIMER_MAX_COUNT@GOTPAGE
Lloh3:
	ldr	x22, [x22, _APIC_TIMER_MAX_COUNT@GOTPAGEOFF]
Lloh4:
	adrp	x23, _LAPIC_CCR_TIMER@GOTPAGE
Lloh5:
	ldr	x23, [x23, _LAPIC_CCR_TIMER@GOTPAGEOFF]
LBB0_1:                                 ; =>This Inner Loop Header: Depth=1
	bl	_lapic_timer_set_divisor
	ldr	x1, [x22]
	mov	x0, x19
	bl	_lapic_timer_oneshot_nointr
	mov	w0, #16960
	movk	w0, #15, lsl #16
	bl	_DELAY
	ldr	x20, [x22]
	ldr	w0, [x23]
	bl	_lapic_read32
	ldr	x9, [x22]
	ldr	w8, [x21]
	sub	x20, x20, x0
	cmp	x20, x9
	b.ne	LBB0_3
; %bb.2:                                ;   in Loop: Header=BB0_1 Depth=1
	lsl	w0, w8, #1
	str	w0, [x21]
	cmp	w0, #129
	b.lt	LBB0_1
	b	LBB0_4
LBB0_3:
	cmp	w8, #129
	b.lt	LBB0_5
LBB0_4:
Lloh6:
	adrp	x0, l_.str@PAGE
Lloh7:
	add	x0, x0, l_.str@PAGEOFF
	bl	_panic
LBB0_5:
Lloh8:
	adrp	x8, _bootverbose@GOTPAGE
Lloh9:
	ldr	x8, [x8, _bootverbose@GOTPAGEOFF]
Lloh10:
	ldr	x8, [x8]
	cbz	x8, LBB0_7
; %bb.6:
	ldr	w1, [x21]
Lloh11:
	adrp	x0, l_.str.1@PAGE
Lloh12:
	add	x0, x0, l_.str.1@PAGEOFF
	mov	x2, x20
	bl	_printf
LBB0_7:
Lloh13:
	adrp	x8, _count_freq@GOTPAGE
Lloh14:
	ldr	x8, [x8, _count_freq@GOTPAGEOFF]
Lloh15:
	str	x20, [x8]
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp], #64             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpAdd	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpAdd	Lloh11, Lloh12
	.loh AdrpLdrGotStr	Lloh13, Lloh14, Lloh15
	.cfi_endproc
                                        ; -- End function
	.comm	_lapic_timer_divisor,4,2        ; @lapic_timer_divisor
	.comm	_APIC_TIMER_MAX_COUNT,8,3       ; @APIC_TIMER_MAX_COUNT
	.comm	_LAPIC_CCR_TIMER,4,2            ; @LAPIC_CCR_TIMER
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"lapic: Divisor too big"

	.comm	_bootverbose,8,3                ; @bootverbose
l_.str.1:                               ; @.str.1
	.asciz	"lapic: Divisor %lu, Frequency %lu Hz\n"

	.comm	_count_freq,8,3                 ; @count_freq
	.no_dead_strip	_lapic_calibrate_initcount
.subsections_via_symbols
