	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ppt_setup_msi                  ## -- Begin function ppt_setup_msi
	.p2align	4, 0x90
_ppt_setup_msi:                         ## @ppt_setup_msi
	.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	$56, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	24(%rbp), %r14d
	testl	%r14d, %r14d
	js	LBB0_8
## %bb.1:
	movq	_MAX_MSIMSGS@GOTPCREL(%rip), %rax
	cmpl	%r14d, (%rax)
	jl	LBB0_8
## %bb.2:
	movq	%r9, %r12
	movq	%rdi, %rbx
	movl	%edx, %edi
	movl	%ecx, %esi
	movl	%r8d, %edx
	callq	_ppt_find
	testq	%rax, %rax
	je	LBB0_5
## %bb.3:
	movq	%rax, %r13
	cmpq	%rbx, 40(%rax)
	je	LBB0_6
## %bb.4:
	movq	_EBUSY@GOTPCREL(%rip), %rax
	jmp	LBB0_9
LBB0_5:
	movq	_ENOENT@GOTPCREL(%rip), %rax
	jmp	LBB0_9
LBB0_6:
	movq	%r13, %rdi
	callq	_ppt_teardown_msi
	testl	%r14d, %r14d
	je	LBB0_11
## %bb.7:
	movq	_RF_ACTIVE@GOTPCREL(%rip), %rax
	movl	(%rax), %r15d
	movl	32(%r13), %edi
	callq	_pci_msi_count
	xorl	%edx, %edx
	xorl	%esi, %esi
	testl	%eax, %eax
	setne	%bl
	movq	_RF_SHAREABLE@GOTPCREL(%rip), %rcx
	cmovel	(%rcx), %edx
	movl	%edx, -44(%rbp)                 ## 4-byte Spill
	movl	$1, %ecx
	cmovnel	%eax, %ecx
	cmpl	%r14d, %ecx
	jge	LBB0_12
LBB0_8:
	movq	_EINVAL@GOTPCREL(%rip), %rax
LBB0_9:
	movl	(%rax), %eax
LBB0_10:
                                        ## kill: def $eax killed $eax killed $rax
	addq	$56, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_12:
	movq	%r12, -80(%rbp)                 ## 8-byte Spill
	testl	%eax, %eax
	je	LBB0_15
## %bb.13:
	movl	%r14d, -48(%rbp)
	movl	32(%r13), %edi
	leaq	-48(%rbp), %rsi
	callq	_pci_alloc_msi
                                        ## kill: def $eax killed $eax def $rax
	testl	%eax, %eax
	jne	LBB0_10
## %bb.14:
	cmpl	%r14d, -48(%rbp)
	movl	$0, %esi
	jne	LBB0_21
LBB0_15:
	movq	16(%rbp), %rax
	movq	%rax, -64(%rbp)                 ## 8-byte Spill
	orl	%r15d, -44(%rbp)                ## 4-byte Folded Spill
	movb	%bl, %sil
	movl	%esi, (%r13)
	movl	%r14d, %eax
	shlq	$3, %rax
	leaq	(%rax,%rax,2), %rax
	movq	%rax, -72(%rbp)                 ## 8-byte Spill
	movl	$1, %ebx
	xorl	%r12d, %r12d
	xorl	%r15d, %r15d
	movl	%esi, %r14d
LBB0_16:                                ## =>This Inner Loop Header: Depth=1
	cmpq	%r15, -72(%rbp)                 ## 8-byte Folded Reload
	je	LBB0_11
## %bb.17:                              ##   in Loop: Header=BB0_16 Depth=1
	movl	%ebx, 4(%r13)
	movq	8(%r13), %rax
	movq	$0, (%rax,%r12)
	movl	%r14d, -56(%rbp)
	movl	32(%r13), %edi
	movq	_SYS_RES_IRQ@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	-56(%rbp), %rdx
	movl	-44(%rbp), %ecx                 ## 4-byte Reload
	callq	_bus_alloc_resource_any
	movq	24(%r13), %rcx
	movq	%rax, (%rcx,%r12)
	movq	24(%r13), %rax
	cmpq	$0, (%rax,%r12)
	je	LBB0_19
## %bb.18:                              ##   in Loop: Header=BB0_16 Depth=1
	movq	16(%r13), %rcx
	leaq	(%rcx,%r15), %r9
	movq	%r13, 16(%rcx,%r15)
	movq	-80(%rbp), %rdx                 ## 8-byte Reload
	movq	%rdx, 8(%rcx,%r15)
	movl	%ebx, -52(%rbp)                 ## 4-byte Spill
	movq	-64(%rbp), %rbx                 ## 8-byte Reload
	movq	%rbx, (%rcx,%r15)
	movl	32(%r13), %edi
	movq	_INTR_MPSAFE@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edx
	movq	_INTR_TYPE_NET@GOTPCREL(%rip), %rcx
	orl	(%rcx), %edx
	movq	(%rax,%r12), %rsi
	movq	_pptintr@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movq	8(%r13), %rax
	addq	%r12, %rax
	movq	%rax, (%rsp)
	xorl	%r8d, %r8d
	callq	_bus_setup_intr
	addq	$24, %r15
	addq	$8, %r12
	incq	%rbx
	movq	%rbx, -64(%rbp)                 ## 8-byte Spill
	movl	-52(%rbp), %ebx                 ## 4-byte Reload
	incl	%r14d
	incl	%ebx
	testl	%eax, %eax
	je	LBB0_16
LBB0_19:
	movq	%r13, %rdi
	callq	_ppt_teardown_msi
	movq	_ENXIO@GOTPCREL(%rip), %rax
	jmp	LBB0_9
LBB0_11:
	xorl	%eax, %eax
	jmp	LBB0_10
LBB0_21:
	movl	32(%r13), %edi
	callq	_pci_release_msi
	movq	_ENOSPC@GOTPCREL(%rip), %rax
	jmp	LBB0_9
	.cfi_endproc
                                        ## -- End function
	.comm	_MAX_MSIMSGS,4,2                ## @MAX_MSIMSGS
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_ENOENT,4,2                     ## @ENOENT
	.comm	_EBUSY,4,2                      ## @EBUSY
	.comm	_RF_ACTIVE,4,2                  ## @RF_ACTIVE
	.comm	_RF_SHAREABLE,4,2               ## @RF_SHAREABLE
	.comm	_ENOSPC,4,2                     ## @ENOSPC
	.comm	_SYS_RES_IRQ,4,2                ## @SYS_RES_IRQ
	.comm	_INTR_TYPE_NET,4,2              ## @INTR_TYPE_NET
	.comm	_INTR_MPSAFE,4,2                ## @INTR_MPSAFE
	.comm	_pptintr,4,2                    ## @pptintr
	.comm	_ENXIO,4,2                      ## @ENXIO
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ppt_setup_msi                  ; -- Begin function ppt_setup_msi
	.p2align	2
_ppt_setup_msi:                         ; @ppt_setup_msi
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x28, x27, [sp, #16]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.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
	tbnz	w7, #31, LBB0_8
; %bb.1:
	mov	x23, x7
Lloh0:
	adrp	x8, _MAX_MSIMSGS@GOTPAGE
Lloh1:
	ldr	x8, [x8, _MAX_MSIMSGS@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	cmp	w8, w7
	b.lt	LBB0_8
; %bb.2:
	mov	x19, x6
	mov	x20, x5
	mov	x22, x0
	mov	x0, x2
	mov	x1, x3
	mov	x2, x4
	bl	_ppt_find
	cbz	x0, LBB0_5
; %bb.3:
	mov	x21, x0
	ldr	x8, [x0, #40]
	cmp	x8, x22
	b.eq	LBB0_6
; %bb.4:
Lloh3:
	adrp	x8, _EBUSY@GOTPAGE
Lloh4:
	ldr	x8, [x8, _EBUSY@GOTPAGEOFF]
	b	LBB0_9
LBB0_5:
Lloh5:
	adrp	x8, _ENOENT@GOTPAGE
Lloh6:
	ldr	x8, [x8, _ENOENT@GOTPAGEOFF]
	b	LBB0_9
LBB0_6:
	mov	x0, x21
	bl	_ppt_teardown_msi
	cbz	w23, LBB0_19
; %bb.7:
Lloh7:
	adrp	x8, _RF_ACTIVE@GOTPAGE
Lloh8:
	ldr	x8, [x8, _RF_ACTIVE@GOTPAGEOFF]
Lloh9:
	ldr	w22, [x8]
	ldr	w0, [x21, #32]
	bl	_pci_msi_count
Lloh10:
	adrp	x8, _RF_SHAREABLE@GOTPAGE
Lloh11:
	ldr	x8, [x8, _RF_SHAREABLE@GOTPAGEOFF]
Lloh12:
	ldr	w8, [x8]
	cmp	w0, #0
	csel	w27, w8, wzr, eq
	cset	w24, ne
	csinc	w8, w0, wzr, ne
	cmp	w8, w23
	b.ge	LBB0_11
LBB0_8:
Lloh13:
	adrp	x8, _EINVAL@GOTPAGE
Lloh14:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
LBB0_9:
	ldr	w0, [x8]
LBB0_10:
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
LBB0_11:
	cbz	w0, LBB0_14
; %bb.12:
	str	w23, [sp, #8]
	ldr	w0, [x21, #32]
	add	x1, sp, #8
	bl	_pci_alloc_msi
	cbnz	w0, LBB0_10
; %bb.13:
	ldr	w8, [sp, #8]
	cmp	w8, w23
	b.ne	LBB0_20
LBB0_14:
	mov	x25, #0
	mov	x26, #0
	orr	w22, w27, w22
	str	w24, [x21]
	mov	w8, #24
	umull	x23, w23, w8
	mov	w27, #1
Lloh15:
	adrp	x28, _pptintr@GOTPAGE
Lloh16:
	ldr	x28, [x28, _pptintr@GOTPAGEOFF]
LBB0_15:                                ; =>This Inner Loop Header: Depth=1
	cmp	x23, x26
	b.eq	LBB0_19
; %bb.16:                               ;   in Loop: Header=BB0_15 Depth=1
	ldr	x8, [x21, #8]
	str	xzr, [x8, x25]
	str	w27, [x21, #4]
	add	w8, w24, w27
	sub	w8, w8, #1
	str	w8, [sp, #12]
	ldr	w0, [x21, #32]
Lloh17:
	adrp	x8, _SYS_RES_IRQ@GOTPAGE
Lloh18:
	ldr	x8, [x8, _SYS_RES_IRQ@GOTPAGEOFF]
Lloh19:
	ldr	w1, [x8]
	add	x2, sp, #12
	mov	x3, x22
	bl	_bus_alloc_resource_any
	ldr	x8, [x21, #24]
	str	x0, [x8, x25]
	ldr	x8, [x21, #24]
	ldr	x9, [x8, x25]
	cbz	x9, LBB0_18
; %bb.17:                               ;   in Loop: Header=BB0_15 Depth=1
	ldp	x10, x9, [x21, #8]
	add	x5, x9, x26
	stp	x20, x21, [x5, #8]
	str	x19, [x5]
	ldr	x1, [x8, x25]
	ldr	w0, [x21, #32]
Lloh20:
	adrp	x8, _INTR_TYPE_NET@GOTPAGE
Lloh21:
	ldr	x8, [x8, _INTR_TYPE_NET@GOTPAGEOFF]
Lloh22:
	ldr	w8, [x8]
Lloh23:
	adrp	x9, _INTR_MPSAFE@GOTPAGE
Lloh24:
	ldr	x9, [x9, _INTR_MPSAFE@GOTPAGEOFF]
Lloh25:
	ldr	w9, [x9]
	orr	w2, w9, w8
	ldr	w3, [x28]
	add	x6, x10, x25
	mov	x4, #0
	bl	_bus_setup_intr
	add	x26, x26, #24
	add	x25, x25, #8
	add	x19, x19, #1
	add	w27, w27, #1
	cbz	w0, LBB0_15
LBB0_18:
	mov	x0, x21
	bl	_ppt_teardown_msi
Lloh26:
	adrp	x8, _ENXIO@GOTPAGE
Lloh27:
	ldr	x8, [x8, _ENXIO@GOTPAGEOFF]
	b	LBB0_9
LBB0_19:
	mov	w0, #0
	b	LBB0_10
LBB0_20:
	ldr	w0, [x21, #32]
	bl	_pci_release_msi
Lloh28:
	adrp	x8, _ENOSPC@GOTPAGE
Lloh29:
	ldr	x8, [x8, _ENOSPC@GOTPAGEOFF]
	b	LBB0_9
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh13, Lloh14
	.loh AdrpLdrGot	Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh25
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGot	Lloh26, Lloh27
	.loh AdrpLdrGot	Lloh28, Lloh29
	.cfi_endproc
                                        ; -- End function
	.comm	_MAX_MSIMSGS,4,2                ; @MAX_MSIMSGS
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_ENOENT,4,2                     ; @ENOENT
	.comm	_EBUSY,4,2                      ; @EBUSY
	.comm	_RF_ACTIVE,4,2                  ; @RF_ACTIVE
	.comm	_RF_SHAREABLE,4,2               ; @RF_SHAREABLE
	.comm	_ENOSPC,4,2                     ; @ENOSPC
	.comm	_SYS_RES_IRQ,4,2                ; @SYS_RES_IRQ
	.comm	_INTR_TYPE_NET,4,2              ; @INTR_TYPE_NET
	.comm	_INTR_MPSAFE,4,2                ; @INTR_MPSAFE
	.comm	_pptintr,4,2                    ; @pptintr
	.comm	_ENXIO,4,2                      ; @ENXIO
.subsections_via_symbols
