	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_msix_alloc                     ## -- Begin function msix_alloc
	.p2align	4, 0x90
_msix_alloc:                            ## @msix_alloc
	.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	_msi_enabled@GOTPCREL(%rip), %rax
	cmpl	$0, (%rax)
	je	LBB0_15
## %bb.1:
	movq	%rsi, -64(%rbp)                 ## 8-byte Spill
	leaq	-44(%rbp), %rsi
	movq	%rdi, -56(%rbp)                 ## 8-byte Spill
	callq	_bus_get_domain
	testq	%rax, %rax
	je	LBB0_3
## %bb.2:
	movl	$0, -44(%rbp)
LBB0_3:
	movq	_msi_lock@GOTPCREL(%rip), %r13
	movq	_num_msi_irqs@GOTPCREL(%rip), %r14
	movq	_first_msi_irq@GOTPCREL(%rip), %r15
LBB0_4:                                 ## =>This Loop Header: Depth=1
                                        ##     Child Loop BB0_6 Depth 2
	movq	%r13, %rdi
	callq	_mtx_lock
	cmpl	$0, (%r14)
	jle	LBB0_9
## %bb.5:                               ##   in Loop: Header=BB0_4 Depth=1
	movl	(%r15), %ebx
	.p2align	4, 0x90
LBB0_6:                                 ##   Parent Loop BB0_4 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	movl	%ebx, %edi
	callq	_intr_lookup_source
	testq	%rax, %rax
	je	LBB0_10
## %bb.7:                               ##   in Loop: Header=BB0_6 Depth=2
	movq	%rax, %r12
	cmpq	$0, 56(%rax)
	je	LBB0_12
## %bb.8:                               ##   in Loop: Header=BB0_6 Depth=2
	incl	%ebx
	movl	(%r15), %eax
	movl	(%r14), %ecx
	leal	(%rcx,%rax), %edx
	cmpl	%edx, %ebx
	jl	LBB0_6
	jmp	LBB0_13
	.p2align	4, 0x90
LBB0_9:                                 ##   in Loop: Header=BB0_4 Depth=1
	jne	LBB0_11
	jmp	LBB0_14
	.p2align	4, 0x90
LBB0_10:                                ##   in Loop: Header=BB0_4 Depth=1
	movl	(%r14), %eax
	addl	(%r15), %eax
	cmpl	%ebx, %eax
	je	LBB0_14
LBB0_11:                                ##   in Loop: Header=BB0_4 Depth=1
	movq	%r13, %rdi
	callq	_mtx_unlock
	xorl	%eax, %eax
	callq	_msi_create_source
	jmp	LBB0_4
LBB0_12:
	movl	(%r15), %eax
	movl	(%r14), %ecx
LBB0_13:
	addl	%eax, %ecx
	cmpl	%ecx, %ebx
	jne	LBB0_16
LBB0_14:
	movq	_msi_lock@GOTPCREL(%rip), %rdi
	callq	_mtx_unlock
LBB0_15:
	movq	_ENXIO@GOTPCREL(%rip), %rax
LBB0_21:
	movl	(%rax), %eax
LBB0_22:
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_16:
	movl	-44(%rbp), %edi
	callq	_intr_next_cpu
	movl	%eax, %r13d
	movl	%eax, %edi
	movl	%ebx, %esi
	callq	_apic_alloc_vector
	testl	%eax, %eax
	je	LBB0_20
## %bb.17:
	movl	%eax, %r14d
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	movq	%rax, 56(%r12)
	movq	_bootverbose@GOTPCREL(%rip), %rax
	cmpq	$0, (%rax)
	je	LBB0_19
## %bb.18:
	movl	4(%r12), %esi
	leaq	L_.str(%rip), %rdi
	movl	%r13d, %edx
	movl	%r14d, %ecx
	callq	_printf
LBB0_19:
	movl	%r13d, 8(%r12)
	movq	%r12, 48(%r12)
	movl	%r14d, 12(%r12)
	movabsq	$4294967297, %rax               ## imm = 0x100000001
	movq	%rax, 16(%r12)
	movl	$1, 24(%r12)
	movq	$0, 40(%r12)
	xorl	%edi, %edi
	cmpq	$0, 32(%r12)
	sete	%dil
	leaq	L_.str.1(%rip), %rsi
	callq	_KASSERT
	movq	_msi_lock@GOTPCREL(%rip), %rdi
	callq	_mtx_unlock
	movq	-64(%rbp), %rax                 ## 8-byte Reload
	movl	%ebx, (%rax)
	xorl	%eax, %eax
	jmp	LBB0_22
LBB0_20:
	movq	_msi_lock@GOTPCREL(%rip), %rdi
	callq	_mtx_unlock
	movq	_ENOSPC@GOTPCREL(%rip), %rax
	jmp	LBB0_21
	.cfi_endproc
                                        ## -- End function
	.comm	_msi_enabled,4,2                ## @msi_enabled
	.comm	_ENXIO,4,2                      ## @ENXIO
	.comm	_msi_lock,4,2                   ## @msi_lock
	.comm	_first_msi_irq,4,2              ## @first_msi_irq
	.comm	_num_msi_irqs,4,2               ## @num_msi_irqs
	.comm	_ENOSPC,4,2                     ## @ENOSPC
	.comm	_bootverbose,8,3                ## @bootverbose
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"msi: routing MSI-X IRQ %d to local APIC %u vector %u\n"

L_.str.1:                               ## @.str.1
	.asciz	"dead MSI-X has handlers"

	.comm	_EOPNOTSUPP,4,2                 ## @EOPNOTSUPP
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_msix_alloc                     ; -- Begin function msix_alloc
	.p2align	2
_msix_alloc:                            ; @msix_alloc
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #96
	.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
Lloh0:
	adrp	x8, _msi_enabled@GOTPAGE
Lloh1:
	ldr	x8, [x8, _msi_enabled@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	cbz	w8, LBB0_15
; %bb.1:
	mov	x19, x1
	mov	x20, x0
	add	x1, sp, #12
	bl	_bus_get_domain
	cbz	x0, LBB0_3
; %bb.2:
	str	wzr, [sp, #12]
LBB0_3:
Lloh3:
	adrp	x23, _msi_lock@GOTPAGE
Lloh4:
	ldr	x23, [x23, _msi_lock@GOTPAGEOFF]
Lloh5:
	adrp	x24, _num_msi_irqs@GOTPAGE
Lloh6:
	ldr	x24, [x24, _num_msi_irqs@GOTPAGEOFF]
Lloh7:
	adrp	x25, _first_msi_irq@GOTPAGE
Lloh8:
	ldr	x25, [x25, _first_msi_irq@GOTPAGEOFF]
LBB0_4:                                 ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_6 Depth 2
	mov	x0, x23
	bl	_mtx_lock
	ldr	w8, [x24]
	cmp	w8, #1
	b.lt	LBB0_9
; %bb.5:                                ;   in Loop: Header=BB0_4 Depth=1
	ldr	w21, [x25]
LBB0_6:                                 ;   Parent Loop BB0_4 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	mov	x0, x21
	bl	_intr_lookup_source
	cbz	x0, LBB0_10
; %bb.7:                                ;   in Loop: Header=BB0_6 Depth=2
	mov	x22, x0
	ldr	x8, [x0, #56]
	cbz	x8, LBB0_12
; %bb.8:                                ;   in Loop: Header=BB0_6 Depth=2
	add	w21, w21, #1
	ldr	w8, [x25]
	ldr	w9, [x24]
	add	w10, w9, w8
	cmp	w21, w10
	b.lt	LBB0_6
	b	LBB0_13
LBB0_9:                                 ;   in Loop: Header=BB0_4 Depth=1
	cbnz	w8, LBB0_11
	b	LBB0_14
LBB0_10:                                ;   in Loop: Header=BB0_4 Depth=1
	ldr	w8, [x25]
	ldr	w9, [x24]
	add	w8, w9, w8
	cmp	w8, w21
	b.eq	LBB0_14
LBB0_11:                                ;   in Loop: Header=BB0_4 Depth=1
	mov	x0, x23
	bl	_mtx_unlock
	bl	_msi_create_source
	b	LBB0_4
LBB0_12:
	ldr	w8, [x25]
	ldr	w9, [x24]
LBB0_13:
	add	w8, w9, w8
	cmp	w21, w8
	b.ne	LBB0_18
LBB0_14:
Lloh9:
	adrp	x0, _msi_lock@GOTPAGE
Lloh10:
	ldr	x0, [x0, _msi_lock@GOTPAGEOFF]
	bl	_mtx_unlock
LBB0_15:
Lloh11:
	adrp	x8, _ENXIO@GOTPAGE
Lloh12:
	ldr	x8, [x8, _ENXIO@GOTPAGEOFF]
LBB0_16:
	ldr	w0, [x8]
LBB0_17:
	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
	add	sp, sp, #96
	ret
LBB0_18:
	ldr	w0, [sp, #12]
	bl	_intr_next_cpu
	mov	x23, x0
	mov	x1, x21
	bl	_apic_alloc_vector
	cbz	w0, LBB0_22
; %bb.19:
	mov	x24, x0
	str	x20, [x22, #56]
Lloh13:
	adrp	x8, _bootverbose@GOTPAGE
Lloh14:
	ldr	x8, [x8, _bootverbose@GOTPAGEOFF]
Lloh15:
	ldr	x8, [x8]
	cbz	x8, LBB0_21
; %bb.20:
	ldr	w1, [x22, #4]
Lloh16:
	adrp	x0, l_.str@PAGE
Lloh17:
	add	x0, x0, l_.str@PAGEOFF
	mov	x2, x23
	mov	x3, x24
	bl	_printf
LBB0_21:
	stp	w23, w24, [x22, #8]
	movi.2s	v0, #1
	str	d0, [x22, #16]
	mov	w8, #1
	str	w8, [x22, #24]
	stp	xzr, x22, [x22, #40]
	ldr	x8, [x22, #32]
	cmp	x8, #0
	cset	w0, eq
Lloh18:
	adrp	x1, l_.str.1@PAGE
Lloh19:
	add	x1, x1, l_.str.1@PAGEOFF
	bl	_KASSERT
Lloh20:
	adrp	x0, _msi_lock@GOTPAGE
Lloh21:
	ldr	x0, [x0, _msi_lock@GOTPAGEOFF]
	bl	_mtx_unlock
	mov	w0, #0
	str	w21, [x19]
	b	LBB0_17
LBB0_22:
Lloh22:
	adrp	x0, _msi_lock@GOTPAGE
Lloh23:
	ldr	x0, [x0, _msi_lock@GOTPAGEOFF]
	bl	_mtx_unlock
Lloh24:
	adrp	x8, _ENOSPC@GOTPAGE
Lloh25:
	ldr	x8, [x8, _ENOSPC@GOTPAGEOFF]
	b	LBB0_16
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh9, Lloh10
	.loh AdrpLdrGot	Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpAdd	Lloh16, Lloh17
	.loh AdrpLdrGot	Lloh20, Lloh21
	.loh AdrpAdd	Lloh18, Lloh19
	.loh AdrpLdrGot	Lloh24, Lloh25
	.loh AdrpLdrGot	Lloh22, Lloh23
	.cfi_endproc
                                        ; -- End function
	.comm	_msi_enabled,4,2                ; @msi_enabled
	.comm	_ENXIO,4,2                      ; @ENXIO
	.comm	_msi_lock,4,2                   ; @msi_lock
	.comm	_first_msi_irq,4,2              ; @first_msi_irq
	.comm	_num_msi_irqs,4,2               ; @num_msi_irqs
	.comm	_ENOSPC,4,2                     ; @ENOSPC
	.comm	_bootverbose,8,3                ; @bootverbose
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"msi: routing MSI-X IRQ %d to local APIC %u vector %u\n"

l_.str.1:                               ; @.str.1
	.asciz	"dead MSI-X has handlers"

	.comm	_EOPNOTSUPP,4,2                 ; @EOPNOTSUPP
.subsections_via_symbols
