	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function ioapic_assign_cpu
_ioapic_assign_cpu:                     ## @ioapic_assign_cpu
	.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, %rbx
	movq	(%rdi), %r14
	movq	8(%rdi), %r13
	movq	_vm_guest@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	_VM_GUEST_HV@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_4
## %bb.1:
	testq	%r14, %r14
	je	LBB0_3
## %bb.2:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	jmp	LBB0_20
LBB0_3:
	xorl	%r14d, %r14d
	xorl	%esi, %esi
LBB0_4:
	movq	_IRQ_NMI@GOTPCREL(%rip), %rcx
	xorl	%eax, %eax
	cmpq	(%rcx), %r13
	movl	$0, %r12d
	cmovneq	%rsi, %r12
	movq	16(%rbx), %rcx
	testq	%r14, %r14
	je	LBB0_6
## %bb.5:
	cmpq	%rcx, %r12
	je	LBB0_21
LBB0_6:
	movq	%rcx, -56(%rbp)                 ## 8-byte Spill
	movq	%r12, %rdi
	movq	%r13, %rsi
	callq	_apic_alloc_vector
	testq	%rax, %rax
	je	LBB0_19
## %bb.7:
	movq	%rax, %r15
	movq	_icu_lock@GOTPCREL(%rip), %rdi
	callq	_mtx_lock_spin
	cmpl	$0, 36(%rbx)
	jne	LBB0_10
## %bb.8:
	cmpl	$0, 32(%rbx)
	jne	LBB0_10
## %bb.9:
	movl	4(%r13), %eax
	movl	%eax, -44(%rbp)                 ## 4-byte Spill
	movl	24(%rbx), %edi
	callq	_IOAPIC_REDTBL_LO
	movq	_IOART_INTMSET@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edx
	orl	28(%rbx), %edx
	movl	-44(%rbp), %edi                 ## 4-byte Reload
	movl	%eax, %esi
	callq	_ioapic_write
	movq	_icu_lock@GOTPCREL(%rip), %rdi
	callq	_mtx_unlock_spin
	movl	$100, %edi
	callq	_DELAY
	movq	_icu_lock@GOTPCREL(%rip), %rdi
	callq	_mtx_lock_spin
LBB0_10:
	movq	%r12, 16(%rbx)
	movq	%r15, (%rbx)
	testq	%r15, %r15
	jle	LBB0_12
## %bb.11:
	movq	%r12, %rdi
	movq	%r15, %rsi
	callq	_apic_enable_vector
LBB0_12:
	movq	_bootverbose@GOTPCREL(%rip), %rax
	cmpq	$0, (%rax)
	je	LBB0_14
## %bb.13:
	movl	(%r13), %esi
	movl	24(%rbx), %edx
	leaq	L_.str(%rip), %rdi
	callq	_printf
	movq	%rbx, %rdi
	callq	_ioapic_print_irq
	movl	(%rbx), %edx
	movl	16(%rbx), %esi
	leaq	L_.str.1(%rip), %rdi
	callq	_printf
LBB0_14:
	movq	%rbx, %rdi
	callq	_ioapic_program_intpin
	movq	_icu_lock@GOTPCREL(%rip), %rdi
	callq	_mtx_unlock_spin
	testq	%r14, %r14
	movq	-56(%rbp), %r15                 ## 8-byte Reload
	je	LBB0_18
## %bb.15:
	cmpq	$0, (%rbx)
	jle	LBB0_17
## %bb.16:
	movq	%r15, %rdi
	movq	%r14, %rsi
	callq	_apic_disable_vector
LBB0_17:
	movq	8(%rbx), %rdx
	movq	%r15, %rdi
	movq	%r14, %rsi
	callq	_apic_free_vector
LBB0_18:
	xorl	%eax, %eax
	jmp	LBB0_21
LBB0_19:
	movq	_ENOSPC@GOTPCREL(%rip), %rax
LBB0_20:
	movl	(%rax), %eax
LBB0_21:
                                        ## kill: def $eax killed $eax killed $rax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_vm_guest,8,3                   ## @vm_guest
	.comm	_VM_GUEST_HV,8,3                ## @VM_GUEST_HV
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_IRQ_NMI,8,3                    ## @IRQ_NMI
	.comm	_ENOSPC,4,2                     ## @ENOSPC
	.comm	_icu_lock,4,2                   ## @icu_lock
	.comm	_IOART_INTMSET,4,2              ## @IOART_INTMSET
	.comm	_bootverbose,8,3                ## @bootverbose
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"ioapic%u: routing intpin %u ("

L_.str.1:                               ## @.str.1
	.asciz	") to lapic %u vector %u\n"

	.no_dead_strip	_ioapic_assign_cpu
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function ioapic_assign_cpu
_ioapic_assign_cpu:                     ; @ioapic_assign_cpu
	.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
Lloh0:
	adrp	x8, _vm_guest@GOTPAGE
Lloh1:
	ldr	x8, [x8, _vm_guest@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
Lloh3:
	adrp	x9, _VM_GUEST_HV@GOTPAGE
Lloh4:
	ldr	x9, [x9, _VM_GUEST_HV@GOTPAGEOFF]
Lloh5:
	ldr	x9, [x9]
	ldp	x20, x22, [x0]
	cmp	x8, x9
	b.ne	LBB0_4
; %bb.1:
	cbz	x20, LBB0_3
; %bb.2:
Lloh6:
	adrp	x8, _EINVAL@GOTPAGE
Lloh7:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh8:
	ldr	w0, [x8]
	b	LBB0_19
LBB0_3:
	mov	x1, #0
LBB0_4:
Lloh9:
	adrp	x8, _IRQ_NMI@GOTPAGE
Lloh10:
	ldr	x8, [x8, _IRQ_NMI@GOTPAGEOFF]
Lloh11:
	ldr	x8, [x8]
	cmp	x22, x8
	csel	x23, xzr, x1, eq
	ldr	x21, [x19, #16]
	cbz	x20, LBB0_6
; %bb.5:
	cmp	x23, x21
	b.eq	LBB0_18
LBB0_6:
	mov	x0, x23
	mov	x1, x22
	bl	_apic_alloc_vector
	cbz	x0, LBB0_20
; %bb.7:
	mov	x24, x0
Lloh12:
	adrp	x0, _icu_lock@GOTPAGE
Lloh13:
	ldr	x0, [x0, _icu_lock@GOTPAGEOFF]
	bl	_mtx_lock_spin
	ldr	w8, [x19, #36]
	cbnz	w8, LBB0_10
; %bb.8:
	ldr	w8, [x19, #32]
	cbnz	w8, LBB0_10
; %bb.9:
	ldr	w25, [x22, #4]
	ldr	w0, [x19, #24]
	bl	_IOAPIC_REDTBL_LO
	mov	x1, x0
	ldr	w8, [x19, #28]
Lloh14:
	adrp	x9, _IOART_INTMSET@GOTPAGE
Lloh15:
	ldr	x9, [x9, _IOART_INTMSET@GOTPAGEOFF]
Lloh16:
	ldr	w9, [x9]
	orr	w2, w9, w8
	mov	x0, x25
	bl	_ioapic_write
Lloh17:
	adrp	x25, _icu_lock@GOTPAGE
Lloh18:
	ldr	x25, [x25, _icu_lock@GOTPAGEOFF]
	mov	x0, x25
	bl	_mtx_unlock_spin
	mov	w0, #100
	bl	_DELAY
	mov	x0, x25
	bl	_mtx_lock_spin
LBB0_10:
	str	x23, [x19, #16]
	str	x24, [x19]
	cmp	x24, #1
	b.lt	LBB0_12
; %bb.11:
	mov	x0, x23
	mov	x1, x24
	bl	_apic_enable_vector
LBB0_12:
Lloh19:
	adrp	x8, _bootverbose@GOTPAGE
Lloh20:
	ldr	x8, [x8, _bootverbose@GOTPAGEOFF]
Lloh21:
	ldr	x8, [x8]
	cbz	x8, LBB0_14
; %bb.13:
	ldr	w1, [x22]
	ldr	w2, [x19, #24]
Lloh22:
	adrp	x0, l_.str@PAGE
Lloh23:
	add	x0, x0, l_.str@PAGEOFF
	bl	_printf
	mov	x0, x19
	bl	_ioapic_print_irq
	ldr	w1, [x19, #16]
	ldr	w2, [x19]
Lloh24:
	adrp	x0, l_.str.1@PAGE
Lloh25:
	add	x0, x0, l_.str.1@PAGEOFF
	bl	_printf
LBB0_14:
	mov	x0, x19
	bl	_ioapic_program_intpin
Lloh26:
	adrp	x0, _icu_lock@GOTPAGE
Lloh27:
	ldr	x0, [x0, _icu_lock@GOTPAGEOFF]
	bl	_mtx_unlock_spin
	cbz	x20, LBB0_18
; %bb.15:
	ldr	x8, [x19]
	cmp	x8, #1
	b.lt	LBB0_17
; %bb.16:
	mov	x0, x21
	mov	x1, x20
	bl	_apic_disable_vector
LBB0_17:
	ldr	x2, [x19, #8]
	mov	x0, x21
	mov	x1, x20
	bl	_apic_free_vector
LBB0_18:
	mov	w0, #0
LBB0_19:
	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
LBB0_20:
Lloh28:
	adrp	x8, _ENOSPC@GOTPAGE
Lloh29:
	ldr	x8, [x8, _ENOSPC@GOTPAGEOFF]
Lloh30:
	ldr	w0, [x8]
	b	LBB0_19
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh12, Lloh13
	.loh AdrpLdrGot	Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.loh AdrpAdd	Lloh24, Lloh25
	.loh AdrpAdd	Lloh22, Lloh23
	.loh AdrpLdrGot	Lloh26, Lloh27
	.loh AdrpLdrGotLdr	Lloh28, Lloh29, Lloh30
	.cfi_endproc
                                        ; -- End function
	.comm	_vm_guest,8,3                   ; @vm_guest
	.comm	_VM_GUEST_HV,8,3                ; @VM_GUEST_HV
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_IRQ_NMI,8,3                    ; @IRQ_NMI
	.comm	_ENOSPC,4,2                     ; @ENOSPC
	.comm	_icu_lock,4,2                   ; @icu_lock
	.comm	_IOART_INTMSET,4,2              ; @IOART_INTMSET
	.comm	_bootverbose,8,3                ; @bootverbose
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"ioapic%u: routing intpin %u ("

l_.str.1:                               ; @.str.1
	.asciz	") to lapic %u vector %u\n"

	.no_dead_strip	_ioapic_assign_cpu
.subsections_via_symbols
