	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mg_disk_init
_mg_disk_init:                          ## @mg_disk_init
	.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
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %rbx
	movq	16(%rdi), %rax
	movq	(%rax), %r14
	movl	8(%rdi), %edi
	xorl	%esi, %esi
	callq	_gpio_set_value
	movq	_ATA_BUSY@GOTPCREL(%rip), %r12
	movl	(%r12), %esi
	movq	_MG_TMAX_RST_TO_BUSY@GOTPCREL(%rip), %r13
	movl	(%r13), %edx
	movq	%rbx, %rdi
	callq	_mg_wait
	testl	%eax, %eax
	jne	LBB0_10
## %bb.1:
	movl	8(%rbx), %edi
	movl	$1, %esi
	callq	_gpio_set_value
	movq	_MG_STAT_READY@GOTPCREL(%rip), %r15
	movl	(%r15), %esi
	movq	_MG_TMAX_HDRST_TO_RDY@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%rbx, %rdi
	callq	_mg_wait
	testl	%eax, %eax
	jne	LBB0_10
## %bb.2:
	movq	_ATA_SRST@GOTPCREL(%rip), %rax
	xorl	%edi, %edi
	cmpq	$0, (%r14)
	movq	_ATA_NIEN@GOTPCREL(%rip), %rcx
	je	LBB0_4
## %bb.3:
	movl	(%rcx), %edi
LBB0_4:
	orl	(%rax), %edi
	movq	_MG_REG_DRV_CTRL@GOTPCREL(%rip), %rax
	movq	(%rax), %rsi
	addq	(%rbx), %rsi
	callq	_outb
	movl	(%r12), %esi
	movl	(%r13), %edx
	movq	%rbx, %rdi
	callq	_mg_wait
	testl	%eax, %eax
	jne	LBB0_10
## %bb.5:
	movq	_MG_REG_DRV_CTRL@GOTPCREL(%rip), %rcx
	xorl	%edi, %edi
	cmpq	$0, (%r14)
	je	LBB0_7
## %bb.6:
	movq	_ATA_NIEN@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
LBB0_7:
	movq	(%rcx), %rsi
	addq	(%rbx), %rsi
	callq	_outb
	movl	(%r15), %esi
	movq	_MG_TMAX_SWRST_TO_RDY@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%rbx, %rdi
	callq	_mg_wait
	testl	%eax, %eax
	jne	LBB0_10
## %bb.8:
	movq	_MG_REG_STATUS@GOTPCREL(%rip), %rax
	movq	(%rax), %rdi
	addq	(%rbx), %rdi
	callq	_inb
	movl	%eax, %ecx
	notl	%ecx
	xorl	%eax, %eax
	testb	$15, %cl
	jne	LBB0_10
## %bb.9:
	movq	_MG_ERR_INIT_STAT@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
LBB0_10:
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_ATA_BUSY,4,2                   ## @ATA_BUSY
	.comm	_MG_TMAX_RST_TO_BUSY,4,2        ## @MG_TMAX_RST_TO_BUSY
	.comm	_MG_STAT_READY,4,2              ## @MG_STAT_READY
	.comm	_MG_TMAX_HDRST_TO_RDY,4,2       ## @MG_TMAX_HDRST_TO_RDY
	.comm	_ATA_SRST,4,2                   ## @ATA_SRST
	.comm	_ATA_NIEN,4,2                   ## @ATA_NIEN
	.comm	_MG_REG_DRV_CTRL,8,3            ## @MG_REG_DRV_CTRL
	.comm	_MG_TMAX_SWRST_TO_RDY,4,2       ## @MG_TMAX_SWRST_TO_RDY
	.comm	_MG_REG_STATUS,8,3              ## @MG_REG_STATUS
	.comm	_MG_ERR_INIT_STAT,4,2           ## @MG_ERR_INIT_STAT
	.no_dead_strip	_mg_disk_init
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mg_disk_init
_mg_disk_init:                          ; @mg_disk_init
	.cfi_startproc
; %bb.0:
	stp	x26, x25, [sp, #-80]!           ; 16-byte Folded Spill
	.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
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	mov	x19, x0
	ldr	x8, [x0, #16]
	ldr	x20, [x8]
	ldr	w0, [x0, #8]
	mov	w1, #0
	bl	_gpio_set_value
Lloh0:
	adrp	x22, _ATA_BUSY@GOTPAGE
Lloh1:
	ldr	x22, [x22, _ATA_BUSY@GOTPAGEOFF]
	ldr	w1, [x22]
Lloh2:
	adrp	x23, _MG_TMAX_RST_TO_BUSY@GOTPAGE
Lloh3:
	ldr	x23, [x23, _MG_TMAX_RST_TO_BUSY@GOTPAGEOFF]
	ldr	w2, [x23]
	mov	x0, x19
	bl	_mg_wait
	cbnz	w0, LBB0_5
; %bb.1:
	ldr	w0, [x19, #8]
	mov	w1, #1
	bl	_gpio_set_value
Lloh4:
	adrp	x21, _MG_STAT_READY@GOTPAGE
Lloh5:
	ldr	x21, [x21, _MG_STAT_READY@GOTPAGEOFF]
	ldr	w1, [x21]
Lloh6:
	adrp	x8, _MG_TMAX_HDRST_TO_RDY@GOTPAGE
Lloh7:
	ldr	x8, [x8, _MG_TMAX_HDRST_TO_RDY@GOTPAGEOFF]
Lloh8:
	ldr	w2, [x8]
	mov	x0, x19
	bl	_mg_wait
	cbnz	w0, LBB0_5
; %bb.2:
Lloh9:
	adrp	x8, _ATA_SRST@GOTPAGE
Lloh10:
	ldr	x8, [x8, _ATA_SRST@GOTPAGEOFF]
Lloh11:
	ldr	w8, [x8]
	ldr	x9, [x20]
Lloh12:
	adrp	x24, _ATA_NIEN@GOTPAGE
Lloh13:
	ldr	x24, [x24, _ATA_NIEN@GOTPAGEOFF]
	ldr	w10, [x24]
	cmp	x9, #0
	csel	w9, wzr, w10, eq
	orr	w0, w9, w8
	ldr	x8, [x19]
Lloh14:
	adrp	x25, _MG_REG_DRV_CTRL@GOTPAGE
Lloh15:
	ldr	x25, [x25, _MG_REG_DRV_CTRL@GOTPAGEOFF]
	ldr	x9, [x25]
	add	x1, x9, x8
	bl	_outb
	ldr	w1, [x22]
	ldr	w2, [x23]
	mov	x0, x19
	bl	_mg_wait
	cbnz	w0, LBB0_5
; %bb.3:
	ldr	x8, [x20]
	ldr	w9, [x24]
	cmp	x8, #0
	csel	w0, wzr, w9, eq
	ldr	x8, [x19]
	ldr	x9, [x25]
	add	x1, x9, x8
	bl	_outb
	ldr	w1, [x21]
Lloh16:
	adrp	x8, _MG_TMAX_SWRST_TO_RDY@GOTPAGE
Lloh17:
	ldr	x8, [x8, _MG_TMAX_SWRST_TO_RDY@GOTPAGEOFF]
Lloh18:
	ldr	w2, [x8]
	mov	x0, x19
	bl	_mg_wait
	cbnz	w0, LBB0_5
; %bb.4:
	ldr	x8, [x19]
Lloh19:
	adrp	x9, _MG_REG_STATUS@GOTPAGE
Lloh20:
	ldr	x9, [x9, _MG_REG_STATUS@GOTPAGEOFF]
Lloh21:
	ldr	x9, [x9]
	add	x0, x9, x8
	bl	_inb
Lloh22:
	adrp	x8, _MG_ERR_INIT_STAT@GOTPAGE
Lloh23:
	ldr	x8, [x8, _MG_ERR_INIT_STAT@GOTPAGEOFF]
Lloh24:
	ldr	w8, [x8]
	mov	w9, #15
	bics	wzr, w9, w0
	csel	w0, w8, wzr, eq
LBB0_5:
	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
	ldp	x26, x25, [sp], #80             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh14, Lloh15
	.loh AdrpLdrGot	Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh22, Lloh23, Lloh24
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.cfi_endproc
                                        ; -- End function
	.comm	_ATA_BUSY,4,2                   ; @ATA_BUSY
	.comm	_MG_TMAX_RST_TO_BUSY,4,2        ; @MG_TMAX_RST_TO_BUSY
	.comm	_MG_STAT_READY,4,2              ; @MG_STAT_READY
	.comm	_MG_TMAX_HDRST_TO_RDY,4,2       ; @MG_TMAX_HDRST_TO_RDY
	.comm	_ATA_SRST,4,2                   ; @ATA_SRST
	.comm	_ATA_NIEN,4,2                   ; @ATA_NIEN
	.comm	_MG_REG_DRV_CTRL,8,3            ; @MG_REG_DRV_CTRL
	.comm	_MG_TMAX_SWRST_TO_RDY,4,2       ; @MG_TMAX_SWRST_TO_RDY
	.comm	_MG_REG_STATUS,8,3              ; @MG_REG_STATUS
	.comm	_MG_ERR_INIT_STAT,4,2           ; @MG_ERR_INIT_STAT
	.no_dead_strip	_mg_disk_init
.subsections_via_symbols
