	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_mga_do_dma_flush               ## -- Begin function mga_do_dma_flush
	.p2align	4, 0x90
_mga_do_dma_flush:                      ## @mga_do_dma_flush
	.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, %r15
	leaq	L_.str(%rip), %rdi
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_DRM_DEBUG
	cmpl	$0, (%r15)
	jle	LBB0_4
## %bb.1:
	movq	_MGA_STATUS@GOTPCREL(%rip), %r14
	movq	_MGA_ENGINE_IDLE_MASK@GOTPCREL(%rip), %r12
	movq	_MGA_ENDPRDMASTS@GOTPCREL(%rip), %r13
	.p2align	4, 0x90
LBB0_2:                                 ## =>This Inner Loop Header: Depth=1
	movl	(%r14), %edi
	callq	_MGA_READ
	andl	(%r12), %eax
	cmpl	(%r13), %eax
	je	LBB0_4
## %bb.3:                               ##   in Loop: Header=BB0_2 Depth=1
	movl	$1, %edi
	callq	_DRM_UDELAY
	incl	%ebx
	cmpl	(%r15), %ebx
	jl	LBB0_2
LBB0_4:
	movq	16(%r15), %r14
	cmpq	24(%r15), %r14
	jne	LBB0_6
## %bb.5:
	leaq	L_.str.1(%rip), %rdi
	jmp	LBB0_9
LBB0_6:
	movq	8(%r15), %rax
	addl	(%rax), %r14d
	movl	$1, %edi
	callq	_BEGIN_DMA
	movq	_MGA_DMAPAD@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	xorl	%esi, %esi
	movl	%edi, %edx
	xorl	%ecx, %ecx
	movl	%edi, %r8d
	xorl	%r9d, %r9d
	pushq	$0
	pushq	%rdi
	callq	_DMA_BLOCK
	addq	$16, %rsp
	xorl	%eax, %eax
	callq	_ADVANCE_DMA
	movq	16(%r15), %rax
	movq	%rax, 24(%r15)
	movq	_MGA_PRIMADDRESS@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_MGA_READ
	movl	%eax, %ecx
	subl	%r14d, %ecx
	jg	LBB0_8
## %bb.7:
	movl	36(%r15), %ecx
	subl	16(%r15), %ecx
LBB0_8:
	movl	%ecx, 32(%r15)
	movq	8(%r15), %rcx
	movslq	(%rcx), %rcx
	movslq	%eax, %rsi
	subq	%rcx, %rsi
	leaq	L_.str.2(%rip), %rdi
	xorl	%eax, %eax
	callq	_DRM_DEBUG
	movq	8(%r15), %rax
	movslq	(%rax), %rax
	movslq	%r14d, %rsi
	subq	%rax, %rsi
	leaq	L_.str.3(%rip), %rdi
	xorl	%eax, %eax
	callq	_DRM_DEBUG
	movl	32(%r15), %esi
	leaq	L_.str.4(%rip), %rdi
	xorl	%eax, %eax
	callq	_DRM_DEBUG
	xorl	%eax, %eax
	callq	_mga_flush_write_combine
	movq	_MGA_PRIMEND@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	orl	4(%r15), %r14d
	movl	%r14d, %esi
	callq	_MGA_WRITE
	leaq	L_.str.5(%rip), %rdi
LBB0_9:
	xorl	%eax, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_DRM_DEBUG                      ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.comm	_DMA_LOCALS,4,2                 ## @DMA_LOCALS
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"\n"

	.comm	_MGA_STATUS,4,2                 ## @MGA_STATUS
	.comm	_MGA_ENGINE_IDLE_MASK,4,2       ## @MGA_ENGINE_IDLE_MASK
	.comm	_MGA_ENDPRDMASTS,4,2            ## @MGA_ENDPRDMASTS
L_.str.1:                               ## @.str.1
	.asciz	"   bailing out...\n"

	.comm	_MGA_DMAPAD,4,2                 ## @MGA_DMAPAD
	.comm	_MGA_PRIMADDRESS,4,2            ## @MGA_PRIMADDRESS
L_.str.2:                               ## @.str.2
	.asciz	"   head = 0x%06lx\n"

L_.str.3:                               ## @.str.3
	.asciz	"   tail = 0x%06lx\n"

L_.str.4:                               ## @.str.4
	.asciz	"  space = 0x%06x\n"

	.comm	_MGA_PRIMEND,4,2                ## @MGA_PRIMEND
L_.str.5:                               ## @.str.5
	.asciz	"done.\n"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_mga_do_dma_flush               ; -- Begin function mga_do_dma_flush
	.p2align	2
_mga_do_dma_flush:                      ; @mga_do_dma_flush
	.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
Lloh0:
	adrp	x0, l_.str@PAGE
Lloh1:
	add	x0, x0, l_.str@PAGEOFF
	bl	_DRM_DEBUG
	ldr	w8, [x19]
	cmp	w8, #1
	b.lt	LBB0_4
; %bb.1:
	mov	w20, #0
Lloh2:
	adrp	x21, _MGA_STATUS@GOTPAGE
Lloh3:
	ldr	x21, [x21, _MGA_STATUS@GOTPAGEOFF]
Lloh4:
	adrp	x22, _MGA_ENGINE_IDLE_MASK@GOTPAGE
Lloh5:
	ldr	x22, [x22, _MGA_ENGINE_IDLE_MASK@GOTPAGEOFF]
Lloh6:
	adrp	x23, _MGA_ENDPRDMASTS@GOTPAGE
Lloh7:
	ldr	x23, [x23, _MGA_ENDPRDMASTS@GOTPAGEOFF]
LBB0_2:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w0, [x21]
	bl	_MGA_READ
	ldr	w8, [x22]
	and	w8, w8, w0
	ldr	w9, [x23]
	cmp	w8, w9
	b.eq	LBB0_4
; %bb.3:                                ;   in Loop: Header=BB0_2 Depth=1
	mov	w0, #1
	bl	_DRM_UDELAY
	add	w20, w20, #1
	ldr	w8, [x19]
	cmp	w20, w8
	b.lt	LBB0_2
LBB0_4:
	ldp	x8, x9, [x19, #16]
	cmp	x8, x9
	b.ne	LBB0_6
; %bb.5:
Lloh8:
	adrp	x0, l_.str.1@PAGE
Lloh9:
	add	x0, x0, l_.str.1@PAGEOFF
	b	LBB0_9
LBB0_6:
	ldr	x9, [x19, #8]
	ldr	w9, [x9]
	add	w20, w9, w8
	mov	w0, #1
	bl	_BEGIN_DMA
Lloh10:
	adrp	x8, _MGA_DMAPAD@GOTPAGE
Lloh11:
	ldr	x8, [x8, _MGA_DMAPAD@GOTPAGEOFF]
Lloh12:
	ldr	w0, [x8]
	mov	w1, #0
	mov	x2, x0
	mov	w3, #0
	mov	x4, x0
	mov	w5, #0
	mov	x6, x0
	mov	w7, #0
	bl	_DMA_BLOCK
	bl	_ADVANCE_DMA
	ldr	x8, [x19, #16]
	str	x8, [x19, #24]
Lloh13:
	adrp	x8, _MGA_PRIMADDRESS@GOTPAGE
Lloh14:
	ldr	x8, [x8, _MGA_PRIMADDRESS@GOTPAGEOFF]
Lloh15:
	ldr	w0, [x8]
	bl	_MGA_READ
                                        ; kill: def $w0 killed $w0 def $x0
	subs	w8, w0, w20
	b.gt	LBB0_8
; %bb.7:
	ldr	w8, [x19, #36]
	ldr	w9, [x19, #16]
	sub	w8, w8, w9
LBB0_8:
	str	w8, [x19, #32]
	ldr	x8, [x19, #8]
	ldrsw	x8, [x8]
	sxtw	x9, w0
	sub	x8, x9, x8
	str	x8, [sp]
Lloh16:
	adrp	x0, l_.str.2@PAGE
Lloh17:
	add	x0, x0, l_.str.2@PAGEOFF
	bl	_DRM_DEBUG
	ldr	x8, [x19, #8]
	ldrsw	x8, [x8]
	sxtw	x9, w20
	sub	x8, x9, x8
	str	x8, [sp]
Lloh18:
	adrp	x0, l_.str.3@PAGE
Lloh19:
	add	x0, x0, l_.str.3@PAGEOFF
	bl	_DRM_DEBUG
	ldr	w8, [x19, #32]
	str	x8, [sp]
Lloh20:
	adrp	x0, l_.str.4@PAGE
Lloh21:
	add	x0, x0, l_.str.4@PAGEOFF
	bl	_DRM_DEBUG
	bl	_mga_flush_write_combine
Lloh22:
	adrp	x8, _MGA_PRIMEND@GOTPAGE
Lloh23:
	ldr	x8, [x8, _MGA_PRIMEND@GOTPAGEOFF]
Lloh24:
	ldr	w0, [x8]
	ldr	w8, [x19, #4]
	orr	w1, w8, w20
	bl	_MGA_WRITE
Lloh25:
	adrp	x0, l_.str.5@PAGE
Lloh26:
	add	x0, x0, l_.str.5@PAGEOFF
LBB0_9:
	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
	b	_DRM_DEBUG
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpAdd	Lloh8, Lloh9
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpAdd	Lloh25, Lloh26
	.loh AdrpLdrGotLdr	Lloh22, Lloh23, Lloh24
	.loh AdrpAdd	Lloh20, Lloh21
	.loh AdrpAdd	Lloh18, Lloh19
	.loh AdrpAdd	Lloh16, Lloh17
	.cfi_endproc
                                        ; -- End function
	.comm	_DMA_LOCALS,4,2                 ; @DMA_LOCALS
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"\n"

	.comm	_MGA_STATUS,4,2                 ; @MGA_STATUS
	.comm	_MGA_ENGINE_IDLE_MASK,4,2       ; @MGA_ENGINE_IDLE_MASK
	.comm	_MGA_ENDPRDMASTS,4,2            ; @MGA_ENDPRDMASTS
l_.str.1:                               ; @.str.1
	.asciz	"   bailing out...\n"

	.comm	_MGA_DMAPAD,4,2                 ; @MGA_DMAPAD
	.comm	_MGA_PRIMADDRESS,4,2            ; @MGA_PRIMADDRESS
l_.str.2:                               ; @.str.2
	.asciz	"   head = 0x%06lx\n"

l_.str.3:                               ; @.str.3
	.asciz	"   tail = 0x%06lx\n"

l_.str.4:                               ; @.str.4
	.asciz	"  space = 0x%06x\n"

	.comm	_MGA_PRIMEND,4,2                ; @MGA_PRIMEND
l_.str.5:                               ; @.str.5
	.asciz	"done.\n"

.subsections_via_symbols
