	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_amdgpu_atomfirmware_allocate_fb_scratch ## -- Begin function amdgpu_atomfirmware_allocate_fb_scratch
	.p2align	4, 0x90
_amdgpu_atomfirmware_allocate_fb_scratch: ## @amdgpu_atomfirmware_allocate_fb_scratch
	.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	%rdi, %rbx
	movq	16(%rdi), %r15
	movq	_atom_master_list_of_data_tables_v2_1@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	_vram_usagebyfirmware@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_get_index_into_master_table
	leaq	-56(%rbp), %r9
	movq	%r15, %rdi
	movl	%eax, %esi
	xorl	%edx, %edx
	xorl	%ecx, %ecx
	xorl	%r8d, %r8d
	callq	_amdgpu_atom_parse_data_header
	testq	%rax, %rax
	je	LBB0_3
## %bb.1:
	movq	%rbx, -48(%rbp)                 ## 8-byte Spill
	movq	8(%r15), %r13
	movq	-56(%rbp), %r14
	movl	8(%r14,%r13), %edi
	callq	_le32_to_cpu
	movq	%rax, %r12
	movl	4(%r14,%r13), %edi
	callq	_le16_to_cpu
	movl	%eax, %ebx
	movl	(%r14,%r13), %edi
	callq	_le16_to_cpu
	leaq	L_.str(%rip), %rdi
	movq	%r12, %rsi
	movl	%ebx, %edx
	movl	%eax, %ecx
	callq	_DRM_DEBUG
	movl	8(%r14,%r13), %edi
	callq	_le32_to_cpu
	movq	%rax, %rbx
	movl	4(%r14,%r13), %edi
	callq	_le16_to_cpu
	movq	_ATOM_VRAM_OPERATION_FLAGS_MASK@GOTPCREL(%rip), %rdx
	movq	_ATOM_VRAM_BLOCK_SRIOV_MSG_SHARE_RESERVATION@GOTPCREL(%rip), %rcx
	movl	(%rcx), %esi
	movq	_ATOM_VRAM_OPERATION_FLAGS_SHIFT@GOTPCREL(%rip), %rcx
	movb	(%rcx), %cl
	shll	%cl, %esi
	movq	(%rdx), %rcx
	movq	%rcx, %rdx
	andq	%rbx, %rdx
	movslq	%esi, %rsi
	cmpq	%rsi, %rdx
	jne	LBB0_4
## %bb.2:
	cltq
	notq	%rcx
	andq	%rcx, %rbx
	shlq	$10, %rbx
	movq	-48(%rbp), %rcx                 ## 8-byte Reload
	movq	%rbx, 8(%rcx)
	shlq	$10, %rax
	movq	%rax, (%rcx)
LBB0_3:
	movl	$0, (%r15)
LBB0_5:
	movl	$20480, %ebx                    ## imm = 0x5000
LBB0_6:
	movq	_GFP_KERNEL@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	%ebx, %edi
	callq	_kzalloc
	movl	%eax, 4(%r15)
	testl	%eax, %eax
	je	LBB0_7
## %bb.8:
	movl	%ebx, (%r15)
	xorl	%eax, %eax
	jmp	LBB0_9
LBB0_7:
	movq	_ENOMEM@GOTPCREL(%rip), %rcx
	xorl	%eax, %eax
	subl	(%rcx), %eax
LBB0_9:
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_4:
	movl	(%r13,%r14), %edi
	callq	_le16_to_cpu
	movl	%eax, %ebx
	shll	$10, %ebx
	movl	$0, (%r15)
	jne	LBB0_6
	jmp	LBB0_5
	.cfi_endproc
                                        ## -- End function
	.comm	_atom_master_list_of_data_tables_v2_1,4,2 ## @atom_master_list_of_data_tables_v2_1
	.comm	_vram_usagebyfirmware,4,2       ## @vram_usagebyfirmware
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"atom firmware requested %08x %dkb fw %dkb drv\n"

	.comm	_ATOM_VRAM_OPERATION_FLAGS_MASK,8,3 ## @ATOM_VRAM_OPERATION_FLAGS_MASK
	.comm	_ATOM_VRAM_BLOCK_SRIOV_MSG_SHARE_RESERVATION,4,2 ## @ATOM_VRAM_BLOCK_SRIOV_MSG_SHARE_RESERVATION
	.comm	_ATOM_VRAM_OPERATION_FLAGS_SHIFT,4,2 ## @ATOM_VRAM_OPERATION_FLAGS_SHIFT
	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ## @ENOMEM
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_amdgpu_atomfirmware_allocate_fb_scratch ; -- Begin function amdgpu_atomfirmware_allocate_fb_scratch
	.p2align	2
_amdgpu_atomfirmware_allocate_fb_scratch: ; @amdgpu_atomfirmware_allocate_fb_scratch
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #96
	.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
	mov	x20, x0
	ldr	x19, [x0, #16]
Lloh0:
	adrp	x8, _atom_master_list_of_data_tables_v2_1@GOTPAGE
Lloh1:
	ldr	x8, [x8, _atom_master_list_of_data_tables_v2_1@GOTPAGEOFF]
Lloh2:
	ldr	w0, [x8]
Lloh3:
	adrp	x8, _vram_usagebyfirmware@GOTPAGE
Lloh4:
	ldr	x8, [x8, _vram_usagebyfirmware@GOTPAGEOFF]
Lloh5:
	ldr	w1, [x8]
	bl	_get_index_into_master_table
	mov	x1, x0
	add	x5, sp, #8
	mov	x0, x19
	mov	x2, #0
	mov	x3, #0
	mov	x4, #0
	bl	_amdgpu_atom_parse_data_header
	cbz	x0, LBB0_3
; %bb.1:
	ldr	x23, [x19, #8]
	ldr	x24, [sp, #8]
	add	x25, x24, x23
	ldr	w0, [x25, #8]
	bl	_le32_to_cpu
	mov	x21, x0
	ldr	w0, [x25, #4]
	bl	_le16_to_cpu
	mov	x22, x0
	ldr	w0, [x25]
	bl	_le16_to_cpu
	mov	x3, x0
Lloh6:
	adrp	x0, l_.str@PAGE
Lloh7:
	add	x0, x0, l_.str@PAGEOFF
	mov	x1, x21
	mov	x2, x22
	bl	_DRM_DEBUG
	ldr	w0, [x25, #8]
	bl	_le32_to_cpu
	mov	x21, x0
	ldr	w0, [x25, #4]
	bl	_le16_to_cpu
                                        ; kill: def $w0 killed $w0 def $x0
Lloh8:
	adrp	x8, _ATOM_VRAM_OPERATION_FLAGS_MASK@GOTPAGE
Lloh9:
	ldr	x8, [x8, _ATOM_VRAM_OPERATION_FLAGS_MASK@GOTPAGEOFF]
Lloh10:
	ldr	x8, [x8]
	and	x9, x8, x21
Lloh11:
	adrp	x10, _ATOM_VRAM_BLOCK_SRIOV_MSG_SHARE_RESERVATION@GOTPAGE
Lloh12:
	ldr	x10, [x10, _ATOM_VRAM_BLOCK_SRIOV_MSG_SHARE_RESERVATION@GOTPAGEOFF]
Lloh13:
	ldr	w10, [x10]
Lloh14:
	adrp	x11, _ATOM_VRAM_OPERATION_FLAGS_SHIFT@GOTPAGE
Lloh15:
	ldr	x11, [x11, _ATOM_VRAM_OPERATION_FLAGS_SHIFT@GOTPAGEOFF]
Lloh16:
	ldr	w11, [x11]
	lsl	w10, w10, w11
	cmp	x9, w10, sxtw
	b.ne	LBB0_9
; %bb.2:
	bic	x8, x21, x8
	lsl	x8, x8, #10
	sbfiz	x9, x0, #10, #32
	stp	x9, x8, [x20]
LBB0_3:
	str	wzr, [x19]
LBB0_4:
	mov	w20, #20480
LBB0_5:
Lloh17:
	adrp	x8, _GFP_KERNEL@GOTPAGE
Lloh18:
	ldr	x8, [x8, _GFP_KERNEL@GOTPAGEOFF]
Lloh19:
	ldr	w1, [x8]
	mov	x0, x20
	bl	_kzalloc
	str	w0, [x19, #4]
	cbz	w0, LBB0_7
; %bb.6:
	mov	w0, #0
	str	w20, [x19]
	b	LBB0_8
LBB0_7:
Lloh20:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh21:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh22:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_8:
	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
	add	sp, sp, #96
	ret
LBB0_9:
	ldr	w0, [x23, x24]
	bl	_le16_to_cpu
	lsl	w20, w0, #10
	str	wzr, [x19]
	cbnz	w20, LBB0_5
	b	LBB0_4
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpAdd	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.cfi_endproc
                                        ; -- End function
	.comm	_atom_master_list_of_data_tables_v2_1,4,2 ; @atom_master_list_of_data_tables_v2_1
	.comm	_vram_usagebyfirmware,4,2       ; @vram_usagebyfirmware
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"atom firmware requested %08x %dkb fw %dkb drv\n"

	.comm	_ATOM_VRAM_OPERATION_FLAGS_MASK,8,3 ; @ATOM_VRAM_OPERATION_FLAGS_MASK
	.comm	_ATOM_VRAM_BLOCK_SRIOV_MSG_SHARE_RESERVATION,4,2 ; @ATOM_VRAM_BLOCK_SRIOV_MSG_SHARE_RESERVATION
	.comm	_ATOM_VRAM_OPERATION_FLAGS_SHIFT,4,2 ; @ATOM_VRAM_OPERATION_FLAGS_SHIFT
	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ; @ENOMEM
.subsections_via_symbols
