	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function amd64_insert_memory
_amd64_insert_memory:                   ## @amd64_insert_memory
	.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	$24, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%edx, %r13d
	movl	%esi, -44(%rbp)                 ## 4-byte Spill
	movq	%rdi, %r14
	movq	32(%rdi), %r15
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_agp_num_entries
	cmpl	%r13d, (%r14)
	jne	LBB0_5
## %bb.1:
	movl	%eax, %r12d
	movq	(%r15), %rax
	movq	%r15, %rdi
	movl	%r13d, %esi
	callq	*(%rax)
	testl	%eax, %eax
	jne	LBB0_3
## %bb.2:
	movslq	-44(%rbp), %r15                 ## 4-byte Folded Reload
	movq	8(%r14), %rax
	leaq	(%rax,%r15), %rcx
	movslq	%r12d, %rdx
	cmpq	%rdx, %rcx
	jbe	LBB0_8
LBB0_3:
	movq	_EINVAL@GOTPCREL(%rip), %rax
LBB0_4:
	xorl	%ebx, %ebx
	jmp	LBB0_6
LBB0_5:
	movq	_EINVAL@GOTPCREL(%rip), %rax
LBB0_6:
	subl	(%rax), %ebx
LBB0_7:
	movl	%ebx, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_8:
	cmpq	%r15, %rcx
	jbe	LBB0_12
## %bb.9:
	movq	_agp_bridge@GOTPCREL(%rip), %r12
	movq	%r15, %rbx
	.p2align	4, 0x90
LBB0_10:                                ## =>This Inner Loop Header: Depth=1
	movq	(%r12), %r13
	movq	(%r13), %rdi
	addq	%rbx, %rdi
	callq	_readl
	movq	%r13, %rdi
	movl	%eax, %esi
	callq	_PGE_EMPTY
	testl	%eax, %eax
	je	LBB0_18
## %bb.11:                              ##   in Loop: Header=BB0_10 Depth=1
	incq	%rbx
	movq	8(%r14), %rax
	leaq	(%rax,%r15), %rcx
	cmpq	%rbx, %rcx
	ja	LBB0_10
LBB0_12:
	cmpl	$0, 16(%r14)
	jne	LBB0_14
## %bb.13:
	xorl	%eax, %eax
	callq	_global_cache_flush
	movl	$1, 16(%r14)
	movq	8(%r14), %rax
LBB0_14:
	testq	%rax, %rax
	je	LBB0_17
## %bb.15:
	xorl	%r12d, %r12d
	movq	%r14, -56(%rbp)                 ## 8-byte Spill
	.p2align	4, 0x90
LBB0_16:                                ## =>This Inner Loop Header: Depth=1
	movq	_agp_bridge@GOTPCREL(%rip), %r14
	movq	(%r14), %rbx
	movq	8(%rbx), %rax
	movq	(%rax), %r13
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	movq	24(%rax), %rax
	movl	(%rax,%r12,4), %edi
	callq	_page_to_phys
	movq	%rbx, %rdi
	movl	%eax, %esi
	xorl	%edx, %edx
	callq	*%r13
	movq	%rax, %rbx
	movq	%rax, %rdi
	movabsq	$-1099511623684, %rax           ## imm = 0xFFFFFF0000000FFC
	andq	%rax, %rdi
	callq	_BUG_ON
	movq	%rbx, %rax
	shrq	$28, %rax
	andl	$4080, %eax                     ## imm = 0xFF0
	andl	$-4096, %ebx                    ## imm = 0xF000
	orq	%rax, %rbx
	movq	_GPTE_VALID@GOTPCREL(%rip), %rax
	orq	(%rax), %rbx
	movq	_GPTE_COHERENT@GOTPCREL(%rip), %rax
	orq	(%rax), %rbx
	movq	(%r14), %rax
	movq	(%rax), %rsi
	addq	%r15, %rsi
	movq	%rbx, %rdi
	callq	_writel
	movq	(%r14), %rax
	movq	-56(%rbp), %r14                 ## 8-byte Reload
	movq	(%rax), %rdi
	addq	%r15, %rdi
	callq	_readl
	incq	%r12
	incq	%r15
	cmpq	%r12, 8(%r14)
	ja	LBB0_16
LBB0_17:
	movq	%r14, %rdi
	callq	_amd64_tlbflush
	xorl	%ebx, %ebx
	jmp	LBB0_7
LBB0_18:
	movq	_EBUSY@GOTPCREL(%rip), %rax
	jmp	LBB0_4
	.cfi_endproc
                                        ## -- End function
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_agp_bridge,8,3                 ## @agp_bridge
	.comm	_EBUSY,4,2                      ## @EBUSY
	.comm	_GPTE_VALID,8,3                 ## @GPTE_VALID
	.comm	_GPTE_COHERENT,8,3              ## @GPTE_COHERENT
	.no_dead_strip	_amd64_insert_memory
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function amd64_insert_memory
_amd64_insert_memory:                   ; @amd64_insert_memory
	.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	x22, x2
	mov	x20, x1
	mov	x19, x0
	ldr	x23, [x0, #32]
	bl	_agp_num_entries
	ldr	w8, [x19]
	cmp	w8, w22
	b.ne	LBB0_3
; %bb.1:
	mov	x21, x0
	ldr	x8, [x23]
	ldr	x8, [x8]
	mov	x0, x23
	mov	x1, x22
	blr	x8
	cbnz	w0, LBB0_3
; %bb.2:
	sxtw	x22, w20
	ldr	x8, [x19, #8]
	add	x9, x8, x22
	cmp	x9, w21, sxtw
	b.ls	LBB0_6
LBB0_3:
Lloh0:
	adrp	x8, _EINVAL@GOTPAGE
Lloh1:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
LBB0_4:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_5:
	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_6:
	cmp	x9, x22
	b.ls	LBB0_10
; %bb.7:
Lloh2:
	adrp	x21, _agp_bridge@GOTPAGE
Lloh3:
	ldr	x21, [x21, _agp_bridge@GOTPAGEOFF]
	mov	x23, x22
LBB0_8:                                 ; =>This Inner Loop Header: Depth=1
	ldr	x20, [x21]
	ldr	x8, [x20]
	add	x0, x23, x8
	bl	_readl
	mov	x1, x0
	mov	x0, x20
	bl	_PGE_EMPTY
	cbz	w0, LBB0_16
; %bb.9:                                ;   in Loop: Header=BB0_8 Depth=1
	add	x23, x23, #1
	ldr	x8, [x19, #8]
	add	x9, x8, x22
	cmp	x9, x23
	b.hi	LBB0_8
LBB0_10:
	ldr	w9, [x19, #16]
	cbnz	w9, LBB0_12
; %bb.11:
	bl	_global_cache_flush
	mov	w8, #1
	str	w8, [x19, #16]
	ldr	x8, [x19, #8]
LBB0_12:
	cbz	x8, LBB0_15
; %bb.13:
	mov	x21, #0
Lloh4:
	adrp	x23, _agp_bridge@GOTPAGE
Lloh5:
	ldr	x23, [x23, _agp_bridge@GOTPAGEOFF]
	mov	x24, #-1099511627776
	movk	x24, #4092
Lloh6:
	adrp	x25, _GPTE_VALID@GOTPAGE
Lloh7:
	ldr	x25, [x25, _GPTE_VALID@GOTPAGEOFF]
Lloh8:
	adrp	x26, _GPTE_COHERENT@GOTPAGE
Lloh9:
	ldr	x26, [x26, _GPTE_COHERENT@GOTPAGEOFF]
LBB0_14:                                ; =>This Inner Loop Header: Depth=1
	ldr	x20, [x23]
	ldr	x8, [x20, #8]
	ldr	x27, [x8]
	ldr	x8, [x19, #24]
	ldr	w0, [x8, x21, lsl #2]
	bl	_page_to_phys
	mov	x1, x0
	mov	x0, x20
	mov	w2, #0
	blr	x27
	mov	x20, x0
	and	x0, x0, x24
	bl	_BUG_ON
	lsr	x8, x20, #28
	and	x8, x8, #0xff0
	and	x9, x20, #0xfffff000
	ldr	x10, [x25]
	ldr	x11, [x26]
	orr	x8, x8, x9
	orr	x8, x8, x10
	orr	x0, x8, x11
	ldr	x8, [x23]
	ldr	x8, [x8]
	add	x20, x22, x21
	add	x1, x20, x8
	bl	_writel
	ldr	x8, [x23]
	ldr	x8, [x8]
	add	x0, x20, x8
	bl	_readl
	add	x21, x21, #1
	ldr	x8, [x19, #8]
	cmp	x8, x21
	b.hi	LBB0_14
LBB0_15:
	mov	x0, x19
	bl	_amd64_tlbflush
	mov	w0, #0
	b	LBB0_5
LBB0_16:
Lloh10:
	adrp	x8, _EBUSY@GOTPAGE
Lloh11:
	ldr	x8, [x8, _EBUSY@GOTPAGEOFF]
	b	LBB0_4
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh10, Lloh11
	.cfi_endproc
                                        ; -- End function
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_agp_bridge,8,3                 ; @agp_bridge
	.comm	_EBUSY,4,2                      ; @EBUSY
	.comm	_GPTE_VALID,8,3                 ; @GPTE_VALID
	.comm	_GPTE_COHERENT,8,3              ; @GPTE_COHERENT
	.no_dead_strip	_amd64_insert_memory
.subsections_via_symbols
