	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function amdvi_alloc_intr_resources
_amdvi_alloc_intr_resources:            ## @amdvi_alloc_intr_resources
	.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, %r13
	movl	16(%rdi), %r14d
	movl	%r14d, %edi
	callq	_device_get_parent
	movl	%eax, %edi
	callq	_device_get_parent
	movl	%eax, %r15d
	movl	40(%r13), %edi
	callq	_PCI_RID2BUS
	movl	%eax, %r12d
	movl	40(%r13), %edi
	callq	_PCI_RID2SLOT
	movl	%eax, %ebx
	movl	40(%r13), %edi
	callq	_PCI_RID2FUNC
	movl	%r12d, %edi
	movl	%ebx, %esi
	movl	%eax, %edx
	callq	_pci_find_bsf
	movl	%eax, %r12d
	movl	%eax, %edi
	callq	_device_is_attached
	testq	%rax, %rax
	je	LBB0_2
## %bb.1:
	movl	%r12d, %edi
	callq	_device_get_driver
	movl	(%rax), %edx
	leaq	L_.str(%rip), %rsi
	movl	%r14d, %edi
	xorl	%eax, %eax
	callq	_device_printf
LBB0_2:
	movl	$-1, (%r13)
	movq	$0, 32(%r13)
	movl	%r15d, %edi
	movl	%r14d, %esi
	movl	$1, %edx
	movl	$1, %ecx
	movq	%r13, %r8
	callq	_PCIB_ALLOC_MSI
	testl	%eax, %eax
	je	LBB0_4
## %bb.3:
	leaq	L_.str.1(%rip), %rsi
	movl	%r14d, %edi
	xorl	%eax, %eax
	callq	_device_printf
	movq	_ENOENT@GOTPCREL(%rip), %rax
	jmp	LBB0_7
LBB0_4:
	movq	_SYS_RES_IRQ@GOTPCREL(%rip), %rbx
	movl	(%rbx), %esi
	movq	32(%r13), %rdx
	movl	(%r13), %ecx
	movl	%r14d, %edi
	movl	$1, %r8d
	callq	_bus_set_resource
	testl	%eax, %eax
	je	LBB0_9
## %bb.5:
	leaq	L_.str.2(%rip), %rsi
	movl	%r14d, %edi
	xorl	%eax, %eax
	callq	_device_printf
LBB0_6:
	movq	_ENXIO@GOTPCREL(%rip), %rax
LBB0_7:
	movl	(%rax), %r15d
LBB0_8:
	movl	%r15d, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_9:
	leaq	32(%r13), %rdx
	movl	(%rbx), %esi
	movq	_RF_ACTIVE@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movl	%r14d, %edi
	callq	_bus_alloc_resource_any
	movq	%rax, 24(%r13)
	testq	%rax, %rax
	je	LBB0_12
## %bb.10:
	movq	_INTR_TYPE_MISC@GOTPCREL(%rip), %rcx
	movq	_INTR_MPSAFE@GOTPCREL(%rip), %rdx
	movl	(%rdx), %edx
	orl	(%rcx), %edx
	movq	_amdvi_event_intr@GOTPCREL(%rip), %rcx
	movl	(%rcx), %r8d
	leaq	20(%r13), %rcx
	movq	%rcx, (%rsp)
	movl	%r14d, %edi
	movq	%rax, %rsi
	xorl	%ecx, %ecx
	movq	%r13, %r9
	callq	_bus_setup_intr
	testq	%rax, %rax
	je	LBB0_13
## %bb.11:
	leaq	L_.str.4(%rip), %rsi
	movl	%r14d, %edi
	xorl	%eax, %eax
	callq	_device_printf
	movl	16(%r13), %edi
	movl	(%rbx), %esi
	movq	32(%r13), %rdx
	movq	24(%r13), %rcx
	callq	_bus_release_resource
	movq	$0, 24(%r13)
	jmp	LBB0_6
LBB0_12:
	leaq	L_.str.3(%rip), %rsi
	movl	%r14d, %edi
	xorl	%eax, %eax
	callq	_device_printf
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	jmp	LBB0_7
LBB0_13:
	movq	24(%r13), %rsi
	movl	20(%r13), %edx
	leaq	L_.str.5(%rip), %rcx
	movl	%r14d, %edi
	callq	_bus_describe_intr
	movl	(%r13), %edx
	leaq	-48(%rbp), %rcx
	leaq	-44(%rbp), %r8
	movl	%r15d, %edi
	movl	%r14d, %esi
	callq	_PCIB_MAP_MSI
	testl	%eax, %eax
	je	LBB0_15
## %bb.14:
	movl	%eax, %r15d
	leaq	L_.str.6(%rip), %rsi
	movl	%r14d, %edi
	movl	%eax, %edx
	xorl	%eax, %eax
	callq	_device_printf
	movl	16(%r13), %edi
	callq	_amdvi_free_evt_intr_res
	jmp	LBB0_8
LBB0_15:
	movq	_AMDVI_STATUS_EV_OF@GOTPCREL(%rip), %rax
	movq	_AMDVI_STATUS_EV_INTR@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	orl	(%rax), %ecx
	movq	8(%r13), %rax
	andl	%ecx, (%rax)
	movl	-48(%rbp), %esi
	movl	-44(%rbp), %edx
	movl	%r12d, %edi
	callq	_pci_enable_msi
	xorl	%r15d, %r15d
	jmp	LBB0_8
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"warning: IOMMU device is claimed by another driver %s\n"

L_.str.1:                               ## @.str.1
	.asciz	"Couldn't find event MSI IRQ resource.\n"

	.comm	_ENOENT,4,2                     ## @ENOENT
	.comm	_SYS_RES_IRQ,4,2                ## @SYS_RES_IRQ
L_.str.2:                               ## @.str.2
	.asciz	"Couldn't set event MSI resource.\n"

	.comm	_ENXIO,4,2                      ## @ENXIO
	.comm	_RF_ACTIVE,4,2                  ## @RF_ACTIVE
L_.str.3:                               ## @.str.3
	.asciz	"Unable to allocate event INTR resource.\n"

	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.comm	_INTR_TYPE_MISC,4,2             ## @INTR_TYPE_MISC
	.comm	_INTR_MPSAFE,4,2                ## @INTR_MPSAFE
	.comm	_amdvi_event_intr,4,2           ## @amdvi_event_intr
L_.str.4:                               ## @.str.4
	.asciz	"Fail to setup event intr\n"

L_.str.5:                               ## @.str.5
	.asciz	"fault"

L_.str.6:                               ## @.str.6
	.asciz	"Event interrupt config failed, err=%d.\n"

	.comm	_AMDVI_STATUS_EV_OF,4,2         ## @AMDVI_STATUS_EV_OF
	.comm	_AMDVI_STATUS_EV_INTR,4,2       ## @AMDVI_STATUS_EV_INTR
	.no_dead_strip	_amdvi_alloc_intr_resources
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function amdvi_alloc_intr_resources
_amdvi_alloc_intr_resources:            ; @amdvi_alloc_intr_resources
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #80
	.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
	mov	x19, x0
	ldr	w20, [x0, #16]
	mov	x0, x20
	bl	_device_get_parent
	bl	_device_get_parent
	mov	x21, x0
	ldr	w0, [x19, #40]
	bl	_PCI_RID2BUS
	mov	x22, x0
	ldr	w0, [x19, #40]
	bl	_PCI_RID2SLOT
	mov	x23, x0
	ldr	w0, [x19, #40]
	bl	_PCI_RID2FUNC
	mov	x2, x0
	mov	x0, x22
	mov	x1, x23
	bl	_pci_find_bsf
	mov	x22, x0
	bl	_device_is_attached
	cbz	x0, LBB0_2
; %bb.1:
	mov	x0, x22
	bl	_device_get_driver
	ldr	w8, [x0]
	str	x8, [sp]
Lloh0:
	adrp	x1, l_.str@PAGE
Lloh1:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x20
	bl	_device_printf
LBB0_2:
	mov	w8, #-1
	str	w8, [x19]
	mov	x23, x19
	str	xzr, [x23, #32]!
	mov	x0, x21
	mov	x1, x20
	mov	w2, #1
	mov	w3, #1
	mov	x4, x19
	bl	_PCIB_ALLOC_MSI
	cbz	w0, LBB0_4
; %bb.3:
Lloh2:
	adrp	x1, l_.str.1@PAGE
Lloh3:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x0, x20
	bl	_device_printf
Lloh4:
	adrp	x8, _ENOENT@GOTPAGE
Lloh5:
	ldr	x8, [x8, _ENOENT@GOTPAGEOFF]
	b	LBB0_7
LBB0_4:
Lloh6:
	adrp	x24, _SYS_RES_IRQ@GOTPAGE
Lloh7:
	ldr	x24, [x24, _SYS_RES_IRQ@GOTPAGEOFF]
	ldr	w1, [x24]
	ldr	x2, [x19, #32]
	ldr	w3, [x19]
	mov	x0, x20
	mov	w4, #1
	bl	_bus_set_resource
	cbz	w0, LBB0_9
; %bb.5:
Lloh8:
	adrp	x1, l_.str.2@PAGE
Lloh9:
	add	x1, x1, l_.str.2@PAGEOFF
	mov	x0, x20
	bl	_device_printf
LBB0_6:
Lloh10:
	adrp	x8, _ENXIO@GOTPAGE
Lloh11:
	ldr	x8, [x8, _ENXIO@GOTPAGEOFF]
LBB0_7:
	ldr	w21, [x8]
LBB0_8:
	mov	x0, x21
	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
	add	sp, sp, #80
	ret
LBB0_9:
	ldr	w1, [x24]
Lloh12:
	adrp	x8, _RF_ACTIVE@GOTPAGE
Lloh13:
	ldr	x8, [x8, _RF_ACTIVE@GOTPAGEOFF]
Lloh14:
	ldr	w3, [x8]
	mov	x0, x20
	mov	x2, x23
	bl	_bus_alloc_resource_any
	str	x0, [x19, #24]
	cbz	x0, LBB0_12
; %bb.10:
	mov	x1, x0
Lloh15:
	adrp	x8, _INTR_TYPE_MISC@GOTPAGE
Lloh16:
	ldr	x8, [x8, _INTR_TYPE_MISC@GOTPAGEOFF]
Lloh17:
	ldr	w8, [x8]
Lloh18:
	adrp	x9, _INTR_MPSAFE@GOTPAGE
Lloh19:
	ldr	x9, [x9, _INTR_MPSAFE@GOTPAGEOFF]
Lloh20:
	ldr	w9, [x9]
	orr	w2, w9, w8
Lloh21:
	adrp	x8, _amdvi_event_intr@GOTPAGE
Lloh22:
	ldr	x8, [x8, _amdvi_event_intr@GOTPAGEOFF]
Lloh23:
	ldr	w4, [x8]
	add	x6, x19, #20
	mov	x0, x20
	mov	x3, #0
	mov	x5, x19
	bl	_bus_setup_intr
	cbz	x0, LBB0_13
; %bb.11:
Lloh24:
	adrp	x1, l_.str.4@PAGE
Lloh25:
	add	x1, x1, l_.str.4@PAGEOFF
	mov	x0, x20
	bl	_device_printf
	ldr	w0, [x19, #16]
	ldr	w1, [x24]
	ldp	x3, x2, [x19, #24]
	bl	_bus_release_resource
	str	xzr, [x19, #24]
	b	LBB0_6
LBB0_12:
Lloh26:
	adrp	x1, l_.str.3@PAGE
Lloh27:
	add	x1, x1, l_.str.3@PAGEOFF
	mov	x0, x20
	bl	_device_printf
Lloh28:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh29:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
	b	LBB0_7
LBB0_13:
	ldr	x1, [x19, #24]
	ldr	w2, [x19, #20]
Lloh30:
	adrp	x3, l_.str.5@PAGE
Lloh31:
	add	x3, x3, l_.str.5@PAGEOFF
	mov	x0, x20
	bl	_bus_describe_intr
	ldr	w2, [x19]
	add	x3, sp, #12
	add	x4, sp, #8
	mov	x0, x21
	mov	x1, x20
	bl	_PCIB_MAP_MSI
	mov	x21, x0
	cbz	w0, LBB0_15
; %bb.14:
	str	x21, [sp]
Lloh32:
	adrp	x1, l_.str.6@PAGE
Lloh33:
	add	x1, x1, l_.str.6@PAGEOFF
	mov	x0, x20
	bl	_device_printf
	ldr	w0, [x19, #16]
	bl	_amdvi_free_evt_intr_res
	b	LBB0_8
LBB0_15:
	ldr	x8, [x19, #8]
Lloh34:
	adrp	x9, _AMDVI_STATUS_EV_OF@GOTPAGE
Lloh35:
	ldr	x9, [x9, _AMDVI_STATUS_EV_OF@GOTPAGEOFF]
Lloh36:
	ldr	w9, [x9]
Lloh37:
	adrp	x10, _AMDVI_STATUS_EV_INTR@GOTPAGE
Lloh38:
	ldr	x10, [x10, _AMDVI_STATUS_EV_INTR@GOTPAGEOFF]
Lloh39:
	ldr	w10, [x10]
	orr	w9, w10, w9
	ldr	w10, [x8]
	and	w9, w10, w9
	str	w9, [x8]
	ldp	w2, w1, [sp, #8]
	mov	x0, x22
	bl	_pci_enable_msi
	b	LBB0_8
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpAdd	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpAdd	Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpAdd	Lloh24, Lloh25
	.loh AdrpLdrGot	Lloh28, Lloh29
	.loh AdrpAdd	Lloh26, Lloh27
	.loh AdrpAdd	Lloh30, Lloh31
	.loh AdrpAdd	Lloh32, Lloh33
	.loh AdrpLdrGotLdr	Lloh37, Lloh38, Lloh39
	.loh AdrpLdrGotLdr	Lloh34, Lloh35, Lloh36
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"warning: IOMMU device is claimed by another driver %s\n"

l_.str.1:                               ; @.str.1
	.asciz	"Couldn't find event MSI IRQ resource.\n"

	.comm	_ENOENT,4,2                     ; @ENOENT
	.comm	_SYS_RES_IRQ,4,2                ; @SYS_RES_IRQ
l_.str.2:                               ; @.str.2
	.asciz	"Couldn't set event MSI resource.\n"

	.comm	_ENXIO,4,2                      ; @ENXIO
	.comm	_RF_ACTIVE,4,2                  ; @RF_ACTIVE
l_.str.3:                               ; @.str.3
	.asciz	"Unable to allocate event INTR resource.\n"

	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.comm	_INTR_TYPE_MISC,4,2             ; @INTR_TYPE_MISC
	.comm	_INTR_MPSAFE,4,2                ; @INTR_MPSAFE
	.comm	_amdvi_event_intr,4,2           ; @amdvi_event_intr
l_.str.4:                               ; @.str.4
	.asciz	"Fail to setup event intr\n"

l_.str.5:                               ; @.str.5
	.asciz	"fault"

l_.str.6:                               ; @.str.6
	.asciz	"Event interrupt config failed, err=%d.\n"

	.comm	_AMDVI_STATUS_EV_OF,4,2         ; @AMDVI_STATUS_EV_OF
	.comm	_AMDVI_STATUS_EV_INTR,4,2       ; @AMDVI_STATUS_EV_INTR
	.no_dead_strip	_amdvi_alloc_intr_resources
.subsections_via_symbols
