	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function af9005_download_firmware
_af9005_download_firmware:              ## @af9005_download_firmware
	.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	%rsi, -56(%rbp)                 ## 8-byte Spill
	movq	%rdi, %r14
	movq	_FW_BULKOUT_SIZE@GOTPCREL(%rip), %r15
	movl	(%r15), %edi
	addl	$2, %edi
	movq	_GFP_KERNEL@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_kmalloc
	testq	%rax, %rax
	je	LBB0_1
## %bb.2:
	movq	%rax, %r13
	movq	_FW_CONFIG@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	(%r15), %r8d
	addl	$2, %r8d
	leaq	-44(%rbp), %rdx
	movq	%r14, %rdi
	movq	%r13, %rcx
	callq	_af9005_boot_packet
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_19
## %bb.3:
	movl	-44(%rbp), %esi
	cmpl	$1, %esi
	jne	LBB0_4
## %bb.5:
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	movl	(%rax), %eax
	movl	(%r15), %ecx
	cltd
	idivl	%ecx
	movzbl	%cl, %ecx
	movl	%ecx, (%r13)
	movl	(%r15), %ebx
	movzbl	%bh, %ecx
	movl	%ecx, 4(%r13)
	movl	%eax, -48(%rbp)                 ## 4-byte Spill
	testl	%eax, %eax
	jle	LBB0_10
## %bb.6:
	movq	%r13, %rax
	addq	$8, %rax
	movq	%rax, -64(%rbp)                 ## 8-byte Spill
	xorl	%r12d, %r12d
	.p2align	4, 0x90
LBB0_7:                                 ## =>This Inner Loop Header: Depth=1
	movl	%ebx, %ecx
	imull	%r12d, %ecx
	movslq	%ecx, %rsi
	movq	-56(%rbp), %rcx                 ## 8-byte Reload
	addq	8(%rcx), %rsi
	movq	-64(%rbp), %rdi                 ## 8-byte Reload
	movl	%ebx, %edx
	callq	_memcpy
	leaq	L_.str.1(%rip), %rdi
	callq	_deb_fw
	movl	(%r15), %esi
	addl	$2, %esi
	movq	%r13, %rdi
	movq	_deb_fw@GOTPCREL(%rip), %rdx
	callq	_debug_dump
	movq	%r14, %rdi
	movl	$2, %esi
	callq	_usb_sndbulkpipe
	movl	(%r15), %ecx
	addl	$2, %ecx
	movq	%r14, %rdi
	movl	%eax, %esi
	movq	%r13, %rdx
	leaq	-68(%rbp), %r8
	movl	$1000, %r9d                     ## imm = 0x3E8
	callq	_usb_bulk_msg
	testl	%eax, %eax
	jne	LBB0_8
## %bb.9:                               ##   in Loop: Header=BB0_7 Depth=1
	incl	%r12d
	movl	(%r15), %ebx
	cmpl	%r12d, -48(%rbp)                ## 4-byte Folded Reload
	jne	LBB0_7
LBB0_10:
	movq	_FW_CONFIRM@GOTPCREL(%rip), %rcx
	movl	(%rcx), %esi
	addl	$2, %ebx
	leaq	-44(%rbp), %rdx
	movq	%r14, %rdi
	movq	%r13, %rcx
	movl	%ebx, %r8d
	callq	_af9005_boot_packet
	movl	%eax, %ebx
	testl	%eax, %eax
	movq	_FW_CONFIG@GOTPCREL(%rip), %r12
	jne	LBB0_19
## %bb.11:
	movl	-44(%rbp), %edx
	movzbl	-48(%rbp), %esi                 ## 1-byte Folded Reload
	cmpl	%esi, %edx
	jne	LBB0_12
## %bb.13:
	movq	_FW_BOOT@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	(%r15), %r8d
	addl	$2, %r8d
	leaq	-44(%rbp), %rdx
	movq	%r14, %rdi
	movq	%r13, %rcx
	callq	_af9005_boot_packet
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_19
## %bb.14:
	movl	(%r12), %esi
	movl	(%r15), %r8d
	addl	$2, %r8d
	leaq	-44(%rbp), %rdx
	movq	%r14, %rdi
	movq	%r13, %rcx
	callq	_af9005_boot_packet
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_19
## %bb.15:
	movl	-44(%rbp), %esi
	cmpl	$2, %esi
	je	LBB0_19
## %bb.16:
	leaq	L_.str.4(%rip), %rdi
	jmp	LBB0_17
LBB0_1:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_20
LBB0_4:
	leaq	L_.str(%rip), %rdi
LBB0_17:
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_err
LBB0_18:
	movq	_EIO@GOTPCREL(%rip), %rax
	subl	(%rax), %ebx
	jmp	LBB0_19
LBB0_8:
	movl	%eax, %ebx
	leaq	L_.str.2(%rip), %rdi
	movl	%r12d, %esi
	movl	%eax, %edx
	xorl	%eax, %eax
	callq	_err
LBB0_19:
	movq	%r13, %rdi
	callq	_kfree
LBB0_20:
	movl	%ebx, %eax
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_12:
	leaq	L_.str.3(%rip), %rdi
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_err
	jmp	LBB0_18
	.cfi_endproc
                                        ## -- End function
	.comm	_FW_BULKOUT_SIZE,4,2            ## @FW_BULKOUT_SIZE
	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.comm	_FW_CONFIG,4,2                  ## @FW_CONFIG
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"before downloading firmware, FW_CONFIG expected 0x01, received 0x%x"

	.comm	_EIO,4,2                        ## @EIO
L_.str.1:                               ## @.str.1
	.asciz	">>> "

L_.str.2:                               ## @.str.2
	.asciz	"firmware download failed at packet %d with code %d"

	.comm	_FW_CONFIRM,4,2                 ## @FW_CONFIRM
L_.str.3:                               ## @.str.3
	.asciz	"after downloading firmware, FW_CONFIRM expected 0x%x, received 0x%x"

	.comm	_FW_BOOT,4,2                    ## @FW_BOOT
L_.str.4:                               ## @.str.4
	.asciz	"after downloading firmware, FW_CONFIG expected 0x02, received 0x%x"

	.no_dead_strip	_af9005_download_firmware
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function af9005_download_firmware
_af9005_download_firmware:              ; @af9005_download_firmware
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x28, x27, [sp, #16]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.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	x21, x1
	mov	x20, x0
Lloh0:
	adrp	x27, _FW_BULKOUT_SIZE@GOTPAGE
Lloh1:
	ldr	x27, [x27, _FW_BULKOUT_SIZE@GOTPAGEOFF]
	ldr	w8, [x27]
	add	w0, w8, #2
Lloh2:
	adrp	x8, _GFP_KERNEL@GOTPAGE
Lloh3:
	ldr	x8, [x8, _GFP_KERNEL@GOTPAGEOFF]
Lloh4:
	ldr	w1, [x8]
	bl	_kmalloc
	cbz	x0, LBB0_13
; %bb.1:
	mov	x19, x0
Lloh5:
	adrp	x8, _FW_CONFIG@GOTPAGE
Lloh6:
	ldr	x8, [x8, _FW_CONFIG@GOTPAGEOFF]
Lloh7:
	ldr	w1, [x8]
	ldr	w8, [x27]
	add	w4, w8, #2
	add	x2, sp, #8
	mov	x0, x20
	mov	x3, x19
	bl	_af9005_boot_packet
	mov	x23, x0
	cbnz	w0, LBB0_17
; %bb.2:
	ldr	w1, [sp, #8]
	cmp	w1, #1
	b.ne	LBB0_14
; %bb.3:
	ldr	w8, [x21]
	ldr	w9, [x27]
	sdiv	w28, w8, w9
	and	w8, w9, #0xff
	str	w8, [x19]
	ldr	w2, [x27]
	ubfx	w8, w2, #8, #8
	str	w8, [x19, #4]
	cmp	w28, #1
	b.lt	LBB0_7
; %bb.4:
	mov	w22, #0
	add	x24, x19, #8
Lloh8:
	adrp	x25, _deb_fw@GOTPAGE
Lloh9:
	ldr	x25, [x25, _deb_fw@GOTPAGEOFF]
Lloh10:
	adrp	x26, l_.str.1@PAGE
Lloh11:
	add	x26, x26, l_.str.1@PAGEOFF
LBB0_5:                                 ; =>This Inner Loop Header: Depth=1
	ldr	x8, [x21, #8]
	mul	w9, w2, w22
	add	x1, x8, w9, sxtw
	mov	x0, x24
	bl	_memcpy
	mov	x0, x26
	bl	_deb_fw
	ldr	w8, [x27]
	add	w1, w8, #2
	mov	x0, x19
	mov	x2, x25
	bl	_debug_dump
	mov	x0, x20
	mov	w1, #2
	bl	_usb_sndbulkpipe
	mov	x1, x0
	ldr	w8, [x27]
	add	w3, w8, #2
	add	x4, sp, #12
	mov	x0, x20
	mov	x2, x19
	mov	w5, #1000
	bl	_usb_bulk_msg
	cbnz	w0, LBB0_16
; %bb.6:                                ;   in Loop: Header=BB0_5 Depth=1
	add	w22, w22, #1
	ldr	w2, [x27]
	cmp	w28, w22
	b.ne	LBB0_5
LBB0_7:
Lloh12:
	adrp	x8, _FW_CONFIRM@GOTPAGE
Lloh13:
	ldr	x8, [x8, _FW_CONFIRM@GOTPAGEOFF]
Lloh14:
	ldr	w1, [x8]
	add	w4, w2, #2
	add	x2, sp, #8
	mov	x0, x20
	mov	x3, x19
	bl	_af9005_boot_packet
	mov	x23, x0
Lloh15:
	adrp	x21, _FW_CONFIG@GOTPAGE
Lloh16:
	ldr	x21, [x21, _FW_CONFIG@GOTPAGEOFF]
	cbnz	w0, LBB0_17
; %bb.8:
	ldr	w8, [sp, #8]
	and	w1, w28, #0xff
	cmp	w8, w1
	b.ne	LBB0_19
; %bb.9:
Lloh17:
	adrp	x8, _FW_BOOT@GOTPAGE
Lloh18:
	ldr	x8, [x8, _FW_BOOT@GOTPAGEOFF]
Lloh19:
	ldr	w1, [x8]
	ldr	w8, [x27]
	add	w4, w8, #2
	add	x2, sp, #8
	mov	x0, x20
	mov	x3, x19
	bl	_af9005_boot_packet
	mov	x23, x0
	cbnz	w0, LBB0_17
; %bb.10:
	ldr	w1, [x21]
	ldr	w8, [x27]
	add	w4, w8, #2
	add	x2, sp, #8
	mov	x0, x20
	mov	x3, x19
	bl	_af9005_boot_packet
	mov	x23, x0
	cbnz	w0, LBB0_17
; %bb.11:
	ldr	w1, [sp, #8]
	cmp	w1, #2
	b.eq	LBB0_17
; %bb.12:
Lloh20:
	adrp	x0, l_.str.4@PAGE
Lloh21:
	add	x0, x0, l_.str.4@PAGEOFF
	b	LBB0_15
LBB0_13:
Lloh22:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh23:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh24:
	ldr	w8, [x8]
	neg	w23, w8
	b	LBB0_18
LBB0_14:
Lloh25:
	adrp	x0, l_.str@PAGE
Lloh26:
	add	x0, x0, l_.str@PAGEOFF
LBB0_15:
	bl	_err
Lloh27:
	adrp	x8, _EIO@GOTPAGE
Lloh28:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
Lloh29:
	ldr	w8, [x8]
	neg	w23, w8
	b	LBB0_17
LBB0_16:
	mov	x23, x0
	str	x23, [sp]
Lloh30:
	adrp	x0, l_.str.2@PAGE
Lloh31:
	add	x0, x0, l_.str.2@PAGEOFF
	mov	x1, x22
	bl	_err
LBB0_17:
	mov	x0, x19
	bl	_kfree
LBB0_18:
	mov	x0, x23
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
LBB0_19:
	str	x8, [sp]
Lloh32:
	adrp	x0, l_.str.3@PAGE
Lloh33:
	add	x0, x0, l_.str.3@PAGEOFF
	b	LBB0_15
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpAdd	Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpAdd	Lloh20, Lloh21
	.loh AdrpLdrGotLdr	Lloh22, Lloh23, Lloh24
	.loh AdrpAdd	Lloh25, Lloh26
	.loh AdrpLdrGotLdr	Lloh27, Lloh28, Lloh29
	.loh AdrpAdd	Lloh30, Lloh31
	.loh AdrpAdd	Lloh32, Lloh33
	.cfi_endproc
                                        ; -- End function
	.comm	_FW_BULKOUT_SIZE,4,2            ; @FW_BULKOUT_SIZE
	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.comm	_FW_CONFIG,4,2                  ; @FW_CONFIG
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"before downloading firmware, FW_CONFIG expected 0x01, received 0x%x"

	.comm	_EIO,4,2                        ; @EIO
l_.str.1:                               ; @.str.1
	.asciz	">>> "

l_.str.2:                               ; @.str.2
	.asciz	"firmware download failed at packet %d with code %d"

	.comm	_FW_CONFIRM,4,2                 ; @FW_CONFIRM
l_.str.3:                               ; @.str.3
	.asciz	"after downloading firmware, FW_CONFIRM expected 0x%x, received 0x%x"

	.comm	_FW_BOOT,4,2                    ; @FW_BOOT
l_.str.4:                               ; @.str.4
	.asciz	"after downloading firmware, FW_CONFIG expected 0x02, received 0x%x"

	.no_dead_strip	_af9005_download_firmware
.subsections_via_symbols
