	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function nes_mmap
_nes_mmap:                              ## @nes_mmap
	.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	%r12
	pushq	%rbx
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsi, %r14
	movq	%rdi, %rbx
	movl	(%rdi), %edi
	callq	_to_nesvnic
	movq	(%rax), %r12
	movq	%rbx, %rdi
	callq	_to_nesucontext
	movq	%rax, %r15
	movslq	(%r14), %rbx
	movl	(%rax), %eax
	cmpl	%eax, %ebx
	jge	LBB0_1
## %bb.12:
	movl	16(%r15), %esi
	movq	%rbx, %rdi
	callq	_test_bit
	testl	%eax, %eax
	je	LBB0_13
## %bb.15:
	movl	16(%r14), %edi
	callq	_pgprot_noncached
	movl	%eax, 16(%r14)
	movq	8(%r15), %rcx
	movl	(%rcx,%rbx,4), %edx
	subl	4(%r12), %edx
	shll	$12, %edx
	addl	(%r12), %edx
	movq	_PAGE_SHIFT@GOTPCREL(%rip), %rcx
	movb	(%rcx), %cl
	sarl	%cl, %edx
	movq	24(%r14), %rsi
	movq	_PAGE_SIZE@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	movq	%r14, %rdi
	movl	%eax, %r8d
	callq	_io_remap_pfn_range
	testq	%rax, %rax
	je	LBB0_17
## %bb.16:
	movq	_EAGAIN@GOTPCREL(%rip), %rax
	jmp	LBB0_14
LBB0_1:
	subl	%eax, %ebx
	movq	_PAGE_SIZE@GOTPCREL(%rip), %rax
	movslq	(%rax), %rcx
	imull	%ecx, %ebx
	movslq	%ebx, %rax
	movq	8(%r12), %rdx
	movslq	(%rdx), %rdx
	leaq	(%rcx,%rdx,8), %rdx
	decq	%rdx
	negl	%ecx
	movslq	%ecx, %rcx
	andq	%rdx, %rcx
	movq	%rax, %rdx
	orq	%rcx, %rdx
	shrq	$32, %rdx
	je	LBB0_2
## %bb.3:
	xorl	%edx, %edx
	divq	%rcx
	movq	%rax, %r12
	jmp	LBB0_4
LBB0_13:
	movq	_EFAULT@GOTPCREL(%rip), %rax
LBB0_14:
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_19
LBB0_2:
	movl	%ebx, %eax
	xorl	%edx, %edx
	divl	%ecx
	movl	%eax, %r12d
LBB0_4:
	movl	32(%r15), %esi
	movq	%r12, %rdi
	callq	_test_bit
	testl	%eax, %eax
	je	LBB0_5
## %bb.7:
	movq	24(%r15), %rax
	movq	(%rax,%r12,8), %rbx
	testq	%rbx, %rbx
	je	LBB0_8
## %bb.9:
	movq	24(%r14), %r15
	movl	20(%rbx), %edi
	callq	_virt_to_phys
	movq	_PAGE_SHIFT@GOTPCREL(%rip), %rcx
	movb	(%rcx), %cl
	sarl	%cl, %eax
	movq	32(%r14), %rcx
	subq	24(%r14), %rcx
	movl	16(%r14), %r8d
	movq	%r14, %rdi
	movq	%r15, %rsi
	movl	%eax, %edx
	callq	_remap_pfn_range
	testq	%rax, %rax
	je	LBB0_11
## %bb.10:
	movq	_NES_DBG_MMAP@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str.2(%rip), %rsi
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_nes_debug
	movq	_EAGAIN@GOTPCREL(%rip), %rax
	subl	(%rax), %ebx
	jmp	LBB0_19
LBB0_5:
	movq	_NES_DBG_MMAP@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str(%rip), %rsi
	jmp	LBB0_6
LBB0_17:
	movq	%r15, 8(%r14)
	jmp	LBB0_18
LBB0_8:
	movq	_NES_DBG_MMAP@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str.1(%rip), %rsi
LBB0_6:
	xorl	%ebx, %ebx
	movq	%r12, %rdx
	xorl	%eax, %eax
	callq	_nes_debug
	movq	_EFAULT@GOTPCREL(%rip), %rax
	subl	(%rax), %ebx
	jmp	LBB0_19
LBB0_11:
	movq	%rbx, 8(%r14)
LBB0_18:
	xorl	%ebx, %ebx
LBB0_19:
	movl	%ebx, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_PAGE_SIZE,4,2                  ## @PAGE_SIZE
	.comm	_NES_DBG_MMAP,4,2               ## @NES_DBG_MMAP
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"wq %lu not allocated\n"

	.comm	_EFAULT,4,2                     ## @EFAULT
L_.str.1:                               ## @.str.1
	.asciz	"wq %lu has a NULL QP base.\n"

	.comm	_PAGE_SHIFT,4,2                 ## @PAGE_SHIFT
L_.str.2:                               ## @.str.2
	.asciz	"remap_pfn_range failed.\n"

	.comm	_EAGAIN,4,2                     ## @EAGAIN
	.comm	_ENOSYS,4,2                     ## @ENOSYS
	.no_dead_strip	_nes_mmap
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function nes_mmap
_nes_mmap:                              ; @nes_mmap
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #64
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.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
	mov	x19, x1
	mov	x20, x0
	ldr	w0, [x0]
	bl	_to_nesvnic
	ldr	x22, [x0]
	mov	x0, x20
	bl	_to_nesucontext
	mov	x20, x0
	ldrsw	x21, [x19]
	ldr	w8, [x0]
	cmp	w21, w8
	b.ge	LBB0_4
; %bb.1:
	ldr	w1, [x20, #16]
	mov	x0, x21
	bl	_test_bit
	cbz	w0, LBB0_12
; %bb.2:
	ldr	w0, [x19, #16]
	bl	_pgprot_noncached
	mov	x4, x0
	str	w0, [x19, #16]
	ldr	x8, [x20, #8]
	ldr	w8, [x8, x21, lsl #2]
	ldr	x1, [x19, #24]
	ldp	w9, w10, [x22]
	sub	w8, w8, w10
Lloh0:
	adrp	x10, _PAGE_SHIFT@GOTPAGE
Lloh1:
	ldr	x10, [x10, _PAGE_SHIFT@GOTPAGEOFF]
	add	w8, w9, w8, lsl #12
Lloh2:
	ldr	w9, [x10]
	asr	w2, w8, w9
Lloh3:
	adrp	x8, _PAGE_SIZE@GOTPAGE
Lloh4:
	ldr	x8, [x8, _PAGE_SIZE@GOTPAGEOFF]
Lloh5:
	ldr	w3, [x8]
	mov	x0, x19
	bl	_io_remap_pfn_range
	cbnz	x0, LBB0_8
; %bb.3:
	str	x20, [x19, #8]
	b	LBB0_14
LBB0_4:
	sub	w8, w21, w8
Lloh6:
	adrp	x9, _PAGE_SIZE@GOTPAGE
Lloh7:
	ldr	x9, [x9, _PAGE_SIZE@GOTPAGEOFF]
Lloh8:
	ldrsw	x9, [x9]
	mul	w8, w9, w8
	sxtw	x8, w8
	ldr	x10, [x22, #8]
	ldrsw	x10, [x10]
	add	x10, x9, x10, lsl #3
	sub	x10, x10, #1
	neg	w9, w9
	sxtw	x9, w9
	and	x9, x10, x9
	udiv	x21, x8, x9
	ldr	w1, [x20, #32]
	mov	x0, x21
	bl	_test_bit
	cbz	w0, LBB0_9
; %bb.5:
	ldr	x8, [x20, #24]
	ldr	x22, [x8, x21, lsl #3]
	cbz	x22, LBB0_10
; %bb.6:
	ldr	x20, [x19, #24]
	ldr	w0, [x22, #20]
	bl	_virt_to_phys
Lloh9:
	adrp	x8, _PAGE_SHIFT@GOTPAGE
Lloh10:
	ldr	x8, [x8, _PAGE_SHIFT@GOTPAGEOFF]
Lloh11:
	ldr	w8, [x8]
	asr	w2, w0, w8
	ldp	x9, x8, [x19, #24]
	sub	x3, x8, x9
	ldr	w4, [x19, #16]
	mov	x0, x19
	mov	x1, x20
	bl	_remap_pfn_range
	cbz	x0, LBB0_15
; %bb.7:
Lloh12:
	adrp	x8, _NES_DBG_MMAP@GOTPAGE
Lloh13:
	ldr	x8, [x8, _NES_DBG_MMAP@GOTPAGEOFF]
Lloh14:
	ldr	w0, [x8]
Lloh15:
	adrp	x1, l_.str.2@PAGE
Lloh16:
	add	x1, x1, l_.str.2@PAGEOFF
	bl	_nes_debug
LBB0_8:
Lloh17:
	adrp	x8, _EAGAIN@GOTPAGE
Lloh18:
	ldr	x8, [x8, _EAGAIN@GOTPAGEOFF]
	b	LBB0_13
LBB0_9:
Lloh19:
	adrp	x8, _NES_DBG_MMAP@GOTPAGE
Lloh20:
	ldr	x8, [x8, _NES_DBG_MMAP@GOTPAGEOFF]
Lloh21:
	ldr	w0, [x8]
	str	x21, [sp]
Lloh22:
	adrp	x1, l_.str@PAGE
Lloh23:
	add	x1, x1, l_.str@PAGEOFF
	b	LBB0_11
LBB0_10:
Lloh24:
	adrp	x8, _NES_DBG_MMAP@GOTPAGE
Lloh25:
	ldr	x8, [x8, _NES_DBG_MMAP@GOTPAGEOFF]
Lloh26:
	ldr	w0, [x8]
	str	x21, [sp]
Lloh27:
	adrp	x1, l_.str.1@PAGE
Lloh28:
	add	x1, x1, l_.str.1@PAGEOFF
LBB0_11:
	bl	_nes_debug
LBB0_12:
Lloh29:
	adrp	x8, _EFAULT@GOTPAGE
Lloh30:
	ldr	x8, [x8, _EFAULT@GOTPAGEOFF]
LBB0_13:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_14:
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #64
	ret
LBB0_15:
	str	x22, [x19, #8]
	b	LBB0_14
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpAdd	Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGot	Lloh17, Lloh18
	.loh AdrpAdd	Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.loh AdrpAdd	Lloh27, Lloh28
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.loh AdrpLdrGot	Lloh29, Lloh30
	.cfi_endproc
                                        ; -- End function
	.comm	_PAGE_SIZE,4,2                  ; @PAGE_SIZE
	.comm	_NES_DBG_MMAP,4,2               ; @NES_DBG_MMAP
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"wq %lu not allocated\n"

	.comm	_EFAULT,4,2                     ; @EFAULT
l_.str.1:                               ; @.str.1
	.asciz	"wq %lu has a NULL QP base.\n"

	.comm	_PAGE_SHIFT,4,2                 ; @PAGE_SHIFT
l_.str.2:                               ; @.str.2
	.asciz	"remap_pfn_range failed.\n"

	.comm	_EAGAIN,4,2                     ; @EAGAIN
	.comm	_ENOSYS,4,2                     ; @ENOSYS
	.no_dead_strip	_nes_mmap
.subsections_via_symbols
