	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_msi_alloc                      ## -- Begin function msi_alloc
	.p2align	4, 0x90
_msi_alloc:                             ## @msi_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	$72, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%edx, -44(%rbp)                 ## 4-byte Spill
	movq	_msi_enabled@GOTPCREL(%rip), %rax
	cmpl	$0, (%rax)
	je	LBB0_30
## %bb.1:
	movq	%rcx, %r14
	movl	%esi, %ebx
	leaq	-80(%rbp), %rsi
	movq	%rdi, -104(%rbp)                ## 8-byte Spill
	callq	_bus_get_domain
	testq	%rax, %rax
	je	LBB0_3
## %bb.2:
	movq	$0, -80(%rbp)
LBB0_3:
	cmpl	$2, %ebx
	movq	%rbx, -64(%rbp)                 ## 8-byte Spill
	jl	LBB0_5
## %bb.4:
	leal	(,%rbx,8), %edi
	movq	_M_MSI@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_M_WAITOK@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	callq	_malloc
	jmp	LBB0_6
LBB0_5:
	xorl	%eax, %eax
LBB0_6:
	movq	%rax, -56(%rbp)                 ## 8-byte Spill
	movq	_first_msi_irq@GOTPCREL(%rip), %r13
	movq	%r14, -88(%rbp)                 ## 8-byte Spill
	.p2align	4, 0x90
LBB0_7:                                 ## =>This Loop Header: Depth=1
                                        ##     Child Loop BB0_10 Depth 2
                                        ##     Child Loop BB0_17 Depth 2
	movq	_msi_lock@GOTPCREL(%rip), %rdi
	callq	_mtx_lock
	movl	(%r13), %ebx
	movq	_num_msi_irqs@GOTPCREL(%rip), %rax
	cmpl	$0, (%rax)
	jle	LBB0_13
## %bb.8:                               ##   in Loop: Header=BB0_7 Depth=1
	xorl	%r15d, %r15d
	movq	-64(%rbp), %r12                 ## 8-byte Reload
	jmp	LBB0_10
	.p2align	4, 0x90
LBB0_9:                                 ##   in Loop: Header=BB0_10 Depth=2
	incl	%ebx
	movq	_num_msi_irqs@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	addl	(%r13), %eax
	cmpl	%eax, %ebx
	jge	LBB0_14
LBB0_10:                                ##   Parent Loop BB0_7 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	movl	%ebx, %edi
	callq	_intr_lookup_source
	testq	%rax, %rax
	je	LBB0_14
## %bb.11:                              ##   in Loop: Header=BB0_10 Depth=2
	cmpq	$0, 48(%rax)
	jne	LBB0_9
## %bb.12:                              ##   in Loop: Header=BB0_10 Depth=2
	movslq	%r15d, %r15
	movl	%ebx, (%r14,%r15,4)
	incl	%r15d
	cmpl	%r12d, %r15d
	jne	LBB0_9
	jmp	LBB0_18
	.p2align	4, 0x90
LBB0_13:                                ##   in Loop: Header=BB0_7 Depth=1
	xorl	%r15d, %r15d
	movq	-64(%rbp), %r12                 ## 8-byte Reload
LBB0_14:                                ##   in Loop: Header=BB0_7 Depth=1
	cmpl	%r12d, %r15d
	jge	LBB0_19
## %bb.15:                              ##   in Loop: Header=BB0_7 Depth=1
	addl	%r12d, %ebx
	subl	%r15d, %ebx
	movq	_num_msi_irqs@GOTPCREL(%rip), %rcx
	movl	(%rcx), %r14d
	addl	(%r13), %r14d
	movq	_msi_lock@GOTPCREL(%rip), %rdi
	callq	_mtx_unlock
	cmpl	%r14d, %ebx
	jg	LBB0_29
## %bb.16:                              ##   in Loop: Header=BB0_7 Depth=1
	movl	%r12d, %ebx
	subl	%r15d, %ebx
	movq	-88(%rbp), %r14                 ## 8-byte Reload
	.p2align	4, 0x90
LBB0_17:                                ##   Parent Loop BB0_7 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	xorl	%eax, %eax
	callq	_msi_create_source
	decl	%ebx
	jne	LBB0_17
	jmp	LBB0_7
LBB0_18:
	movl	%r12d, %r15d
LBB0_19:
	xorl	%edi, %edi
	cmpl	%r12d, %r15d
	sete	%dil
	leaq	L_.str(%rip), %rsi
	callq	_KASSERT
	movq	-80(%rbp), %rdi
	callq	_intr_next_cpu
	movq	%rax, %rbx
	movq	%rax, %rdi
	movq	%r14, %rsi
	movl	%r12d, %edx
	movl	-44(%rbp), %ecx                 ## 4-byte Reload
	callq	_apic_alloc_vectors
	testl	%eax, %eax
	je	LBB0_28
## %bb.20:
	movq	%r12, %r15
	movl	%eax, %r12d
	movl	(%r14), %edi
	callq	_intr_lookup_source
	movq	%rax, -72(%rbp)                 ## 8-byte Spill
	testl	%r15d, %r15d
	jle	LBB0_25
## %bb.21:
	movl	-64(%rbp), %eax                 ## 4-byte Reload
	movq	%rax, -96(%rbp)                 ## 8-byte Spill
	movl	%r12d, %r13d
	xorl	%r15d, %r15d
	jmp	LBB0_23
	.p2align	4, 0x90
LBB0_22:                                ##   in Loop: Header=BB0_23 Depth=1
	movq	-72(%rbp), %rax                 ## 8-byte Reload
	movq	%rax, 40(%r12)
	xorl	%edi, %edi
	cmpq	$0, 32(%r12)
	sete	%dil
	leaq	L_.str.2(%rip), %rsi
	callq	_KASSERT
	incq	%r15
	cmpq	%r15, -96(%rbp)                 ## 8-byte Folded Reload
	je	LBB0_25
LBB0_23:                                ## =>This Inner Loop Header: Depth=1
	movl	(%r14,%r15,4), %edi
	callq	_intr_lookup_source
	movq	%rax, %r12
	movl	%ebx, (%rax)
	movq	-104(%rbp), %rax                ## 8-byte Reload
	movq	%rax, 48(%r12)
	leaq	(%r15,%r13), %rcx
	movl	%ecx, 4(%r12)
	movq	_bootverbose@GOTPCREL(%rip), %rax
	cmpq	$0, (%rax)
	je	LBB0_22
## %bb.24:                              ##   in Loop: Header=BB0_23 Depth=1
	movl	8(%r12), %esi
	leaq	L_.str.1(%rip), %rdi
	movl	%ebx, %edx
                                        ## kill: def $ecx killed $ecx killed $rcx
	callq	_printf
	jmp	LBB0_22
LBB0_25:
	movq	-64(%rbp), %rdx                 ## 8-byte Reload
	movq	-72(%rbp), %r15                 ## 8-byte Reload
	movl	%edx, 12(%r15)
	movl	-44(%rbp), %eax                 ## 4-byte Reload
	movl	%eax, 16(%r15)
	cmpl	$2, %edx
	movq	-56(%rbp), %rbx                 ## 8-byte Reload
	jl	LBB0_27
## %bb.26:
	shll	$3, %edx
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	_memmove
LBB0_27:
	movq	%rbx, 24(%r15)
	movq	_msi_lock@GOTPCREL(%rip), %rdi
	callq	_mtx_unlock
	xorl	%eax, %eax
	jmp	LBB0_32
LBB0_28:
	movq	_msi_lock@GOTPCREL(%rip), %rdi
	callq	_mtx_unlock
	movq	_M_MSI@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	callq	_free
	movq	_ENOSPC@GOTPCREL(%rip), %rax
	jmp	LBB0_31
LBB0_29:
	movq	_M_MSI@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	callq	_free
LBB0_30:
	movq	_ENXIO@GOTPCREL(%rip), %rax
LBB0_31:
	movl	(%rax), %eax
LBB0_32:
	addq	$72, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_msi_enabled,4,2                ## @msi_enabled
	.comm	_ENXIO,4,2                      ## @ENXIO
	.comm	_M_MSI,4,2                      ## @M_MSI
	.comm	_M_WAITOK,4,2                   ## @M_WAITOK
	.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
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"count mismatch"

	.comm	_ENOSPC,4,2                     ## @ENOSPC
	.comm	_bootverbose,8,3                ## @bootverbose
L_.str.1:                               ## @.str.1
	.asciz	"msi: routing MSI IRQ %d to local APIC %u vector %u\n"

L_.str.2:                               ## @.str.2
	.asciz	"dead MSI 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	_msi_alloc                      ; -- Begin function msi_alloc
	.p2align	2
_msi_alloc:                             ; @msi_alloc
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #128
	.cfi_def_cfa_offset 128
	stp	x28, x27, [sp, #32]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #48]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #64]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #80]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #96]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #112]            ; 16-byte Folded Spill
	add	x29, sp, #112
	.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
Lloh0:
	adrp	x8, _msi_enabled@GOTPAGE
Lloh1:
	ldr	x8, [x8, _msi_enabled@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	cbz	w8, LBB0_30
; %bb.1:
	mov	x22, x3
	mov	x28, x2
	mov	x20, x1
	add	x1, sp, #24
	str	x0, [sp, #16]                   ; 8-byte Folded Spill
	bl	_bus_get_domain
	cbz	x0, LBB0_3
; %bb.2:
	str	xzr, [sp, #24]
LBB0_3:
	cmp	w20, #2
	b.lt	LBB0_5
; %bb.4:
	lsl	w0, w20, #3
Lloh3:
	adrp	x8, _M_MSI@GOTPAGE
Lloh4:
	ldr	x8, [x8, _M_MSI@GOTPAGEOFF]
Lloh5:
	ldr	w1, [x8]
Lloh6:
	adrp	x8, _M_WAITOK@GOTPAGE
Lloh7:
	ldr	x8, [x8, _M_WAITOK@GOTPAGEOFF]
Lloh8:
	ldr	w2, [x8]
	bl	_malloc
	str	x0, [sp, #8]                    ; 8-byte Folded Spill
	b	LBB0_6
LBB0_5:
	str	xzr, [sp, #8]                   ; 8-byte Folded Spill
LBB0_6:
Lloh9:
	adrp	x24, _msi_lock@GOTPAGE
Lloh10:
	ldr	x24, [x24, _msi_lock@GOTPAGEOFF]
Lloh11:
	adrp	x23, _first_msi_irq@GOTPAGE
Lloh12:
	ldr	x23, [x23, _first_msi_irq@GOTPAGEOFF]
Lloh13:
	adrp	x26, _num_msi_irqs@GOTPAGE
Lloh14:
	ldr	x26, [x26, _num_msi_irqs@GOTPAGEOFF]
LBB0_7:                                 ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_10 Depth 2
                                        ;     Child Loop BB0_17 Depth 2
	mov	x0, x24
	bl	_mtx_lock
	ldr	w25, [x23]
	ldr	w8, [x26]
	cmp	w8, #1
	b.lt	LBB0_13
; %bb.8:                                ;   in Loop: Header=BB0_7 Depth=1
	mov	w27, #0
	b	LBB0_10
LBB0_9:                                 ;   in Loop: Header=BB0_10 Depth=2
	add	w25, w25, #1
	ldr	w8, [x23]
	ldr	w9, [x26]
	add	w8, w9, w8
	cmp	w25, w8
	b.ge	LBB0_14
LBB0_10:                                ;   Parent Loop BB0_7 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	mov	x0, x25
	bl	_intr_lookup_source
	cbz	x0, LBB0_14
; %bb.11:                               ;   in Loop: Header=BB0_10 Depth=2
	ldr	x8, [x0, #48]
	cbnz	x8, LBB0_9
; %bb.12:                               ;   in Loop: Header=BB0_10 Depth=2
	str	w25, [x22, w27, sxtw #2]
	add	w27, w27, #1
	cmp	w27, w20
	b.ne	LBB0_9
	b	LBB0_18
LBB0_13:                                ;   in Loop: Header=BB0_7 Depth=1
	mov	w27, #0
LBB0_14:                                ;   in Loop: Header=BB0_7 Depth=1
	cmp	w27, w20
	b.ge	LBB0_19
; %bb.15:                               ;   in Loop: Header=BB0_7 Depth=1
	add	w8, w25, w20
	sub	w19, w8, w27
	ldr	w8, [x23]
	ldr	w9, [x26]
	add	w21, w9, w8
	mov	x0, x24
	bl	_mtx_unlock
	cmp	w19, w21
	b.gt	LBB0_29
; %bb.16:                               ;   in Loop: Header=BB0_7 Depth=1
	sub	w19, w20, w27
LBB0_17:                                ;   Parent Loop BB0_7 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	bl	_msi_create_source
	subs	w19, w19, #1
	b.ne	LBB0_17
	b	LBB0_7
LBB0_18:
	mov	x27, x20
LBB0_19:
	cmp	w27, w20
	cset	w0, eq
Lloh15:
	adrp	x1, l_.str@PAGE
Lloh16:
	add	x1, x1, l_.str@PAGEOFF
	bl	_KASSERT
	ldr	x0, [sp, #24]
	bl	_intr_next_cpu
	mov	x24, x0
	mov	x1, x22
	mov	x2, x20
	mov	x3, x28
	bl	_apic_alloc_vectors
	cbz	w0, LBB0_28
; %bb.20:
	mov	x26, x0
	str	w28, [sp, #4]                   ; 4-byte Folded Spill
	ldr	w0, [x22]
	bl	_intr_lookup_source
	mov	x25, x0
	cmp	w20, #1
	b.lt	LBB0_25
; %bb.21:
Lloh17:
	adrp	x21, _bootverbose@GOTPAGE
Lloh18:
	ldr	x21, [x21, _bootverbose@GOTPAGEOFF]
	mov	w28, w20
Lloh19:
	adrp	x27, l_.str.2@PAGE
Lloh20:
	add	x27, x27, l_.str.2@PAGEOFF
	mov	x19, x22
	b	LBB0_23
LBB0_22:                                ;   in Loop: Header=BB0_23 Depth=1
	str	x25, [x23, #40]
	ldr	x8, [x23, #32]
	cmp	x8, #0
	cset	w0, eq
	mov	x1, x27
	bl	_KASSERT
	add	w26, w26, #1
	add	x19, x19, #4
	subs	x28, x28, #1
	b.eq	LBB0_25
LBB0_23:                                ; =>This Inner Loop Header: Depth=1
	ldr	w0, [x19]
	bl	_intr_lookup_source
	mov	x23, x0
	ldr	x8, [sp, #16]                   ; 8-byte Folded Reload
	str	x8, [x0, #48]
	stp	w24, w26, [x0]
	ldr	x8, [x21]
	cbz	x8, LBB0_22
; %bb.24:                               ;   in Loop: Header=BB0_23 Depth=1
	ldr	w1, [x23, #8]
Lloh21:
	adrp	x0, l_.str.1@PAGE
Lloh22:
	add	x0, x0, l_.str.1@PAGEOFF
	mov	x2, x24
	mov	x3, x26
	bl	_printf
	b	LBB0_22
LBB0_25:
	ldr	w8, [sp, #4]                    ; 4-byte Folded Reload
	stp	w20, w8, [x25, #12]
	cmp	w20, #1
	ldr	x19, [sp, #8]                   ; 8-byte Folded Reload
	b.le	LBB0_27
; %bb.26:
	lsl	w2, w20, #3
	mov	x0, x19
	mov	x1, x22
	bl	_memmove
LBB0_27:
	str	x19, [x25, #24]
Lloh23:
	adrp	x0, _msi_lock@GOTPAGE
Lloh24:
	ldr	x0, [x0, _msi_lock@GOTPAGEOFF]
	bl	_mtx_unlock
	mov	w0, #0
	b	LBB0_32
LBB0_28:
Lloh25:
	adrp	x0, _msi_lock@GOTPAGE
Lloh26:
	ldr	x0, [x0, _msi_lock@GOTPAGEOFF]
	bl	_mtx_unlock
Lloh27:
	adrp	x8, _M_MSI@GOTPAGE
Lloh28:
	ldr	x8, [x8, _M_MSI@GOTPAGEOFF]
Lloh29:
	ldr	w1, [x8]
	ldr	x0, [sp, #8]                    ; 8-byte Folded Reload
	bl	_free
Lloh30:
	adrp	x8, _ENOSPC@GOTPAGE
Lloh31:
	ldr	x8, [x8, _ENOSPC@GOTPAGEOFF]
	b	LBB0_31
LBB0_29:
Lloh32:
	adrp	x8, _M_MSI@GOTPAGE
Lloh33:
	ldr	x8, [x8, _M_MSI@GOTPAGEOFF]
Lloh34:
	ldr	w1, [x8]
	ldr	x0, [sp, #8]                    ; 8-byte Folded Reload
	bl	_free
LBB0_30:
Lloh35:
	adrp	x8, _ENXIO@GOTPAGE
Lloh36:
	ldr	x8, [x8, _ENXIO@GOTPAGEOFF]
LBB0_31:
	ldr	w0, [x8]
LBB0_32:
	ldp	x29, x30, [sp, #112]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #96]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #80]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #64]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #48]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #32]             ; 16-byte Folded Reload
	add	sp, sp, #128
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh13, Lloh14
	.loh AdrpLdrGot	Lloh11, Lloh12
	.loh AdrpLdrGot	Lloh9, Lloh10
	.loh AdrpAdd	Lloh15, Lloh16
	.loh AdrpAdd	Lloh19, Lloh20
	.loh AdrpLdrGot	Lloh17, Lloh18
	.loh AdrpAdd	Lloh21, Lloh22
	.loh AdrpLdrGot	Lloh23, Lloh24
	.loh AdrpLdrGot	Lloh30, Lloh31
	.loh AdrpLdrGotLdr	Lloh27, Lloh28, Lloh29
	.loh AdrpLdrGot	Lloh25, Lloh26
	.loh AdrpLdrGotLdr	Lloh32, Lloh33, Lloh34
	.loh AdrpLdrGot	Lloh35, Lloh36
	.cfi_endproc
                                        ; -- End function
	.comm	_msi_enabled,4,2                ; @msi_enabled
	.comm	_ENXIO,4,2                      ; @ENXIO
	.comm	_M_MSI,4,2                      ; @M_MSI
	.comm	_M_WAITOK,4,2                   ; @M_WAITOK
	.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
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"count mismatch"

	.comm	_ENOSPC,4,2                     ; @ENOSPC
	.comm	_bootverbose,8,3                ; @bootverbose
l_.str.1:                               ; @.str.1
	.asciz	"msi: routing MSI IRQ %d to local APIC %u vector %u\n"

l_.str.2:                               ; @.str.2
	.asciz	"dead MSI has handlers"

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