	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mg_write
_mg_write:                              ## @mg_write
	.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, %r14
	movq	8(%rdi), %rax
	movq	(%rax), %r15
	callq	_blk_rq_sectors
	movl	%eax, %ebx
	movq	%r14, %rdi
	callq	_blk_rq_pos
	movq	_MG_CMD_WR@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	movq	%r15, %rdi
	movl	%eax, %esi
	movl	%ebx, %edx
	xorl	%r8d, %r8d
	callq	_mg_out
	movq	_MG_ERR_NONE@GOTPCREL(%rip), %r12
	cmpq	(%r12), %rax
	jne	LBB0_8
## %bb.1:
	movq	%r14, %rdi
	callq	_blk_rq_pos
	movl	(%r14), %ecx
	leaq	L_.str(%rip), %rdi
	movl	%ebx, %esi
	movl	%eax, %edx
	callq	_MG_DBG
	movq	_ATA_DRQ@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_MG_TMAX_WAIT_WR_DRQ@GOTPCREL(%rip), %r13
	movl	(%r13), %edx
	movq	%r15, %rdi
	callq	_mg_wait
	cmpq	(%r12), %rax
	jne	LBB0_8
## %bb.2:
	decl	%ebx
	.p2align	4, 0x90
LBB0_3:                                 ## =>This Inner Loop Header: Depth=1
	movq	%r15, %rdi
	movq	%r14, %rsi
	callq	_mg_write_one
	movq	_MG_CMD_WR_CONF@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	_MG_REG_COMMAND@GOTPCREL(%rip), %rax
	movq	(%rax), %rsi
	addq	(%r15), %rsi
	callq	_outb
	cmpl	$2, %ebx
	jb	LBB0_5
## %bb.4:                               ##   in Loop: Header=BB0_3 Depth=1
	movq	_ATA_DRQ@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	(%r13), %edx
	movq	%r15, %rdi
	callq	_mg_wait
	cmpq	(%r12), %rax
	jne	LBB0_8
LBB0_5:                                 ##   in Loop: Header=BB0_3 Depth=1
	movq	_MG_STAT_READY@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	(%r13), %edx
	movq	%r15, %rdi
	callq	_mg_wait
	cmpq	(%r12), %rax
	jne	LBB0_8
## %bb.6:                               ##   in Loop: Header=BB0_3 Depth=1
	movq	_MG_SECTOR_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	_mg_end_request
	decl	%ebx
	testq	%rax, %rax
	jne	LBB0_3
## %bb.7:
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_8:
	movq	%r15, %rdi
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_mg_bad_rw_intr                 ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.comm	_MG_CMD_WR,4,2                  ## @MG_CMD_WR
	.comm	_MG_ERR_NONE,8,3                ## @MG_ERR_NONE
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"requested %d sects (from %ld), buffer=0x%p\n"

	.comm	_ATA_DRQ,4,2                    ## @ATA_DRQ
	.comm	_MG_TMAX_WAIT_WR_DRQ,4,2        ## @MG_TMAX_WAIT_WR_DRQ
	.comm	_MG_CMD_WR_CONF,4,2             ## @MG_CMD_WR_CONF
	.comm	_MG_REG_COMMAND,8,3             ## @MG_REG_COMMAND
	.comm	_MG_STAT_READY,4,2              ## @MG_STAT_READY
	.comm	_MG_SECTOR_SIZE,4,2             ## @MG_SECTOR_SIZE
	.no_dead_strip	_mg_write
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mg_write
_mg_write:                              ; @mg_write
	.cfi_startproc
; %bb.0:
	stp	x28, x27, [sp, #-96]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 96
	stp	x26, x25, [sp, #16]             ; 16-byte Folded Spill
	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
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	.cfi_offset w27, -88
	.cfi_offset w28, -96
	mov	x20, x0
	ldr	x8, [x0, #8]
	ldr	x19, [x8]
	bl	_blk_rq_sectors
	mov	x21, x0
	mov	x0, x20
	bl	_blk_rq_pos
	mov	x1, x0
Lloh0:
	adrp	x8, _MG_CMD_WR@GOTPAGE
Lloh1:
	ldr	x8, [x8, _MG_CMD_WR@GOTPAGEOFF]
Lloh2:
	ldr	w3, [x8]
	mov	x0, x19
	mov	x2, x21
	mov	x4, #0
	bl	_mg_out
Lloh3:
	adrp	x22, _MG_ERR_NONE@GOTPAGE
Lloh4:
	ldr	x22, [x22, _MG_ERR_NONE@GOTPAGEOFF]
	ldr	x8, [x22]
	cmp	x0, x8
	b.ne	LBB0_8
; %bb.1:
	mov	x0, x20
	bl	_blk_rq_pos
	mov	x2, x0
	ldr	w3, [x20]
Lloh5:
	adrp	x0, l_.str@PAGE
Lloh6:
	add	x0, x0, l_.str@PAGEOFF
	mov	x1, x21
	bl	_MG_DBG
Lloh7:
	adrp	x23, _ATA_DRQ@GOTPAGE
Lloh8:
	ldr	x23, [x23, _ATA_DRQ@GOTPAGEOFF]
	ldr	w1, [x23]
Lloh9:
	adrp	x24, _MG_TMAX_WAIT_WR_DRQ@GOTPAGE
Lloh10:
	ldr	x24, [x24, _MG_TMAX_WAIT_WR_DRQ@GOTPAGEOFF]
	ldr	w2, [x24]
	mov	x0, x19
	bl	_mg_wait
	ldr	x8, [x22]
	cmp	x0, x8
	b.ne	LBB0_8
; %bb.2:
	sub	w21, w21, #1
Lloh11:
	adrp	x25, _MG_CMD_WR_CONF@GOTPAGE
Lloh12:
	ldr	x25, [x25, _MG_CMD_WR_CONF@GOTPAGEOFF]
Lloh13:
	adrp	x26, _MG_REG_COMMAND@GOTPAGE
Lloh14:
	ldr	x26, [x26, _MG_REG_COMMAND@GOTPAGEOFF]
Lloh15:
	adrp	x27, _MG_STAT_READY@GOTPAGE
Lloh16:
	ldr	x27, [x27, _MG_STAT_READY@GOTPAGEOFF]
Lloh17:
	adrp	x28, _MG_SECTOR_SIZE@GOTPAGE
Lloh18:
	ldr	x28, [x28, _MG_SECTOR_SIZE@GOTPAGEOFF]
LBB0_3:                                 ; =>This Inner Loop Header: Depth=1
	mov	x0, x19
	mov	x1, x20
	bl	_mg_write_one
	ldr	w0, [x25]
	ldr	x8, [x19]
	ldr	x9, [x26]
	add	x1, x9, x8
	bl	_outb
	cmp	w21, #2
	b.lo	LBB0_5
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=1
	ldr	w1, [x23]
	ldr	w2, [x24]
	mov	x0, x19
	bl	_mg_wait
	ldr	x8, [x22]
	cmp	x0, x8
	b.ne	LBB0_8
LBB0_5:                                 ;   in Loop: Header=BB0_3 Depth=1
	ldr	w1, [x27]
	ldr	w2, [x24]
	mov	x0, x19
	bl	_mg_wait
	ldr	x8, [x22]
	cmp	x0, x8
	b.ne	LBB0_8
; %bb.6:                                ;   in Loop: Header=BB0_3 Depth=1
	ldr	w2, [x28]
	mov	x0, x19
	mov	w1, #0
	bl	_mg_end_request
	sub	w21, w21, #1
	cbnz	x0, LBB0_3
; %bb.7:
	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
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp], #96             ; 16-byte Folded Reload
	ret
LBB0_8:
	mov	x0, x19
	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
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp], #96             ; 16-byte Folded Reload
	b	_mg_bad_rw_intr
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh9, Lloh10
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpAdd	Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh17, Lloh18
	.loh AdrpLdrGot	Lloh15, Lloh16
	.loh AdrpLdrGot	Lloh13, Lloh14
	.loh AdrpLdrGot	Lloh11, Lloh12
	.cfi_endproc
                                        ; -- End function
	.comm	_MG_CMD_WR,4,2                  ; @MG_CMD_WR
	.comm	_MG_ERR_NONE,8,3                ; @MG_ERR_NONE
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"requested %d sects (from %ld), buffer=0x%p\n"

	.comm	_ATA_DRQ,4,2                    ; @ATA_DRQ
	.comm	_MG_TMAX_WAIT_WR_DRQ,4,2        ; @MG_TMAX_WAIT_WR_DRQ
	.comm	_MG_CMD_WR_CONF,4,2             ; @MG_CMD_WR_CONF
	.comm	_MG_REG_COMMAND,8,3             ; @MG_REG_COMMAND
	.comm	_MG_STAT_READY,4,2              ; @MG_STAT_READY
	.comm	_MG_SECTOR_SIZE,4,2             ; @MG_SECTOR_SIZE
	.no_dead_strip	_mg_write
.subsections_via_symbols
