	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function nouveau_dmem_pages_alloc
_nouveau_dmem_pages_alloc:              ## @nouveau_dmem_pages_alloc
	.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
	movq	%rdx, %rax
	movq	%rsi, %r13
	movq	%rdi, %r14
	leaq	(,%rsi,8), %rdx
	movq	%rax, -64(%rbp)                 ## 8-byte Spill
	movq	%rax, %rdi
	movl	$255, %esi
	callq	_memset
	movq	(%r14), %rdi
	callq	_mutex_lock
	testq	%r13, %r13
	je	LBB0_13
## %bb.1:
	xorl	%r12d, %r12d
	movq	_DMEM_CHUNK_NPAGES@GOTPCREL(%rip), %r15
	movq	%r14, -48(%rbp)                 ## 8-byte Spill
	jmp	LBB0_2
	.p2align	4, 0x90
LBB0_11:                                ##   in Loop: Header=BB0_2 Depth=1
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	callq	_spin_unlock
	movq	-48(%rbp), %r14                 ## 8-byte Reload
	cmpq	%r13, %r12
	jae	LBB0_13
LBB0_2:                                 ## =>This Loop Header: Depth=1
                                        ##     Child Loop BB0_9 Depth 2
	movq	%r14, %rdi
	callq	_nouveau_dmem_chunk_first_free_locked
	testq	%rax, %rax
	je	LBB0_3
## %bb.6:                               ##   in Loop: Header=BB0_2 Depth=1
	movq	%rax, %rbx
	movq	%rax, %rdi
	addq	$8, %rdi
	movq	%rdi, -56(%rbp)                 ## 8-byte Spill
	callq	_spin_lock
	movl	12(%rbx), %edi
	movq	(%r15), %rsi
	callq	_find_first_zero_bit
	cmpq	(%r15), %rax
	jae	LBB0_11
## %bb.7:                               ##   in Loop: Header=BB0_2 Depth=1
	cmpq	%r13, %r12
	jae	LBB0_11
## %bb.8:                               ##   in Loop: Header=BB0_2 Depth=1
	movq	%rax, %r14
	.p2align	4, 0x90
LBB0_9:                                 ##   Parent Loop BB0_2 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	movq	(%rbx), %rax
	addq	%r14, %rax
	movq	-64(%rbp), %rcx                 ## 8-byte Reload
	movq	%rax, (%rcx,%r12,8)
	movl	12(%rbx), %esi
	movq	%r14, %rdi
	callq	_set_bit
	incl	16(%rbx)
	incq	%r12
	movl	12(%rbx), %edi
	movq	(%r15), %rsi
	movq	%r14, %rdx
	callq	_find_next_zero_bit
	cmpq	(%r15), %rax
	jae	LBB0_11
## %bb.10:                              ##   in Loop: Header=BB0_9 Depth=2
	movq	%rax, %r14
	cmpq	%r13, %r12
	jb	LBB0_9
	jmp	LBB0_11
	.p2align	4, 0x90
LBB0_3:                                 ##   in Loop: Header=BB0_2 Depth=1
	movq	(%r14), %rdi
	callq	_mutex_unlock
	movq	%r14, %rdi
	callq	_nouveau_dmem_chunk_alloc
	testl	%eax, %eax
	jne	LBB0_4
## %bb.5:                               ##   in Loop: Header=BB0_2 Depth=1
	movq	(%r14), %rdi
	callq	_mutex_lock
	cmpq	%r13, %r12
	jb	LBB0_2
LBB0_13:
	movq	(%r14), %rdi
	callq	_mutex_unlock
	xorl	%eax, %eax
LBB0_14:
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_4:
	movl	%eax, %ecx
	xorl	%eax, %eax
	testq	%r12, %r12
	cmovel	%ecx, %eax
	jmp	LBB0_14
	.cfi_endproc
                                        ## -- End function
	.comm	_DMEM_CHUNK_NPAGES,8,3          ## @DMEM_CHUNK_NPAGES
	.no_dead_strip	_nouveau_dmem_pages_alloc
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function nouveau_dmem_pages_alloc
_nouveau_dmem_pages_alloc:              ; @nouveau_dmem_pages_alloc
	.cfi_startproc
; %bb.0:
	stp	x26, x25, [sp, #-80]!           ; 16-byte Folded Spill
	.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
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	mov	x19, x2
	mov	x21, x1
	mov	x20, x0
	lsl	x2, x1, #3
	mov	x0, x19
	mov	w1, #255
	bl	_memset
	ldr	x0, [x20]
	bl	_mutex_lock
	cbz	x21, LBB0_9
; %bb.1:
	mov	x25, #0
Lloh0:
	adrp	x26, _DMEM_CHUNK_NPAGES@GOTPAGE
Lloh1:
	ldr	x26, [x26, _DMEM_CHUNK_NPAGES@GOTPAGEOFF]
	b	LBB0_3
LBB0_2:                                 ;   in Loop: Header=BB0_3 Depth=1
	mov	x0, x22
	bl	_spin_unlock
	cmp	x25, x21
	b.hs	LBB0_9
LBB0_3:                                 ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_6 Depth 2
	mov	x0, x20
	bl	_nouveau_dmem_chunk_first_free_locked
	cbz	x0, LBB0_7
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=1
	mov	x23, x0
	add	x22, x0, #8
	mov	x0, x22
	bl	_spin_lock
	ldr	w0, [x23, #12]
	ldr	x1, [x26]
	bl	_find_first_zero_bit
	ldr	x8, [x26]
	cmp	x0, x8
	ccmp	x25, x21, #2, lo
	b.hs	LBB0_2
; %bb.5:                                ;   in Loop: Header=BB0_3 Depth=1
	mov	x24, x0
LBB0_6:                                 ;   Parent Loop BB0_3 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	ldr	x8, [x23]
	add	x8, x8, x24
	str	x8, [x19, x25, lsl #3]
	ldr	w1, [x23, #12]
	mov	x0, x24
	bl	_set_bit
	ldp	w0, w8, [x23, #12]
	add	w8, w8, #1
	str	w8, [x23, #16]
	add	x25, x25, #1
	ldr	x1, [x26]
	mov	x2, x24
	bl	_find_next_zero_bit
	mov	x24, x0
	ldr	x8, [x26]
	cmp	x0, x8
	ccmp	x25, x21, #2, lo
	b.lo	LBB0_6
	b	LBB0_2
LBB0_7:                                 ;   in Loop: Header=BB0_3 Depth=1
	ldr	x0, [x20]
	bl	_mutex_unlock
	mov	x0, x20
	bl	_nouveau_dmem_chunk_alloc
	cbnz	w0, LBB0_11
; %bb.8:                                ;   in Loop: Header=BB0_3 Depth=1
	ldr	x0, [x20]
	bl	_mutex_lock
	cmp	x25, x21
	b.lo	LBB0_3
LBB0_9:
	ldr	x0, [x20]
	bl	_mutex_unlock
	mov	w0, #0
LBB0_10:
	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
	ldp	x26, x25, [sp], #80             ; 16-byte Folded Reload
	ret
LBB0_11:
	cmp	x25, #0
	csel	w0, w0, wzr, eq
	b	LBB0_10
	.loh AdrpLdrGot	Lloh0, Lloh1
	.cfi_endproc
                                        ; -- End function
	.comm	_DMEM_CHUNK_NPAGES,8,3          ; @DMEM_CHUNK_NPAGES
	.no_dead_strip	_nouveau_dmem_pages_alloc
.subsections_via_symbols
