	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function savage_dma_flush
_savage_dma_flush:                      ## @savage_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
	subq	$56, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r13
	movl	(%rdi), %esi
	movl	4(%rdi), %r14d
	movl	%r14d, %r12d
	movq	24(%rdi), %rax
	subl	%esi, %r12d
	jne	LBB0_1
## %bb.2:
	leaq	(%rsi,%rsi,2), %rdx
	movl	4(%rax,%rdx,4), %ecx
	cmpl	%ecx, (%rax,%rdx,4)
	jne	LBB0_3
## %bb.13:
	addq	$56, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_1:
	leaq	(%rsi,%rsi,2), %rcx
	movl	4(%rax,%rcx,4), %ecx
LBB0_3:
	leaq	(%r14,%r14,2), %rdx
	movq	%rdx, -56(%rbp)                 ## 8-byte Spill
	movl	(%rax,%rdx,4), %r8d
	movl	%r8d, %ebx
	andl	$1, %ebx
	leal	(%r8,%rbx), %eax
	negl	%eax
	andl	$7, %eax
	movl	%eax, -60(%rbp)                 ## 4-byte Spill
	movl	%eax, (%rsp)
	leaq	L_.str(%rip), %rdi
	movq	%rsi, -48(%rbp)                 ## 8-byte Spill
                                        ## kill: def $esi killed $esi killed $rsi
	movl	%r14d, %edx
                                        ## kill: def $r8d killed $r8d killed $r8
	movl	%ebx, %r9d
	xorl	%eax, %eax
	callq	_DRM_DEBUG
	testl	%ebx, %ebx
	je	LBB0_5
## %bb.4:
	movq	24(%r13), %rax
	movq	40(%r13), %rcx
	movq	_SAVAGE_DMA_PAGE_SIZE@GOTPCREL(%rip), %rdx
	movl	(%rdx), %edx
	imull	%r14d, %edx
	shlq	$2, %rdx
	addq	8(%rcx), %rdx
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	movl	(%rax,%rdi,4), %ecx
	leal	1(%rcx), %esi
	movl	%esi, (%rax,%rdi,4)
	movq	_BCI_CMD_WAIT@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, (%rdx,%rcx,4)
LBB0_5:
	xorl	%eax, %eax
	callq	_DRM_MEMORYBARRIER
	movq	24(%r13), %rax
	movq	40(%r13), %rcx
	movq	_SAVAGE_DMA_PAGE_SIZE@GOTPCREL(%rip), %rdx
	movl	(%rdx), %edx
	movl	%edx, %ebx
	movq	-48(%rbp), %rsi                 ## 8-byte Reload
	imull	%esi, %ebx
	leaq	(%rsi,%rsi,2), %rsi
	movq	%rsi, -72(%rbp)                 ## 8-byte Spill
	movl	4(%rax,%rsi,4), %esi
	addl	%esi, %ebx
	shll	$2, %ebx
	addl	(%rcx), %ebx
	imull	%edx, %r12d
	leaq	(,%r14,4), %rcx
	leaq	(%rcx,%rcx,2), %r15
	subl	%esi, %r12d
	addl	(%rax,%r15), %r12d
	movl	%ebx, %esi
	orl	8(%r13), %esi
	leaq	L_.str.1(%rip), %rdi
	movl	%r12d, %edx
	xorl	%eax, %eax
	callq	_DRM_DEBUG
	movl	$3, %edi
	callq	_BEGIN_BCI
	movq	_SAVAGE_DMABUFADDR@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movl	$1, %esi
	callq	_BCI_SET_REGISTERS
	movq	8(%r13), %rdi
	orq	%rbx, %rdi
	callq	_BCI_WRITE
	movl	%r12d, %edi
	callq	_BCI_DMA
	movq	24(%r13), %rax
	movq	%r15, -80(%rbp)                 ## 8-byte Spill
	movl	-60(%rbp), %ecx                 ## 4-byte Reload
	addl	%ecx, (%rax,%r15)
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	_savage_bci_emit_event
	movl	%eax, %r12d
	movl	%r14d, %ebx
	movl	16(%r13), %r15d
	movq	24(%r13), %rdi
	movq	-48(%rbp), %rdx                 ## 8-byte Reload
	subl	%edx, %ebx
	jbe	LBB0_9
## %bb.6:
	movq	%r14, -48(%rbp)                 ## 8-byte Spill
	movq	-72(%rbp), %rax                 ## 8-byte Reload
	leaq	8(,%rax,4), %r14
	.p2align	4, 0x90
LBB0_7:                                 ## =>This Inner Loop Header: Depth=1
	addq	%r14, %rdi
	movl	%r12d, %esi
	movl	%r15d, %edx
	callq	_SET_AGE
	movq	24(%r13), %rdi
	movq	$0, -8(%rdi,%r14)
	addq	$12, %r14
	decl	%ebx
	jne	LBB0_7
## %bb.8:
	movq	-48(%rbp), %r14                 ## 8-byte Reload
	movl	%r14d, %edx
LBB0_9:
	movq	-56(%rbp), %rcx                 ## 8-byte Reload
	movq	_SAVAGE_DMA_PAGE_SIZE@GOTPCREL(%rip), %rsi
	movl	(%rdi,%rcx,4), %eax
	cmpl	(%rsi), %eax
	jne	LBB0_11
## %bb.10:
	movq	-80(%rbp), %rbx                 ## 8-byte Reload
	addq	%rbx, %rdi
	addq	$8, %rdi
	movl	%r12d, %esi
	movl	%r15d, %edx
	callq	_SET_AGE
	movq	24(%r13), %rax
	movq	$0, (%rax,%rbx)
	incl	%r14d
	xorl	%eax, %eax
	cmpl	20(%r13), %r14d
	cmovel	%eax, %r14d
	movl	%r14d, 4(%r13)
	movl	%r14d, (%r13)
	jmp	LBB0_12
LBB0_11:
	movl	%r14d, (%r13)
	movl	%edx, %eax
	leaq	(%rax,%rax,2), %rax
	movl	(%rdi,%rax,4), %eax
	movl	%eax, 4(%rdi,%rcx,4)
LBB0_12:
	leaq	32(%r13), %rdi
	movl	%r12d, %esi
	movl	%r15d, %edx
	callq	_SET_AGE
	movq	24(%r13), %rax
	leaq	(%r14,%r14,2), %rcx
	movl	(%rax,%rcx,4), %edx
	movl	4(%rax,%rcx,4), %ecx
	leaq	L_.str.2(%rip), %rdi
	movl	%r14d, %esi
	xorl	%eax, %eax
	addq	$56, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_DRM_DEBUG                      ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.comm	_BCI_LOCALS,4,2                 ## @BCI_LOCALS
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"first=%u, cur=%u, first->flushed=%u, cur->used=%u, pad=%u, align=%u\n"

	.comm	_SAVAGE_DMA_PAGE_SIZE,4,2       ## @SAVAGE_DMA_PAGE_SIZE
	.comm	_BCI_CMD_WAIT,4,2               ## @BCI_CMD_WAIT
L_.str.1:                               ## @.str.1
	.asciz	"phys_addr=%lx, len=%u\n"

	.comm	_SAVAGE_DMABUFADDR,4,2          ## @SAVAGE_DMABUFADDR
L_.str.2:                               ## @.str.2
	.asciz	"first=cur=%u, cur->used=%u, cur->flushed=%u\n"

	.no_dead_strip	_savage_dma_flush
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function savage_dma_flush
_savage_dma_flush:                      ; @savage_dma_flush
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.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	x20, x0
	ldp	w21, w19, [x0]
	ldr	x8, [x0, #24]
	mov	w9, #12
	madd	x9, x21, x9, x8
	cmp	w19, w21
	b.ne	LBB0_2
; %bb.1:
	ldp	w10, w9, [x9]
	cmp	w10, w9
	b.ne	LBB0_3
	b	LBB0_13
LBB0_2:
	ldr	w9, [x9, #4]
LBB0_3:
	mov	w10, #12
	mul	x10, x19, x10
	ldr	w22, [x8, x10]
	and	w8, w22, #0x1
	add	w10, w22, w8
	neg	w10, w10
	and	w23, w10, #0x7
	stp	x9, x22, [sp]
	stp	x8, x23, [sp, #16]
Lloh0:
	adrp	x0, l_.str@PAGE
Lloh1:
	add	x0, x0, l_.str@PAGEOFF
	mov	x1, x21
	mov	x2, x19
	bl	_DRM_DEBUG
Lloh2:
	adrp	x24, _SAVAGE_DMA_PAGE_SIZE@GOTPAGE
Lloh3:
	ldr	x24, [x24, _SAVAGE_DMA_PAGE_SIZE@GOTPAGEOFF]
	tbz	w22, #0, LBB0_5
; %bb.4:
	ldr	x8, [x20, #40]
	ldr	x8, [x8, #8]
	ldr	w9, [x24]
	mul	w9, w9, w19
	ldr	x10, [x20, #24]
	mov	w11, #12
	mul	x11, x19, x11
	ldr	w12, [x10, x11]
	add	w13, w12, #1
	str	w13, [x10, x11]
	add	x8, x8, w9, uxtw #2
Lloh4:
	adrp	x9, _BCI_CMD_WAIT@GOTPAGE
Lloh5:
	ldr	x9, [x9, _BCI_CMD_WAIT@GOTPAGEOFF]
Lloh6:
	ldr	w9, [x9]
	str	w9, [x8, x12, lsl #2]
LBB0_5:
	bl	_DRM_MEMORYBARRIER
	ldr	x8, [x20, #40]
	ldr	w8, [x8]
	ldr	w9, [x24]
	ldr	x10, [x20, #24]
	mov	w11, #12
	madd	x11, x21, x11, x10
	ldr	w11, [x11, #4]
	madd	w12, w9, w21, w11
	add	w25, w8, w12, lsl #2
	add	x8, x19, x19, lsl #1
	lsl	x26, x8, #2
	ldr	w8, [x10, x26]
	subs	w10, w19, w21
	neg	w11, w11
	madd	w9, w9, w10, w11
	add	w22, w9, w8
	ldr	w8, [x20, #8]
	orr	w1, w25, w8
Lloh7:
	adrp	x0, l_.str.1@PAGE
Lloh8:
	add	x0, x0, l_.str.1@PAGEOFF
	mov	x2, x22
	bl	_DRM_DEBUG
	mov	w0, #3
	bl	_BEGIN_BCI
Lloh9:
	adrp	x8, _SAVAGE_DMABUFADDR@GOTPAGE
Lloh10:
	ldr	x8, [x8, _SAVAGE_DMABUFADDR@GOTPAGEOFF]
Lloh11:
	ldr	w0, [x8]
	mov	w1, #1
	bl	_BCI_SET_REGISTERS
	ldr	x8, [x20, #8]
	orr	x0, x8, x25
	bl	_BCI_WRITE
	mov	x0, x22
	bl	_BCI_DMA
	ldr	x8, [x20, #24]
	ldr	w9, [x8, x26]
	add	w9, w9, w23
	str	w9, [x8, x26]
	mov	x0, x20
	mov	w1, #0
	bl	_savage_bci_emit_event
	mov	x22, x0
	ldr	w23, [x20, #16]
	ldr	x8, [x20, #24]
	subs	w25, w19, w21
	b.ls	LBB0_9
; %bb.6:
	add	x9, x21, x21, lsl #1
	lsl	x21, x9, #2
LBB0_7:                                 ; =>This Inner Loop Header: Depth=1
	add	x8, x8, x21
	add	x0, x8, #8
	mov	x1, x22
	mov	x2, x23
	bl	_SET_AGE
	ldr	x8, [x20, #24]
	add	x9, x8, x21
	str	xzr, [x9]
	add	x21, x21, #12
	subs	w25, w25, #1
	b.ne	LBB0_7
; %bb.8:
	mov	x21, x19
LBB0_9:
	mov	w9, #12
	mul	x10, x19, x9
	ldr	w10, [x8, x10]
	ldr	w11, [x24]
	cmp	w10, w11
	b.ne	LBB0_11
; %bb.10:
	add	x9, x19, x19, lsl #1
	lsl	x21, x9, #2
	add	x8, x8, x21
	add	x0, x8, #8
	mov	x1, x22
	mov	x2, x23
	bl	_SET_AGE
	ldr	x8, [x20, #24]
	add	x8, x8, x21
	str	xzr, [x8]
	add	w8, w19, #1
	ldr	w9, [x20, #20]
	cmp	w8, w9
	csinc	w19, wzr, w19, eq
	stp	w19, w19, [x20]
	b	LBB0_12
LBB0_11:
	str	w19, [x20]
	umull	x10, w21, w9
	ldr	w10, [x8, x10]
	madd	x8, x19, x9, x8
	str	w10, [x8, #4]
LBB0_12:
	add	x0, x20, #32
	mov	x1, x22
	mov	x2, x23
	bl	_SET_AGE
	ldr	x8, [x20, #24]
	mov	w9, #12
	madd	x8, x19, x9, x8
	ldp	w2, w8, [x8]
	str	x8, [sp]
Lloh12:
	adrp	x0, l_.str.2@PAGE
Lloh13:
	add	x0, x0, l_.str.2@PAGEOFF
	mov	x1, x19
	bl	_DRM_DEBUG
LBB0_13:
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpAdd	Lloh7, Lloh8
	.loh AdrpAdd	Lloh12, Lloh13
	.cfi_endproc
                                        ; -- End function
	.comm	_BCI_LOCALS,4,2                 ; @BCI_LOCALS
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"first=%u, cur=%u, first->flushed=%u, cur->used=%u, pad=%u, align=%u\n"

	.comm	_SAVAGE_DMA_PAGE_SIZE,4,2       ; @SAVAGE_DMA_PAGE_SIZE
	.comm	_BCI_CMD_WAIT,4,2               ; @BCI_CMD_WAIT
l_.str.1:                               ; @.str.1
	.asciz	"phys_addr=%lx, len=%u\n"

	.comm	_SAVAGE_DMABUFADDR,4,2          ; @SAVAGE_DMABUFADDR
l_.str.2:                               ; @.str.2
	.asciz	"first=cur=%u, cur->used=%u, cur->flushed=%u\n"

	.no_dead_strip	_savage_dma_flush
.subsections_via_symbols
