	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_rtl8821ae_download_fw          ## -- Begin function rtl8821ae_download_fw
	.p2align	4, 0x90
_rtl8821ae_download_fw:                 ## @rtl8821ae_download_fw
	.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, %r15d
	movq	%rdi, %r12
	callq	_rtl_priv
	movq	%rax, %rbx
	movq	%r12, %rdi
	callq	_rtl_priv
	movq	%rax, %rdi
	callq	_rtl_hal
	movq	%rax, %r13
	movl	(%rax), %r14d
	movq	(%rbx), %rax
	movq	(%rax), %rax
	movq	_HAL_DEF_WOWLAN@GOTPCREL(%rip), %rcx
	movl	(%rcx), %esi
	leaq	-48(%rbp), %rdx
	movq	%r12, %rdi
	callq	*(%rax)
	cmpl	$0, -48(%rbp)
	je	LBB0_2
## %bb.1:
	movq	%rbx, %rdi
	callq	__rtl8821ae_wait_for_h2c_cmd_finish
LBB0_2:
	testl	%r15d, %r15d
	je	LBB0_5
## %bb.3:
	movq	56(%r13), %r15
	testq	%r15, %r15
	je	LBB0_14
## %bb.4:
	movl	%r14d, -44(%rbp)                ## 4-byte Spill
	movq	%rbx, -64(%rbp)                 ## 8-byte Spill
	leaq	56(%r13), %rbx
	movl	4(%r15), %edi
	callq	_le16_to_cpu
	movq	%rax, 40(%r13)
	movl	8(%r15), %eax
	movl	%eax, 32(%r13)
	movq	%r13, %rax
	addq	$48, %rax
	leaq	L_.str.1(%rip), %r8
	jmp	LBB0_7
LBB0_5:
	movq	24(%r13), %r15
	testq	%r15, %r15
	je	LBB0_14
## %bb.6:
	movl	%r14d, -44(%rbp)                ## 4-byte Spill
	movq	%rbx, -64(%rbp)                 ## 8-byte Spill
	leaq	24(%r13), %rbx
	movl	4(%r15), %edi
	callq	_le16_to_cpu
	movq	%rax, 40(%r13)
	movl	8(%r15), %eax
	movl	%eax, 32(%r13)
	movq	%r13, %rax
	addq	$16, %rax
	leaq	L_.str.2(%rip), %r8
LBB0_7:
	movq	(%rax), %r14
	movq	(%rbx), %rax
	movq	%rax, -56(%rbp)                 ## 8-byte Spill
	movq	_COMP_FW@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_DBG_DMESG@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	leaq	L_.str(%rip), %rcx
	movq	-64(%rbp), %rbx                 ## 8-byte Reload
	movq	%rbx, %rdi
	movq	%r14, %r9
	xorl	%eax, %eax
	callq	_RT_TRACE
	movq	%r15, %rdi
	callq	_IS_FW_HEADER_EXIST_8812
	testq	%rax, %rax
	jne	LBB0_9
## %bb.8:
	movq	%r15, %rdi
	callq	_IS_FW_HEADER_EXIST_8821
	testq	%rax, %rax
	je	LBB0_16
LBB0_9:
	movq	_COMP_FW@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_DBG_DMESG@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movl	(%r15), %r9d
	movl	4(%r15), %r8d
	leaq	L_.str.3(%rip), %rcx
	movq	%rbx, %r15
	movq	%rbx, %rdi
	xorl	%eax, %eax
	callq	_RT_TRACE
	movq	-56(%rbp), %rbx                 ## 8-byte Reload
	addq	$48, %rbx
	addq	$-12, %r14
	cmpq	$0, 8(%r13)
	je	LBB0_12
LBB0_10:
	movq	_REG_MCUFWDL@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r15, %rdi
	callq	_rtl_read_byte
	movq	%rbx, %r13
	movl	%eax, %ebx
	movl	$7, %edi
	callq	_BIT
	testl	%ebx, %eax
	movq	%r13, %rbx
	je	LBB0_12
## %bb.11:
	movq	_REG_MCUFWDL@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r15, %rdi
	xorl	%edx, %edx
	callq	_rtl_write_byte
	movq	%r12, %rdi
	callq	_rtl8821ae_firmware_selfreset
LBB0_12:
	movq	%r12, %rdi
	movl	$1, %esi
	callq	__rtl8821ae_enable_fw_download
	movq	%r12, %rdi
	movl	-44(%rbp), %esi                 ## 4-byte Reload
	movq	%rbx, %rdx
	movq	%r14, %rcx
	callq	__rtl8821ae_write_fw
	xorl	%ebx, %ebx
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	__rtl8821ae_enable_fw_download
	movq	%r12, %rdi
	callq	__rtl8821ae_fw_free_to_go
	testl	%eax, %eax
	leaq	L_.str.5(%rip), %rax
	leaq	L_.str.4(%rip), %rcx
	cmoveq	%rax, %rcx
	movq	_COMP_ERR@GOTPCREL(%rip), %rax
	cmoveq	_COMP_FW@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_DBG_DMESG@GOTPCREL(%rip), %rax
	cmoveq	_DBG_LOUD@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r15, %rdi
	xorl	%eax, %eax
	callq	_RT_TRACE
	jmp	LBB0_15
LBB0_14:
	movl	$1, %ebx
LBB0_15:
	movl	%ebx, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_16:
	movq	%rbx, %r15
	movq	-56(%rbp), %rbx                 ## 8-byte Reload
	cmpq	$0, 8(%r13)
	jne	LBB0_10
	jmp	LBB0_12
	.cfi_endproc
                                        ## -- End function
	.comm	_HAL_DEF_WOWLAN,4,2             ## @HAL_DEF_WOWLAN
	.comm	_COMP_FW,4,2                    ## @COMP_FW
	.comm	_DBG_DMESG,4,2                  ## @DBG_DMESG
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"%s Firmware SIZE %d\n"

L_.str.1:                               ## @.str.1
	.asciz	"Wowlan"

L_.str.2:                               ## @.str.2
	.asciz	"Normal"

L_.str.3:                               ## @.str.3
	.asciz	"Firmware Version(%d), Signature(%#x)\n"

	.comm	_REG_MCUFWDL,4,2                ## @REG_MCUFWDL
	.comm	_COMP_ERR,4,2                   ## @COMP_ERR
L_.str.4:                               ## @.str.4
	.asciz	"Firmware is not ready to run!\n"

	.comm	_DBG_LOUD,4,2                   ## @DBG_LOUD
L_.str.5:                               ## @.str.5
	.asciz	"Firmware is ready to run!\n"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_rtl8821ae_download_fw          ; -- Begin function rtl8821ae_download_fw
	.p2align	2
_rtl8821ae_download_fw:                 ; @rtl8821ae_download_fw
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #128
	.cfi_def_cfa_offset 128
	stp	x28, x27, [sp, #32]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #48]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #64]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #80]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #96]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #112]            ; 16-byte Folded Spill
	add	x29, sp, #112
	.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	x23, x1
	mov	x20, x0
	bl	_rtl_priv
	mov	x19, x0
	mov	x0, x20
	bl	_rtl_priv
	bl	_rtl_hal
	mov	x22, x0
	ldr	w21, [x0]
	ldr	x8, [x19]
	ldr	x8, [x8]
	ldr	x8, [x8]
Lloh0:
	adrp	x9, _HAL_DEF_WOWLAN@GOTPAGE
Lloh1:
	ldr	x9, [x9, _HAL_DEF_WOWLAN@GOTPAGEOFF]
Lloh2:
	ldr	w1, [x9]
	add	x2, sp, #28
	mov	x0, x20
	blr	x8
	ldr	w8, [sp, #28]
	cbz	w8, LBB0_2
; %bb.1:
	mov	x0, x19
	bl	__rtl8821ae_wait_for_h2c_cmd_finish
LBB0_2:
	mov	x24, x22
	cbz	w23, LBB0_5
; %bb.3:
	ldr	x25, [x24, #56]!
	cbz	x25, LBB0_14
; %bb.4:
	ldr	w0, [x25, #4]
	bl	_le16_to_cpu
	str	x0, [x22, #40]
	ldr	w8, [x25, #8]
	str	w8, [x22, #32]
	add	x9, x22, #48
Lloh3:
	adrp	x8, l_.str.1@PAGE
Lloh4:
	add	x8, x8, l_.str.1@PAGEOFF
	b	LBB0_7
LBB0_5:
	ldr	x25, [x24, #24]!
	cbz	x25, LBB0_14
; %bb.6:
	ldr	w0, [x25, #4]
	bl	_le16_to_cpu
	str	x0, [x22, #40]
	ldr	w8, [x25, #8]
	str	w8, [x22, #32]
	add	x9, x22, #16
Lloh5:
	adrp	x8, l_.str.2@PAGE
Lloh6:
	add	x8, x8, l_.str.2@PAGEOFF
LBB0_7:
	ldr	x23, [x9]
	ldr	x24, [x24]
Lloh7:
	adrp	x27, _COMP_FW@GOTPAGE
Lloh8:
	ldr	x27, [x27, _COMP_FW@GOTPAGEOFF]
	ldr	w1, [x27]
Lloh9:
	adrp	x26, _DBG_DMESG@GOTPAGE
Lloh10:
	ldr	x26, [x26, _DBG_DMESG@GOTPAGEOFF]
	ldr	w2, [x26]
	stp	x8, x23, [sp]
Lloh11:
	adrp	x3, l_.str@PAGE
Lloh12:
	add	x3, x3, l_.str@PAGEOFF
	mov	x0, x19
	bl	_RT_TRACE
	mov	x0, x25
	bl	_IS_FW_HEADER_EXIST_8812
	cbnz	x0, LBB0_9
; %bb.8:
	mov	x0, x25
	bl	_IS_FW_HEADER_EXIST_8821
	cbz	x0, LBB0_10
LBB0_9:
	ldr	w1, [x27]
	ldr	w2, [x26]
	ldp	w9, w8, [x25]
	stp	x8, x9, [sp]
Lloh13:
	adrp	x3, l_.str.3@PAGE
Lloh14:
	add	x3, x3, l_.str.3@PAGEOFF
	mov	x0, x19
	bl	_RT_TRACE
	add	x24, x24, #48
	sub	x23, x23, #12
LBB0_10:
	ldr	x8, [x22, #8]
	cbz	x8, LBB0_13
; %bb.11:
Lloh15:
	adrp	x25, _REG_MCUFWDL@GOTPAGE
Lloh16:
	ldr	x25, [x25, _REG_MCUFWDL@GOTPAGEOFF]
	ldr	w1, [x25]
	mov	x0, x19
	bl	_rtl_read_byte
	mov	x22, x0
	mov	w0, #7
	bl	_BIT
	tst	w0, w22
	b.eq	LBB0_13
; %bb.12:
	ldr	w1, [x25]
	mov	x0, x19
	mov	w2, #0
	bl	_rtl_write_byte
	mov	x0, x20
	bl	_rtl8821ae_firmware_selfreset
LBB0_13:
	mov	x0, x20
	mov	w1, #1
	bl	__rtl8821ae_enable_fw_download
	mov	x0, x20
	mov	x1, x21
	mov	x2, x24
	mov	x3, x23
	bl	__rtl8821ae_write_fw
	mov	x0, x20
	mov	w1, #0
	bl	__rtl8821ae_enable_fw_download
	mov	x0, x20
	bl	__rtl8821ae_fw_free_to_go
Lloh17:
	adrp	x8, l_.str.4@PAGE
Lloh18:
	add	x8, x8, l_.str.4@PAGEOFF
Lloh19:
	adrp	x9, l_.str.5@PAGE
Lloh20:
	add	x9, x9, l_.str.5@PAGEOFF
	cmp	w0, #0
	csel	x3, x9, x8, eq
Lloh21:
	adrp	x8, _COMP_ERR@GOTPAGE
Lloh22:
	ldr	x8, [x8, _COMP_ERR@GOTPAGEOFF]
	csel	x8, x27, x8, eq
	ldr	w1, [x8]
Lloh23:
	adrp	x8, _DBG_LOUD@GOTPAGE
Lloh24:
	ldr	x8, [x8, _DBG_LOUD@GOTPAGEOFF]
	csel	x8, x8, x26, eq
	ldr	w2, [x8]
	mov	x0, x19
	bl	_RT_TRACE
	mov	w0, #0
	b	LBB0_15
LBB0_14:
	mov	w0, #1
LBB0_15:
	ldp	x29, x30, [sp, #112]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #96]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #80]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #64]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #48]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #32]             ; 16-byte Folded Reload
	add	sp, sp, #128
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh3, Lloh4
	.loh AdrpAdd	Lloh5, Lloh6
	.loh AdrpAdd	Lloh11, Lloh12
	.loh AdrpLdrGot	Lloh9, Lloh10
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpAdd	Lloh13, Lloh14
	.loh AdrpLdrGot	Lloh15, Lloh16
	.loh AdrpLdrGot	Lloh23, Lloh24
	.loh AdrpLdrGot	Lloh21, Lloh22
	.loh AdrpAdd	Lloh19, Lloh20
	.loh AdrpAdd	Lloh17, Lloh18
	.cfi_endproc
                                        ; -- End function
	.comm	_HAL_DEF_WOWLAN,4,2             ; @HAL_DEF_WOWLAN
	.comm	_COMP_FW,4,2                    ; @COMP_FW
	.comm	_DBG_DMESG,4,2                  ; @DBG_DMESG
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"%s Firmware SIZE %d\n"

l_.str.1:                               ; @.str.1
	.asciz	"Wowlan"

l_.str.2:                               ; @.str.2
	.asciz	"Normal"

l_.str.3:                               ; @.str.3
	.asciz	"Firmware Version(%d), Signature(%#x)\n"

	.comm	_REG_MCUFWDL,4,2                ; @REG_MCUFWDL
	.comm	_COMP_ERR,4,2                   ; @COMP_ERR
l_.str.4:                               ; @.str.4
	.asciz	"Firmware is not ready to run!\n"

	.comm	_DBG_LOUD,4,2                   ; @DBG_LOUD
l_.str.5:                               ; @.str.5
	.asciz	"Firmware is ready to run!\n"

.subsections_via_symbols
