	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function madt_setup_io
_madt_setup_io:                         ## @madt_setup_io
	.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	_lapics@GOTPCREL(%rip), %r14
	xorl	%edi, %edi
	cmpq	$0, (%r14)
	setne	%dil
	leaq	L_.str(%rip), %rsi
	callq	_KASSERT
	xorl	%eax, %eax
	callq	_acpi_Startup
	movl	%eax, %ebx
	movl	%eax, %edi
	callq	_ACPI_FAILURE
	testq	%rax, %rax
	je	LBB0_2
## %bb.1:
	movl	%ebx, %edi
	callq	_AcpiFormatException
	leaq	L_.str.1(%rip), %rdi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	_printf
	leaq	L_str.6(%rip), %rdi
	callq	_puts
	leaq	L_.str.3(%rip), %rdi
	callq	_panic
LBB0_2:
	movq	_IOAPIC_MAX_ID@GOTPCREL(%rip), %r12
	movl	(%r12), %eax
	leal	8(,%rax,8), %edi
	movq	_M_MADT@GOTPCREL(%rip), %r15
	movl	(%r15), %esi
	movq	_M_WAITOK@GOTPCREL(%rip), %rax
	movq	_M_ZERO@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edx
	orl	(%rax), %edx
	callq	_malloc
	movq	_ioapics@GOTPCREL(%rip), %r13
	movq	%rax, (%r13)
	movq	_madt_parse_apics@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	xorl	%esi, %esi
	callq	_madt_walk_table
	movq	_madt_parse_ints@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	xorl	%esi, %esi
	callq	_madt_walk_table
	movq	_madt_found_sci_override@GOTPCREL(%rip), %rax
	cmpl	$0, (%rax)
	jne	LBB0_6
## %bb.3:
	movq	_AcpiGbl_FADT@GOTPCREL(%rip), %rbx
	movl	(%rbx), %edi
	leaq	-56(%rbp), %rsi
	leaq	-44(%rbp), %rdx
	callq	_madt_find_interrupt
	testq	%rax, %rax
	je	LBB0_5
## %bb.4:
	movl	(%rbx), %esi
	leaq	L_.str.4(%rip), %rdi
	xorl	%eax, %eax
	callq	_printf
	jmp	LBB0_6
LBB0_5:
	leaq	L_str(%rip), %rdi
	callq	_puts
	movq	-56(%rbp), %rdi
	movl	-44(%rbp), %esi
	movq	_INTR_POLARITY_LOW@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	callq	_ioapic_set_polarity
	movq	-56(%rbp), %rdi
	movl	-44(%rbp), %esi
	movq	_INTR_TRIGGER_LEVEL@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	callq	_ioapic_set_triggermode
LBB0_6:
	movl	(%r12), %eax
	testl	%eax, %eax
	js	LBB0_11
## %bb.7:
	movq	$-1, %rbx
	jmp	LBB0_8
	.p2align	4, 0x90
LBB0_10:                                ##   in Loop: Header=BB0_8 Depth=1
	movslq	%eax, %rcx
	incq	%rbx
	cmpq	%rcx, %rbx
	jge	LBB0_11
LBB0_8:                                 ## =>This Inner Loop Header: Depth=1
	movq	(%r13), %rcx
	movq	8(%rcx,%rbx,8), %rdi
	testq	%rdi, %rdi
	je	LBB0_10
## %bb.9:                               ##   in Loop: Header=BB0_8 Depth=1
	callq	_ioapic_register
	movl	(%r12), %eax
	jmp	LBB0_10
LBB0_11:
	movq	_ACPI_INTR_APIC@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_acpi_SetDefaultIntrModel
	movq	(%r13), %rdi
	movl	(%r15), %esi
	callq	_free
	movq	$0, (%r13)
	movq	(%r14), %rdi
	movl	(%r15), %esi
	callq	_free
	movq	$0, (%r14)
	xorl	%eax, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_lapics,8,3                     ## @lapics
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"local APICs not initialized"

L_.str.1:                               ## @.str.1
	.asciz	"MADT: ACPI Startup failed with %s\n"

L_.str.3:                               ## @.str.3
	.asciz	"Using MADT but ACPI doesn't work"

	.comm	_IOAPIC_MAX_ID,4,2              ## @IOAPIC_MAX_ID
	.comm	_M_MADT,4,2                     ## @M_MADT
	.comm	_M_WAITOK,4,2                   ## @M_WAITOK
	.comm	_M_ZERO,4,2                     ## @M_ZERO
	.comm	_ioapics,8,3                    ## @ioapics
	.comm	_madt_parse_apics,4,2           ## @madt_parse_apics
	.comm	_madt_parse_ints,4,2            ## @madt_parse_ints
	.comm	_madt_found_sci_override,4,2    ## @madt_found_sci_override
	.comm	_AcpiGbl_FADT,4,2               ## @AcpiGbl_FADT
L_.str.4:                               ## @.str.4
	.asciz	"MADT: Could not find APIC for SCI IRQ %u\n"

	.comm	_INTR_POLARITY_LOW,4,2          ## @INTR_POLARITY_LOW
	.comm	_INTR_TRIGGER_LEVEL,4,2         ## @INTR_TRIGGER_LEVEL
	.comm	_ACPI_INTR_APIC,4,2             ## @ACPI_INTR_APIC
L_str:                                  ## @str
	.asciz	"MADT: Forcing active-low polarity and level trigger for SCI"

L_str.6:                                ## @str.6
	.asciz	"Try disabling either ACPI or apic support."

	.no_dead_strip	_madt_setup_io
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function madt_setup_io
_madt_setup_io:                         ; @madt_setup_io
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #96
	.cfi_def_cfa_offset 96
	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
Lloh0:
	adrp	x20, _lapics@GOTPAGE
Lloh1:
	ldr	x20, [x20, _lapics@GOTPAGEOFF]
	ldr	x8, [x20]
	cmp	x8, #0
	cset	w0, ne
Lloh2:
	adrp	x1, l_.str@PAGE
Lloh3:
	add	x1, x1, l_.str@PAGEOFF
	bl	_KASSERT
	bl	_acpi_Startup
	mov	x19, x0
	bl	_ACPI_FAILURE
	cbz	x0, LBB0_2
; %bb.1:
	mov	x0, x19
	bl	_AcpiFormatException
	str	x0, [sp]
Lloh4:
	adrp	x0, l_.str.1@PAGE
Lloh5:
	add	x0, x0, l_.str.1@PAGEOFF
	bl	_printf
Lloh6:
	adrp	x0, l_str.6@PAGE
Lloh7:
	add	x0, x0, l_str.6@PAGEOFF
	bl	_puts
Lloh8:
	adrp	x0, l_.str.3@PAGE
Lloh9:
	add	x0, x0, l_.str.3@PAGEOFF
	bl	_panic
LBB0_2:
Lloh10:
	adrp	x21, _IOAPIC_MAX_ID@GOTPAGE
Lloh11:
	ldr	x21, [x21, _IOAPIC_MAX_ID@GOTPAGEOFF]
	ldr	w8, [x21]
	lsl	w8, w8, #3
	add	w0, w8, #8
Lloh12:
	adrp	x19, _M_MADT@GOTPAGE
Lloh13:
	ldr	x19, [x19, _M_MADT@GOTPAGEOFF]
Lloh14:
	adrp	x8, _M_WAITOK@GOTPAGE
Lloh15:
	ldr	x8, [x8, _M_WAITOK@GOTPAGEOFF]
	ldr	w1, [x19]
Lloh16:
	ldr	w8, [x8]
Lloh17:
	adrp	x9, _M_ZERO@GOTPAGE
Lloh18:
	ldr	x9, [x9, _M_ZERO@GOTPAGEOFF]
Lloh19:
	ldr	w9, [x9]
	orr	w2, w9, w8
	bl	_malloc
Lloh20:
	adrp	x22, _ioapics@GOTPAGE
Lloh21:
	ldr	x22, [x22, _ioapics@GOTPAGEOFF]
	str	x0, [x22]
Lloh22:
	adrp	x8, _madt_parse_apics@GOTPAGE
Lloh23:
	ldr	x8, [x8, _madt_parse_apics@GOTPAGEOFF]
Lloh24:
	ldr	w0, [x8]
	mov	x1, #0
	bl	_madt_walk_table
Lloh25:
	adrp	x8, _madt_parse_ints@GOTPAGE
Lloh26:
	ldr	x8, [x8, _madt_parse_ints@GOTPAGEOFF]
Lloh27:
	ldr	w0, [x8]
	mov	x1, #0
	bl	_madt_walk_table
Lloh28:
	adrp	x8, _madt_found_sci_override@GOTPAGE
Lloh29:
	ldr	x8, [x8, _madt_found_sci_override@GOTPAGEOFF]
Lloh30:
	ldr	w8, [x8]
	cbnz	w8, LBB0_5
; %bb.3:
Lloh31:
	adrp	x23, _AcpiGbl_FADT@GOTPAGE
Lloh32:
	ldr	x23, [x23, _AcpiGbl_FADT@GOTPAGEOFF]
	ldr	w0, [x23]
	add	x1, sp, #24
	add	x2, sp, #20
	bl	_madt_find_interrupt
	cbz	x0, LBB0_10
; %bb.4:
	ldr	w8, [x23]
	str	x8, [sp]
Lloh33:
	adrp	x0, l_.str.4@PAGE
Lloh34:
	add	x0, x0, l_.str.4@PAGEOFF
	bl	_printf
LBB0_5:
	ldr	w8, [x21]
	tbnz	w8, #31, LBB0_11
LBB0_6:
	mov	x23, #0
	b	LBB0_8
LBB0_7:                                 ;   in Loop: Header=BB0_8 Depth=1
	cmp	x23, w8, sxtw
	add	x23, x23, #1
	b.ge	LBB0_11
LBB0_8:                                 ; =>This Inner Loop Header: Depth=1
	ldr	x9, [x22]
	ldr	x0, [x9, x23, lsl #3]
	cbz	x0, LBB0_7
; %bb.9:                                ;   in Loop: Header=BB0_8 Depth=1
	bl	_ioapic_register
	ldr	w8, [x21]
	b	LBB0_7
LBB0_10:
Lloh35:
	adrp	x0, l_str@PAGE
Lloh36:
	add	x0, x0, l_str@PAGEOFF
	bl	_puts
	ldr	x0, [sp, #24]
	ldr	w1, [sp, #20]
Lloh37:
	adrp	x8, _INTR_POLARITY_LOW@GOTPAGE
Lloh38:
	ldr	x8, [x8, _INTR_POLARITY_LOW@GOTPAGEOFF]
Lloh39:
	ldr	w2, [x8]
	bl	_ioapic_set_polarity
	ldr	x0, [sp, #24]
	ldr	w1, [sp, #20]
Lloh40:
	adrp	x8, _INTR_TRIGGER_LEVEL@GOTPAGE
Lloh41:
	ldr	x8, [x8, _INTR_TRIGGER_LEVEL@GOTPAGEOFF]
Lloh42:
	ldr	w2, [x8]
	bl	_ioapic_set_triggermode
	ldr	w8, [x21]
	tbz	w8, #31, LBB0_6
LBB0_11:
Lloh43:
	adrp	x8, _ACPI_INTR_APIC@GOTPAGE
Lloh44:
	ldr	x8, [x8, _ACPI_INTR_APIC@GOTPAGEOFF]
Lloh45:
	ldr	w0, [x8]
	bl	_acpi_SetDefaultIntrModel
	ldr	x0, [x22]
	ldr	w1, [x19]
	bl	_free
	str	xzr, [x22]
	ldr	x0, [x20]
	ldr	w1, [x19]
	bl	_free
	str	xzr, [x20]
	mov	w0, #0
	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
	add	sp, sp, #96
	ret
	.loh AdrpAdd	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpAdd	Lloh8, Lloh9
	.loh AdrpAdd	Lloh6, Lloh7
	.loh AdrpAdd	Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh28, Lloh29, Lloh30
	.loh AdrpLdrGotLdr	Lloh25, Lloh26, Lloh27
	.loh AdrpLdrGotLdr	Lloh22, Lloh23, Lloh24
	.loh AdrpLdrGot	Lloh20, Lloh21
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGot	Lloh12, Lloh13
	.loh AdrpLdrGot	Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh31, Lloh32
	.loh AdrpAdd	Lloh33, Lloh34
	.loh AdrpLdrGotLdr	Lloh40, Lloh41, Lloh42
	.loh AdrpLdrGotLdr	Lloh37, Lloh38, Lloh39
	.loh AdrpAdd	Lloh35, Lloh36
	.loh AdrpLdrGotLdr	Lloh43, Lloh44, Lloh45
	.cfi_endproc
                                        ; -- End function
	.comm	_lapics,8,3                     ; @lapics
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"local APICs not initialized"

l_.str.1:                               ; @.str.1
	.asciz	"MADT: ACPI Startup failed with %s\n"

l_.str.3:                               ; @.str.3
	.asciz	"Using MADT but ACPI doesn't work"

	.comm	_IOAPIC_MAX_ID,4,2              ; @IOAPIC_MAX_ID
	.comm	_M_MADT,4,2                     ; @M_MADT
	.comm	_M_WAITOK,4,2                   ; @M_WAITOK
	.comm	_M_ZERO,4,2                     ; @M_ZERO
	.comm	_ioapics,8,3                    ; @ioapics
	.comm	_madt_parse_apics,4,2           ; @madt_parse_apics
	.comm	_madt_parse_ints,4,2            ; @madt_parse_ints
	.comm	_madt_found_sci_override,4,2    ; @madt_found_sci_override
	.comm	_AcpiGbl_FADT,4,2               ; @AcpiGbl_FADT
l_.str.4:                               ; @.str.4
	.asciz	"MADT: Could not find APIC for SCI IRQ %u\n"

	.comm	_INTR_POLARITY_LOW,4,2          ; @INTR_POLARITY_LOW
	.comm	_INTR_TRIGGER_LEVEL,4,2         ; @INTR_TRIGGER_LEVEL
	.comm	_ACPI_INTR_APIC,4,2             ; @ACPI_INTR_APIC
l_str:                                  ; @str
	.asciz	"MADT: Forcing active-low polarity and level trigger for SCI"

l_str.6:                                ; @str.6
	.asciz	"Try disabling either ACPI or apic support."

	.no_dead_strip	_madt_setup_io
.subsections_via_symbols
