	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function d3d8_allocate_handle
_d3d8_allocate_handle:                  ## @d3d8_allocate_handle
	.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
	movl	%edx, %r14d
	movq	%rsi, %r15
	movq	%rdi, %rbx
	movq	24(%rdi), %rdx
	testq	%rdx, %rdx
	je	LBB0_4
## %bb.1:
	movq	%rdx, %rax
	subq	16(%rbx), %rax
	shrq	$4, %rax
	movl	(%rdx), %ecx
	movq	_D3D8_HANDLE_FREE@GOTPCREL(%rip), %rsi
	cmpl	(%rsi), %ecx
	jne	LBB0_2
## %bb.3:
	movq	8(%rdx), %rcx
	movq	%rcx, 24(%rbx)
	movq	%r15, 8(%rdx)
	movl	%r14d, (%rdx)
	jmp	LBB0_11
LBB0_4:
	movq	(%rbx), %rax
	movq	8(%rbx), %rcx
	cmpq	%rcx, %rax
	jae	LBB0_6
## %bb.5:
	movq	16(%rbx), %rcx
	jmp	LBB0_10
LBB0_2:
	leaq	L_.str(%rip), %rdi
	movl	%eax, %esi
	xorl	%eax, %eax
	callq	_ERR
LBB0_8:
	movq	_D3D8_INVALID_HANDLE@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	jmp	LBB0_11
LBB0_6:
	movq	%rcx, %r12
	shrq	%r12
	addq	%rcx, %r12
	movq	16(%rbx), %rdi
	movl	%r12d, %esi
	shll	$4, %esi
	callq	_heap_realloc
	testq	%rax, %rax
	je	LBB0_7
## %bb.9:
	movq	%rax, %rcx
	shlq	$32, %r12
	sarq	$32, %r12
	movq	%rax, 16(%rbx)
	movq	%r12, 8(%rbx)
	movq	(%rbx), %rax
LBB0_10:
	movq	%rax, %rdx
	shlq	$4, %rdx
	movq	%r15, 8(%rcx,%rdx)
	movl	%r14d, (%rcx,%rdx)
	leaq	1(%rax), %rcx
	movq	%rcx, (%rbx)
LBB0_11:
                                        ## kill: def $eax killed $eax killed $rax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_7:
	leaq	L_.str.1(%rip), %rdi
	xorl	%eax, %eax
	callq	_ERR
	jmp	LBB0_8
	.cfi_endproc
                                        ## -- End function
	.comm	_D3D8_HANDLE_FREE,4,2           ## @D3D8_HANDLE_FREE
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Handle %u(%p) is in the free list, but has type %#x.\n"

	.comm	_D3D8_INVALID_HANDLE,4,2        ## @D3D8_INVALID_HANDLE
L_.str.1:                               ## @.str.1
	.asciz	"Failed to grow the handle table.\n"

	.no_dead_strip	_d3d8_allocate_handle
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function d3d8_allocate_handle
_d3d8_allocate_handle:                  ; @d3d8_allocate_handle
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #80
	.cfi_def_cfa_offset 80
	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
	mov	x19, x2
	mov	x21, x1
	mov	x20, x0
	ldr	x8, [x0, #24]
	cbz	x8, LBB0_3
; %bb.1:
	ldr	x9, [x20, #16]
	sub	x9, x8, x9
	lsr	x0, x9, #4
	ldr	w9, [x8]
Lloh0:
	adrp	x10, _D3D8_HANDLE_FREE@GOTPAGE
Lloh1:
	ldr	x10, [x10, _D3D8_HANDLE_FREE@GOTPAGEOFF]
Lloh2:
	ldr	w10, [x10]
	cmp	w9, w10
	b.ne	LBB0_5
; %bb.2:
	ldr	x9, [x8, #8]
	str	x9, [x20, #24]
	str	x21, [x8, #8]
	str	w19, [x8]
	b	LBB0_10
LBB0_3:
	ldp	x8, x9, [x20]
	cmp	x8, x9
	b.hs	LBB0_7
; %bb.4:
	ldr	x0, [x20, #16]
	b	LBB0_9
LBB0_5:
	stp	x8, x9, [sp, #8]
                                        ; kill: def $w0 killed $w0 killed $x0 def $x0
	str	x0, [sp]
Lloh3:
	adrp	x0, l_.str@PAGE
Lloh4:
	add	x0, x0, l_.str@PAGEOFF
LBB0_6:
	bl	_ERR
Lloh5:
	adrp	x8, _D3D8_INVALID_HANDLE@GOTPAGE
Lloh6:
	ldr	x8, [x8, _D3D8_INVALID_HANDLE@GOTPAGEOFF]
Lloh7:
	ldr	w0, [x8]
	b	LBB0_10
LBB0_7:
	add	x22, x9, x9, lsr #1
	ldr	x0, [x20, #16]
	lsl	w1, w22, #4
	bl	_heap_realloc
	cbz	x0, LBB0_11
; %bb.8:
	lsl	x8, x22, #32
	asr	x8, x8, #32
	stp	x8, x0, [x20, #8]
	ldr	x8, [x20]
LBB0_9:
	add	x9, x0, x8, lsl #4
	str	x21, [x9, #8]
	str	w19, [x9]
	add	x9, x8, #1
	str	x9, [x20]
	mov	x0, x8
LBB0_10:
                                        ; kill: def $w0 killed $w0 killed $x0
	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
	add	sp, sp, #80
	ret
LBB0_11:
Lloh8:
	adrp	x0, l_.str.1@PAGE
Lloh9:
	add	x0, x0, l_.str.1@PAGEOFF
	b	LBB0_6
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpAdd	Lloh8, Lloh9
	.cfi_endproc
                                        ; -- End function
	.comm	_D3D8_HANDLE_FREE,4,2           ; @D3D8_HANDLE_FREE
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Handle %u(%p) is in the free list, but has type %#x.\n"

	.comm	_D3D8_INVALID_HANDLE,4,2        ; @D3D8_INVALID_HANDLE
l_.str.1:                               ; @.str.1
	.asciz	"Failed to grow the handle table.\n"

	.no_dead_strip	_d3d8_allocate_handle
.subsections_via_symbols
