	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function ata_kauai_attach
_ata_kauai_attach:                      ## @ata_kauai_attach
	.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	%rbx
	pushq	%rax
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%edi, %r14d
	callq	_device_get_softc
	movq	%rax, %r15
	movq	_PCIR_BARS@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, -28(%rbp)
	movq	_SYS_RES_MEMORY@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_RF_ACTIVE@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	leaq	-28(%rbp), %rdx
	movl	%r14d, %edi
	callq	_bus_alloc_resource_any
	movq	%rax, 56(%r15)
	testq	%rax, %rax
	je	LBB0_1
## %bb.2:
	movq	_ATA_DATA@GOTPCREL(%rip), %rcx
	movslq	(%rcx), %rdi
	movq	_ATA_COMMAND@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edx
	movq	32(%r15), %r8
	cmpl	%edi, %edx
	jl	LBB0_8
## %bb.3:
	movq	_ATA_KAUAI_REGGAP@GOTPCREL(%rip), %rcx
	movslq	(%rcx), %r10
	movl	%edx, %ebx
	subl	%edi, %ebx
	incl	%ebx
	movq	%rdi, %rsi
	testb	$1, %bl
	je	LBB0_5
## %bb.4:
	movq	%rdi, %r9
	shlq	$4, %r9
	movq	%rax, 8(%r8,%r9)
	movq	%rdi, %rbx
	imulq	%r10, %rbx
	movq	_ATA_KAUAI_REGOFFSET@GOTPCREL(%rip), %rcx
	addq	(%rcx), %rbx
	movq	%rbx, (%r8,%r9)
	leaq	1(%rdi), %rsi
LBB0_5:
	cmpl	%edi, %edx
	je	LBB0_8
## %bb.6:
	subl	%esi, %edx
	incl	%edx
	movq	%rsi, %rdi
	imulq	%r10, %rdi
	incq	%rsi
	movq	%rsi, %rcx
	shlq	$4, %rcx
	leaq	(%r8,%rcx), %rbx
	addq	$8, %rbx
	imulq	%r10, %rsi
	addq	%r10, %r10
	movq	_ATA_KAUAI_REGOFFSET@GOTPCREL(%rip), %r9
	.p2align	4, 0x90
LBB0_7:                                 ## =>This Inner Loop Header: Depth=1
	movq	%rax, -16(%rbx)
	movq	(%r9), %rcx
	addq	%rdi, %rcx
	movq	%rcx, -24(%rbx)
	movq	%rax, (%rbx)
	movq	(%r9), %rcx
	addq	%rsi, %rcx
	movq	%rcx, -8(%rbx)
	addq	%r10, %rdi
	addq	$32, %rbx
	addq	%r10, %rsi
	addl	$-2, %edx
	jne	LBB0_7
LBB0_8:
	movq	_ATA_CONTROL@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	shlq	$4, %rcx
	movq	%rax, 8(%r8,%rcx)
	movq	_ATA_KAUAI_ALTOFFSET@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rax, (%r8,%rcx)
	movl	%r14d, %edi
	callq	_ata_default_registers
	movq	$0, 24(%r15)
	movq	_ATA_USE_16BIT@GOTPCREL(%rip), %rax
	movl	20(%r15), %ecx
	orl	(%rax), %ecx
	movq	_ATA_NO_ATAPI_DMA@GOTPCREL(%rip), %rax
	orl	(%rax), %ecx
	movl	%ecx, 20(%r15)
	movl	%r14d, %edi
	callq	_ata_generic_hw
	movl	%r14d, %edi
	callq	_pci_enable_busmaster
	movl	$1, 8(%r15)
	movq	56(%r15), %rax
	movq	%rax, 48(%r15)
	movq	_ATA_KAUAI_DBDMAOFFSET@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 40(%r15)
	movl	%r14d, %edi
	callq	_ata_dbdma_dmainit
	movq	56(%r15), %rdi
	movq	_PIO_CONFIG_REG@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_bus_read_4
	andl	$251662335, %eax                ## imm = 0xF000FFF
	movq	(%r15), %rcx
	movl	%eax, 4(%rcx)
	movl	%eax, (%rcx)
	movq	72(%r15), %rax
	xorps	%xmm0, %xmm0
	movups	%xmm0, (%rax)
	movq	64(%r15), %rax
	movups	%xmm0, (%rax)
	movq	56(%r15), %rdi
	xorl	%esi, %esi
	movl	$7, %edx
	callq	_bus_write_4
	movq	_ata_kauai_begin_transaction@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 16(%r15)
	movl	%r14d, %edi
	callq	_ata_attach
	jmp	LBB0_9
LBB0_1:
	leaq	L_.str(%rip), %rsi
	movl	%r14d, %edi
	callq	_device_printf
	movq	_ENXIO@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
LBB0_9:
	addq	$8, %rsp
	popq	%rbx
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_PCIR_BARS,4,2                  ## @PCIR_BARS
	.comm	_SYS_RES_MEMORY,4,2             ## @SYS_RES_MEMORY
	.comm	_RF_ACTIVE,4,2                  ## @RF_ACTIVE
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"could not allocate memory\n"

	.comm	_ENXIO,4,2                      ## @ENXIO
	.comm	_ATA_DATA,4,2                   ## @ATA_DATA
	.comm	_ATA_COMMAND,4,2                ## @ATA_COMMAND
	.comm	_ATA_KAUAI_REGGAP,4,2           ## @ATA_KAUAI_REGGAP
	.comm	_ATA_KAUAI_REGOFFSET,8,3        ## @ATA_KAUAI_REGOFFSET
	.comm	_ATA_CONTROL,8,3                ## @ATA_CONTROL
	.comm	_ATA_KAUAI_ALTOFFSET,8,3        ## @ATA_KAUAI_ALTOFFSET
	.comm	_ATA_USE_16BIT,4,2              ## @ATA_USE_16BIT
	.comm	_ATA_NO_ATAPI_DMA,4,2           ## @ATA_NO_ATAPI_DMA
	.comm	_ATA_KAUAI_DBDMAOFFSET,4,2      ## @ATA_KAUAI_DBDMAOFFSET
	.comm	_PIO_CONFIG_REG,4,2             ## @PIO_CONFIG_REG
	.comm	_ata_kauai_begin_transaction,4,2 ## @ata_kauai_begin_transaction
	.comm	_ATA_INTR_FLAGS,4,2             ## @ATA_INTR_FLAGS
	.comm	_RF_SHAREABLE,4,2               ## @RF_SHAREABLE
	.comm	_SYS_RES_IRQ,4,2                ## @SYS_RES_IRQ
	.comm	_ata_kauai_dma_interrupt,8,3    ## @ata_kauai_dma_interrupt
	.no_dead_strip	_ata_kauai_attach
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function ata_kauai_attach
_ata_kauai_attach:                      ; @ata_kauai_attach
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #48
	.cfi_def_cfa_offset 48
	stp	x20, x19, [sp, #16]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #32]             ; 16-byte Folded Spill
	add	x29, sp, #32
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	mov	x19, x0
	bl	_device_get_softc
	mov	x20, x0
Lloh0:
	adrp	x8, _PCIR_BARS@GOTPAGE
Lloh1:
	ldr	x8, [x8, _PCIR_BARS@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	str	w8, [sp, #12]
Lloh3:
	adrp	x8, _SYS_RES_MEMORY@GOTPAGE
Lloh4:
	ldr	x8, [x8, _SYS_RES_MEMORY@GOTPAGEOFF]
Lloh5:
	ldr	w1, [x8]
Lloh6:
	adrp	x8, _RF_ACTIVE@GOTPAGE
Lloh7:
	ldr	x8, [x8, _RF_ACTIVE@GOTPAGEOFF]
Lloh8:
	ldr	w3, [x8]
	add	x2, sp, #12
	mov	x0, x19
	bl	_bus_alloc_resource_any
	str	x0, [x20, #56]
	cbz	x0, LBB0_5
; %bb.1:
Lloh9:
	adrp	x8, _ATA_DATA@GOTPAGE
Lloh10:
	ldr	x8, [x8, _ATA_DATA@GOTPAGEOFF]
Lloh11:
	ldrsw	x12, [x8]
Lloh12:
	adrp	x8, _ATA_COMMAND@GOTPAGE
Lloh13:
	ldr	x8, [x8, _ATA_COMMAND@GOTPAGEOFF]
Lloh14:
	ldr	w13, [x8]
	ldr	x8, [x20, #32]
	cmp	w12, w13
	b.gt	LBB0_4
; %bb.2:
Lloh15:
	adrp	x9, _ATA_KAUAI_REGGAP@GOTPAGE
Lloh16:
	ldr	x9, [x9, _ATA_KAUAI_REGGAP@GOTPAGEOFF]
Lloh17:
	ldrsw	x9, [x9]
	mul	x10, x12, x9
	add	x11, x8, x12, lsl #4
	add	x11, x11, #8
	sub	w12, w13, w12
	add	w12, w12, #1
Lloh18:
	adrp	x13, _ATA_KAUAI_REGOFFSET@GOTPAGE
Lloh19:
	ldr	x13, [x13, _ATA_KAUAI_REGOFFSET@GOTPAGEOFF]
LBB0_3:                                 ; =>This Inner Loop Header: Depth=1
	str	x0, [x11]
	ldr	x14, [x13]
	add	x14, x10, x14
	stur	x14, [x11, #-8]
	add	x10, x10, x9
	add	x11, x11, #16
	subs	w12, w12, #1
	b.ne	LBB0_3
LBB0_4:
Lloh20:
	adrp	x9, _ATA_CONTROL@GOTPAGE
Lloh21:
	ldr	x9, [x9, _ATA_CONTROL@GOTPAGEOFF]
Lloh22:
	ldr	x9, [x9]
	add	x8, x8, x9, lsl #4
Lloh23:
	adrp	x9, _ATA_KAUAI_ALTOFFSET@GOTPAGE
Lloh24:
	ldr	x9, [x9, _ATA_KAUAI_ALTOFFSET@GOTPAGEOFF]
Lloh25:
	ldr	x9, [x9]
	stp	x9, x0, [x8]
	mov	x0, x19
	bl	_ata_default_registers
	str	xzr, [x20, #24]
Lloh26:
	adrp	x8, _ATA_USE_16BIT@GOTPAGE
Lloh27:
	ldr	x8, [x8, _ATA_USE_16BIT@GOTPAGEOFF]
Lloh28:
	ldr	w8, [x8]
	ldr	w9, [x20, #20]
	orr	w8, w9, w8
Lloh29:
	adrp	x9, _ATA_NO_ATAPI_DMA@GOTPAGE
Lloh30:
	ldr	x9, [x9, _ATA_NO_ATAPI_DMA@GOTPAGEOFF]
Lloh31:
	ldr	w9, [x9]
	orr	w8, w9, w8
	str	w8, [x20, #20]
	mov	x0, x19
	bl	_ata_generic_hw
	mov	x0, x19
	bl	_pci_enable_busmaster
	mov	w8, #1
	str	w8, [x20, #8]
	ldr	x8, [x20, #56]
	str	x8, [x20, #48]
Lloh32:
	adrp	x8, _ATA_KAUAI_DBDMAOFFSET@GOTPAGE
Lloh33:
	ldr	x8, [x8, _ATA_KAUAI_DBDMAOFFSET@GOTPAGEOFF]
Lloh34:
	ldr	w8, [x8]
	str	w8, [x20, #40]
	mov	x0, x19
	bl	_ata_dbdma_dmainit
	ldr	x0, [x20, #56]
Lloh35:
	adrp	x8, _PIO_CONFIG_REG@GOTPAGE
Lloh36:
	ldr	x8, [x8, _PIO_CONFIG_REG@GOTPAGEOFF]
Lloh37:
	ldr	w1, [x8]
	bl	_bus_read_4
	and	w8, w0, #0xfffffff
	and	w8, w8, #0xff000fff
	ldr	x9, [x20]
	stp	w8, w8, [x9]
	ldr	x8, [x20, #72]
	stp	xzr, xzr, [x8]
	ldr	x8, [x20, #64]
	stp	xzr, xzr, [x8]
	ldr	x0, [x20, #56]
	mov	w1, #0
	mov	w2, #7
	bl	_bus_write_4
Lloh38:
	adrp	x8, _ata_kauai_begin_transaction@GOTPAGE
Lloh39:
	ldr	x8, [x8, _ata_kauai_begin_transaction@GOTPAGEOFF]
Lloh40:
	ldr	w8, [x8]
	str	w8, [x20, #16]
	mov	x0, x19
	bl	_ata_attach
	b	LBB0_6
LBB0_5:
Lloh41:
	adrp	x1, l_.str@PAGE
Lloh42:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x19
	bl	_device_printf
Lloh43:
	adrp	x8, _ENXIO@GOTPAGE
Lloh44:
	ldr	x8, [x8, _ENXIO@GOTPAGEOFF]
Lloh45:
	ldr	w0, [x8]
LBB0_6:
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #48
	ret
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpLdrGotLdr	Lloh38, Lloh39, Lloh40
	.loh AdrpLdrGotLdr	Lloh35, Lloh36, Lloh37
	.loh AdrpLdrGotLdr	Lloh32, Lloh33, Lloh34
	.loh AdrpLdrGotLdr	Lloh29, Lloh30, Lloh31
	.loh AdrpLdrGotLdr	Lloh26, Lloh27, Lloh28
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh25
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh43, Lloh44, Lloh45
	.loh AdrpAdd	Lloh41, Lloh42
	.cfi_endproc
                                        ; -- End function
	.comm	_PCIR_BARS,4,2                  ; @PCIR_BARS
	.comm	_SYS_RES_MEMORY,4,2             ; @SYS_RES_MEMORY
	.comm	_RF_ACTIVE,4,2                  ; @RF_ACTIVE
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"could not allocate memory\n"

	.comm	_ENXIO,4,2                      ; @ENXIO
	.comm	_ATA_DATA,4,2                   ; @ATA_DATA
	.comm	_ATA_COMMAND,4,2                ; @ATA_COMMAND
	.comm	_ATA_KAUAI_REGGAP,4,2           ; @ATA_KAUAI_REGGAP
	.comm	_ATA_KAUAI_REGOFFSET,8,3        ; @ATA_KAUAI_REGOFFSET
	.comm	_ATA_CONTROL,8,3                ; @ATA_CONTROL
	.comm	_ATA_KAUAI_ALTOFFSET,8,3        ; @ATA_KAUAI_ALTOFFSET
	.comm	_ATA_USE_16BIT,4,2              ; @ATA_USE_16BIT
	.comm	_ATA_NO_ATAPI_DMA,4,2           ; @ATA_NO_ATAPI_DMA
	.comm	_ATA_KAUAI_DBDMAOFFSET,4,2      ; @ATA_KAUAI_DBDMAOFFSET
	.comm	_PIO_CONFIG_REG,4,2             ; @PIO_CONFIG_REG
	.comm	_ata_kauai_begin_transaction,4,2 ; @ata_kauai_begin_transaction
	.comm	_ATA_INTR_FLAGS,4,2             ; @ATA_INTR_FLAGS
	.comm	_RF_SHAREABLE,4,2               ; @RF_SHAREABLE
	.comm	_SYS_RES_IRQ,4,2                ; @SYS_RES_IRQ
	.comm	_ata_kauai_dma_interrupt,8,3    ; @ata_kauai_dma_interrupt
	.no_dead_strip	_ata_kauai_attach
.subsections_via_symbols
