	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function nes_alloc_fast_reg_mr
_nes_alloc_fast_reg_mr:                 ## @nes_alloc_fast_reg_mr
	.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	%esi, %r14d
	movq	%rdi, %rbx
	callq	_to_nespd
	movq	%rax, %r13
	movl	(%rbx), %edi
	callq	_to_nesvnic
	movq	(%rax), %r12
	movq	(%r12), %rbx
	movl	$0, -44(%rbp)
	movslq	%r14d, %rax
	movq	_NES_4K_PBL_CHUNK_SIZE@GOTPCREL(%rip), %rcx
	movslq	(%rcx), %rcx
	shrq	$2, %rcx
	cmpq	%rax, %rcx
	jae	LBB0_1
## %bb.10:
	movq	_E2BIG@GOTPCREL(%rip), %rax
	xorl	%edi, %edi
	subl	(%rax), %edi
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_ERR_PTR                        ## TAILCALL
LBB0_1:
	leaq	-48(%rbp), %rdi
	movl	$4, %esi
	callq	_get_random_bytes
	movl	-48(%rbp), %r15d
	movl	%r15d, %eax
	sarl	$8, %eax
	cltd
	idivl	(%rbx)
	movl	%edx, -48(%rbp)
	movl	(%rbx), %edx
	movl	4(%rbx), %esi
	movq	_NES_RESOURCE_FAST_MR@GOTPCREL(%rip), %rax
	movl	(%rax), %r9d
	leaq	-44(%rbp), %rcx
	movq	%rbx, %rdi
	leaq	-48(%rbp), %r8
	callq	_nes_alloc_resource
	testl	%eax, %eax
	je	LBB0_3
## %bb.2:
	movl	%eax, %edi
	jmp	LBB0_8
LBB0_3:
	movl	%r15d, -52(%rbp)                ## 4-byte Spill
	movq	%r13, -64(%rbp)                 ## 8-byte Spill
	movq	_GFP_KERNEL@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	$12, %edi
	callq	_kzalloc
	testq	%rax, %rax
	je	LBB0_7
## %bb.4:
	movq	%rax, %r13
	movl	-44(%rbp), %ecx
	movl	%ecx, %r15d
	shll	$8, %r15d
	addl	-52(%rbp), %r15d                ## 4-byte Folded Reload
	movq	_NES_DBG_MR@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str(%rip), %rsi
	movl	%r15d, %edx
	callq	_nes_debug
	movq	%r12, %rdi
	movq	-64(%rbp), %rsi                 ## 8-byte Reload
	movl	%r15d, %edx
	movl	%r14d, %ecx
	callq	_alloc_fast_reg_mr
	testl	%eax, %eax
	je	LBB0_5
## %bb.6:
	movq	%r13, %rdi
	callq	_kfree
LBB0_7:
	movl	4(%rbx), %esi
	movl	-44(%rbp), %edx
	movq	%rbx, %rdi
	callq	_nes_free_resource
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	xorl	%edi, %edi
	subl	(%rax), %edi
LBB0_8:
	callq	_ERR_PTR
	movq	%rax, %r13
LBB0_9:
	movq	%r13, %rax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_5:
	movl	%r15d, (%r13)
	movl	%r15d, 4(%r13)
	movq	_IWNES_MEMREG_TYPE_FMEM@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 8(%r13)
	jmp	LBB0_9
	.cfi_endproc
                                        ## -- End function
	.comm	_NES_4K_PBL_CHUNK_SIZE,4,2      ## @NES_4K_PBL_CHUNK_SIZE
	.comm	_E2BIG,4,2                      ## @E2BIG
	.comm	_NES_RESOURCE_FAST_MR,4,2       ## @NES_RESOURCE_FAST_MR
	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.comm	_NES_DBG_MR,4,2                 ## @NES_DBG_MR
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Allocating STag 0x%08X index = 0x%08X\n"

	.comm	_IWNES_MEMREG_TYPE_FMEM,4,2     ## @IWNES_MEMREG_TYPE_FMEM
	.no_dead_strip	_nes_alloc_fast_reg_mr
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function nes_alloc_fast_reg_mr
_nes_alloc_fast_reg_mr:                 ; @nes_alloc_fast_reg_mr
	.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	x20, x1
	mov	x19, x0
	bl	_to_nespd
	mov	x21, x0
	ldr	w0, [x19]
	bl	_to_nesvnic
	ldr	x22, [x0]
	ldr	x19, [x22]
	str	wzr, [sp, #8]
	sxtw	x8, w20
Lloh0:
	adrp	x9, _NES_4K_PBL_CHUNK_SIZE@GOTPAGE
Lloh1:
	ldr	x9, [x9, _NES_4K_PBL_CHUNK_SIZE@GOTPAGEOFF]
Lloh2:
	ldrsw	x9, [x9]
	cmp	x8, x9, lsr #2
	b.ls	LBB0_2
; %bb.1:
Lloh3:
	adrp	x8, _E2BIG@GOTPAGE
Lloh4:
	ldr	x8, [x8, _E2BIG@GOTPAGEOFF]
Lloh5:
	ldr	w8, [x8]
	neg	w0, w8
	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	_ERR_PTR
LBB0_2:
	add	x0, sp, #12
	mov	w1, #4
	bl	_get_random_bytes
	ldr	w24, [sp, #12]
	asr	w8, w24, #8
	ldp	w9, w1, [x19]
	sdiv	w10, w8, w9
	msub	w8, w10, w9, w8
	str	w8, [sp, #12]
	ldr	w2, [x19]
Lloh6:
	adrp	x8, _NES_RESOURCE_FAST_MR@GOTPAGE
Lloh7:
	ldr	x8, [x8, _NES_RESOURCE_FAST_MR@GOTPAGEOFF]
Lloh8:
	ldr	w5, [x8]
	add	x3, sp, #8
	add	x4, sp, #12
	mov	x0, x19
	bl	_nes_alloc_resource
	cbnz	w0, LBB0_7
; %bb.3:
Lloh9:
	adrp	x8, _GFP_KERNEL@GOTPAGE
Lloh10:
	ldr	x8, [x8, _GFP_KERNEL@GOTPAGEOFF]
Lloh11:
	ldr	w1, [x8]
	mov	w0, #12
	bl	_kzalloc
	cbz	x0, LBB0_6
; %bb.4:
	mov	x23, x0
	ldr	w3, [sp, #8]
	add	w24, w24, w3, lsl #8
Lloh12:
	adrp	x8, _NES_DBG_MR@GOTPAGE
Lloh13:
	ldr	x8, [x8, _NES_DBG_MR@GOTPAGEOFF]
Lloh14:
	ldr	w0, [x8]
Lloh15:
	adrp	x1, l_.str@PAGE
Lloh16:
	add	x1, x1, l_.str@PAGEOFF
	mov	x2, x24
	bl	_nes_debug
	mov	x0, x22
	mov	x1, x21
	mov	x2, x24
	mov	x3, x20
	bl	_alloc_fast_reg_mr
	cbz	w0, LBB0_9
; %bb.5:
	mov	x0, x23
	bl	_kfree
LBB0_6:
	ldr	w1, [x19, #4]
	ldr	w2, [sp, #8]
	mov	x0, x19
	bl	_nes_free_resource
Lloh17:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh18:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh19:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_7:
	bl	_ERR_PTR
	mov	x23, x0
LBB0_8:
	mov	x0, x23
	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
	ret
LBB0_9:
	stp	w24, w24, [x23]
Lloh20:
	adrp	x8, _IWNES_MEMREG_TYPE_FMEM@GOTPAGE
Lloh21:
	ldr	x8, [x8, _IWNES_MEMREG_TYPE_FMEM@GOTPAGEOFF]
Lloh22:
	ldr	w8, [x8]
	str	w8, [x23, #8]
	b	LBB0_8
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpAdd	Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.cfi_endproc
                                        ; -- End function
	.comm	_NES_4K_PBL_CHUNK_SIZE,4,2      ; @NES_4K_PBL_CHUNK_SIZE
	.comm	_E2BIG,4,2                      ; @E2BIG
	.comm	_NES_RESOURCE_FAST_MR,4,2       ; @NES_RESOURCE_FAST_MR
	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.comm	_NES_DBG_MR,4,2                 ; @NES_DBG_MR
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Allocating STag 0x%08X index = 0x%08X\n"

	.comm	_IWNES_MEMREG_TYPE_FMEM,4,2     ; @IWNES_MEMREG_TYPE_FMEM
	.no_dead_strip	_nes_alloc_fast_reg_mr
.subsections_via_symbols
