	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function sdma_v5_0_load_microcode
_sdma_v5_0_load_microcode:              ## @sdma_v5_0_load_microcode
	.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	$40, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r15
	xorl	%r14d, %r14d
	xorl	%esi, %esi
	callq	_sdma_v5_0_enable
	cmpl	$0, (%r15)
	jle	LBB0_12
## %bb.1:
	xorl	%r14d, %r14d
	movq	%r15, -56(%rbp)                 ## 8-byte Spill
	jmp	LBB0_2
	.p2align	4, 0x90
LBB0_10:                                ##   in Loop: Header=BB0_2 Depth=1
	movq	_mmSDMA0_UCODE_ADDR@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	-56(%rbp), %r15                 ## 8-byte Reload
	movq	%r15, %rdi
	movq	-48(%rbp), %r14                 ## 8-byte Reload
	movl	%r14d, %esi
	callq	_sdma_v5_0_get_reg_offset
	movq	8(%r15), %rcx
	movq	-72(%rbp), %rdx                 ## 8-byte Reload
	movl	(%rcx,%rdx), %esi
	movl	%eax, %edi
	callq	_WREG32
	incq	%r14
	movslq	(%r15), %rax
	cmpq	%rax, %r14
	jge	LBB0_11
LBB0_2:                                 ## =>This Loop Header: Depth=1
                                        ##     Child Loop BB0_6 Depth 2
	movq	8(%r15), %rax
	movq	%r14, %rbx
	shlq	$4, %rbx
	movq	8(%rax,%rbx), %rax
	testq	%rax, %rax
	je	LBB0_3
## %bb.4:                               ##   in Loop: Header=BB0_2 Depth=1
	movq	(%rax), %r12
	movq	%r12, -48(%rbp)                 ## 8-byte Spill
	movq	%r12, %rdi
	callq	_amdgpu_ucode_print_sdma_hdr
	movl	4(%r12), %edi
	callq	_le32_to_cpu
                                        ## kill: def $eax killed $eax def $rax
	movq	%rax, -64(%rbp)                 ## 8-byte Spill
	leal	3(%rax), %r12d
	testl	%eax, %eax
	cmovnsl	%eax, %r12d
	movq	8(%r15), %rax
	movq	%rbx, -72(%rbp)                 ## 8-byte Spill
	movq	8(%rax,%rbx), %rax
	movq	(%rax), %r13
	movq	-48(%rbp), %rax                 ## 8-byte Reload
	movl	(%rax), %edi
	callq	_le32_to_cpu
	movl	%eax, %ebx
	movq	_mmSDMA0_UCODE_ADDR@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r15, %rdi
	movq	%r14, -48(%rbp)                 ## 8-byte Spill
	movl	%r14d, %esi
	callq	_sdma_v5_0_get_reg_offset
	movl	%eax, %edi
	xorl	%esi, %esi
	callq	_WREG32
	cmpl	$4, -64(%rbp)                   ## 4-byte Folded Reload
	jl	LBB0_10
## %bb.5:                               ##   in Loop: Header=BB0_2 Depth=1
	sarl	$2, %r12d
	addl	%ebx, %r13d
	xorl	%r14d, %r14d
	xorl	%r15d, %r15d
	jmp	LBB0_6
	.p2align	4, 0x90
LBB0_9:                                 ##   in Loop: Header=BB0_6 Depth=2
	movq	_mmSDMA0_UCODE_DATA@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	movq	-48(%rbp), %rsi                 ## 8-byte Reload
                                        ## kill: def $esi killed $esi killed $rsi
	callq	_sdma_v5_0_get_reg_offset
	movl	%eax, %ebx
	movl	%r13d, %edi
	callq	_le32_to_cpup
	movl	%ebx, %edi
	movl	%eax, %esi
	callq	_WREG32
	incl	%r15d
	decl	%r14d
	addl	$4, %r13d
	decl	%r12d
	je	LBB0_10
LBB0_6:                                 ##   Parent Loop BB0_2 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	movq	_amdgpu_emu_mode@GOTPCREL(%rip), %rax
	cmpl	$1, (%rax)
	jne	LBB0_9
## %bb.7:                               ##   in Loop: Header=BB0_6 Depth=2
	movl	%r15d, %eax
	imulq	$274877907, %rax, %rax          ## imm = 0x10624DD3
	shrq	$37, %rax
	imull	$500, %eax, %eax                ## imm = 0x1F4
	addl	%r14d, %eax
	jne	LBB0_9
## %bb.8:                               ##   in Loop: Header=BB0_6 Depth=2
	movl	$1, %edi
	callq	_msleep
	jmp	LBB0_9
LBB0_11:
	xorl	%r14d, %r14d
	jmp	LBB0_12
LBB0_3:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%r14d, %r14d
	subl	(%rax), %r14d
LBB0_12:
	movl	%r14d, %eax
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_mmSDMA0_UCODE_ADDR,4,2         ## @mmSDMA0_UCODE_ADDR
	.comm	_amdgpu_emu_mode,4,2            ## @amdgpu_emu_mode
	.comm	_mmSDMA0_UCODE_DATA,4,2         ## @mmSDMA0_UCODE_DATA
	.no_dead_strip	_sdma_v5_0_load_microcode
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function sdma_v5_0_load_microcode
_sdma_v5_0_load_microcode:              ; @sdma_v5_0_load_microcode
	.cfi_startproc
; %bb.0:
	stp	x28, x27, [sp, #-96]!           ; 16-byte Folded Spill
	.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
	.cfi_offset w27, -88
	.cfi_offset w28, -96
	mov	x19, x0
	mov	w1, #0
	bl	_sdma_v5_0_enable
	ldr	w8, [x19]
	cmp	w8, #1
	b.lt	LBB0_9
; %bb.1:
	mov	x20, #0
Lloh0:
	adrp	x23, _mmSDMA0_UCODE_ADDR@GOTPAGE
Lloh1:
	ldr	x23, [x23, _mmSDMA0_UCODE_ADDR@GOTPAGEOFF]
	mov	w25, #500
Lloh2:
	adrp	x26, _amdgpu_emu_mode@GOTPAGE
Lloh3:
	ldr	x26, [x26, _amdgpu_emu_mode@GOTPAGEOFF]
Lloh4:
	adrp	x27, _mmSDMA0_UCODE_DATA@GOTPAGE
Lloh5:
	ldr	x27, [x27, _mmSDMA0_UCODE_DATA@GOTPAGEOFF]
	b	LBB0_3
LBB0_2:                                 ;   in Loop: Header=BB0_3 Depth=1
Lloh6:
	adrp	x23, _mmSDMA0_UCODE_ADDR@GOTPAGE
Lloh7:
	ldr	x23, [x23, _mmSDMA0_UCODE_ADDR@GOTPAGEOFF]
	ldr	w2, [x23]
	mov	x0, x19
	mov	x1, x20
	bl	_sdma_v5_0_get_reg_offset
	ldr	x8, [x19, #8]
	lsl	x9, x20, #4
	ldr	w1, [x8, x9]
	bl	_WREG32
	add	x20, x20, #1
	ldrsw	x8, [x19]
	cmp	x20, x8
	b.ge	LBB0_9
LBB0_3:                                 ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_7 Depth 2
	ldr	x8, [x19, #8]
	add	x8, x8, x20, lsl #4
	ldr	x8, [x8, #8]
	cbz	x8, LBB0_10
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=1
	ldr	x21, [x8]
	mov	x0, x21
	bl	_amdgpu_ucode_print_sdma_hdr
	ldr	w0, [x21, #4]
	bl	_le32_to_cpu
	mov	x22, x0
	add	w8, w0, #3
	cmp	w0, #0
	csel	w24, w8, w0, lt
	ldr	x8, [x19, #8]
	add	x8, x8, x20, lsl #4
	ldr	x8, [x8, #8]
	ldr	x28, [x8]
	ldr	w0, [x21]
	bl	_le32_to_cpu
	mov	x21, x0
	ldr	w2, [x23]
	mov	x0, x19
	mov	x1, x20
	bl	_sdma_v5_0_get_reg_offset
	mov	w1, #0
	bl	_WREG32
	cmp	w22, #4
	b.lt	LBB0_2
; %bb.5:                                ;   in Loop: Header=BB0_3 Depth=1
	mov	x8, x28
	mov	w28, #0
	mov	w23, #0
	asr	w24, w24, #2
	add	w21, w8, w21
	b	LBB0_7
LBB0_6:                                 ;   in Loop: Header=BB0_7 Depth=2
	ldr	w2, [x27]
	mov	x0, x19
	mov	x1, x20
	bl	_sdma_v5_0_get_reg_offset
	mov	x22, x0
	mov	x0, x21
	bl	_le32_to_cpup
	mov	x1, x0
	mov	x0, x22
	bl	_WREG32
	add	w23, w23, #1
	sub	w28, w28, #1
	add	w21, w21, #4
	sub	w24, w24, #1
	cbz	w24, LBB0_2
LBB0_7:                                 ;   Parent Loop BB0_3 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	mov	w8, #19923
	movk	w8, #4194, lsl #16
	umull	x8, w23, w8
	lsr	x8, x8, #37
	madd	w8, w8, w25, w28
	ldr	w9, [x26]
	cmp	w9, #1
	ccmp	w8, #0, #0, eq
	b.ne	LBB0_6
; %bb.8:                                ;   in Loop: Header=BB0_7 Depth=2
	mov	w0, #1
	bl	_msleep
	b	LBB0_6
LBB0_9:
	mov	w0, #0
	b	LBB0_11
LBB0_10:
Lloh8:
	adrp	x8, _EINVAL@GOTPAGE
Lloh9:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh10:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_11:
	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
	ldp	x28, x27, [sp], #96             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.cfi_endproc
                                        ; -- End function
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_mmSDMA0_UCODE_ADDR,4,2         ; @mmSDMA0_UCODE_ADDR
	.comm	_amdgpu_emu_mode,4,2            ; @amdgpu_emu_mode
	.comm	_mmSDMA0_UCODE_DATA,4,2         ; @mmSDMA0_UCODE_DATA
	.no_dead_strip	_sdma_v5_0_load_microcode
.subsections_via_symbols
