	.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	$56, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsi, -80(%rbp)                 ## 8-byte Spill
	movq	%rdi, %r15
	movq	%rsp, %r12
	movq	___stack_chk_guard@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rax, -48(%rbp)
	movq	_FW_BULKOUT_SIZE@GOTPCREL(%rip), %r14
	movl	(%r14), %eax
	addl	$2, %eax
	shlq	$2, %rax
	callq	____chkstk_darwin
	addq	$15, %rax
	andq	$-16, %rax
	subq	%rax, %rsp
	movq	%rsp, %r13
	movq	_FW_CONFIG@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	-52(%rbp), %rdx
	movq	%r15, %rdi
	callq	_af9005_boot_packet
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_17
## %bb.1:
	movl	-52(%rbp), %esi
	cmpl	$1, %esi
	jne	LBB0_2
## %bb.3:
	movq	%r12, -72(%rbp)                 ## 8-byte Spill
	movq	-80(%rbp), %rdi                 ## 8-byte Reload
	movl	(%rdi), %eax
	movl	(%r14), %ecx
	cltd
	idivl	%ecx
                                        ## kill: def $eax killed $eax def $rax
	movzbl	%cl, %edx
	movl	%edx, (%r13)
	movzbl	%ch, %edx
	movl	%edx, 4(%r13)
	movq	%rax, -64(%rbp)                 ## 8-byte Spill
	testl	%eax, %eax
	jle	LBB0_9
## %bb.4:
	movq	%r13, %rax
	addq	$8, %rax
	movq	%rax, -88(%rbp)                 ## 8-byte Spill
	movq	-64(%rbp), %rax                 ## 8-byte Reload
	decl	%eax
	movl	%eax, -56(%rbp)                 ## 4-byte Spill
	xorl	%r12d, %r12d
	.p2align	4, 0x90
LBB0_5:                                 ## =>This Inner Loop Header: Depth=1
	movl	%ecx, %eax
	imull	%r12d, %eax
	movslq	%eax, %rsi
	addq	8(%rdi), %rsi
	movq	-88(%rbp), %rdi                 ## 8-byte Reload
	movl	%ecx, %edx
	callq	_memcpy
	leaq	L_.str.1(%rip), %rdi
	callq	_deb_fw
	movl	(%r14), %esi
	addl	$2, %esi
	movq	%r13, %rdi
	movq	_deb_fw@GOTPCREL(%rip), %rdx
	callq	_debug_dump
	movq	%r15, %rdi
	movl	$2, %esi
	callq	_usb_sndbulkpipe
	movl	(%r14), %ecx
	addl	$2, %ecx
	movq	%r15, %rdi
	movl	%eax, %esi
	movq	%r13, %rdx
	leaq	-92(%rbp), %r8
	movl	$1000, %r9d                     ## imm = 0x3E8
	callq	_usb_bulk_msg
	testl	%eax, %eax
	jne	LBB0_6
## %bb.7:                               ##   in Loop: Header=BB0_5 Depth=1
	cmpl	%r12d, -56(%rbp)                ## 4-byte Folded Reload
	movq	-80(%rbp), %rdi                 ## 8-byte Reload
	je	LBB0_9
## %bb.8:                               ##   in Loop: Header=BB0_5 Depth=1
	movl	(%r14), %ecx
	incl	%r12d
	jmp	LBB0_5
LBB0_2:
	leaq	L_.str(%rip), %rdi
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_err
	movq	_EIO@GOTPCREL(%rip), %rax
	subl	(%rax), %ebx
	jmp	LBB0_17
LBB0_9:
	movq	_FW_CONFIRM@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	-52(%rbp), %rdx
	movq	%r15, %rdi
	callq	_af9005_boot_packet
	movl	%eax, %ebx
	testl	%eax, %eax
	movq	-72(%rbp), %r12                 ## 8-byte Reload
	jne	LBB0_17
## %bb.10:
	movq	%r12, %r14
	movl	-52(%rbp), %edx
	movzbl	-64(%rbp), %esi                 ## 1-byte Folded Reload
	cmpl	%esi, %edx
	jne	LBB0_11
## %bb.12:
	movq	_FW_BOOT@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	-52(%rbp), %rdx
	movq	%r15, %rdi
	callq	_af9005_boot_packet
	movl	%eax, %ebx
	testl	%eax, %eax
	movq	%r14, %r12
	jne	LBB0_17
## %bb.13:
	movq	_FW_CONFIG@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	-52(%rbp), %rdx
	movq	%r15, %rdi
	callq	_af9005_boot_packet
	movl	%eax, %ebx
	movq	%r14, %r12
	testl	%eax, %eax
	jne	LBB0_17
## %bb.14:
	movl	-52(%rbp), %esi
	xorl	%ebx, %ebx
	cmpl	$2, %esi
	je	LBB0_17
## %bb.15:
	leaq	L_.str.4(%rip), %rdi
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_err
	jmp	LBB0_16
LBB0_6:
	movl	%eax, %ebx
	leaq	L_.str.2(%rip), %rdi
	movl	%r12d, %esi
	movl	%eax, %edx
	xorl	%eax, %eax
	callq	_err
	movq	-72(%rbp), %r12                 ## 8-byte Reload
	jmp	LBB0_17
LBB0_11:
	leaq	L_.str.3(%rip), %rdi
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_err
LBB0_16:
	movq	_EIO@GOTPCREL(%rip), %rax
	subl	(%rax), %ebx
	movq	%r14, %r12
LBB0_17:
	movq	%r12, %rsp
	movq	___stack_chk_guard@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	cmpq	-48(%rbp), %rax
	jne	LBB0_19
## %bb.18:
	movl	%ebx, %eax
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_19:
	callq	___stack_chk_fail
	.cfi_endproc
                                        ## -- End function
	.comm	_FW_BULKOUT_SIZE,4,2            ## @FW_BULKOUT_SIZE
	.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:
	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
	sub	sp, sp, #32
	mov	x20, x1
	mov	x19, x0
	mov	x22, sp
Lloh0:
	adrp	x8, ___stack_chk_guard@GOTPAGE
Lloh1:
	ldr	x8, [x8, ___stack_chk_guard@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
	stur	x8, [x29, #-88]
Lloh3:
	adrp	x28, _FW_BULKOUT_SIZE@GOTPAGE
Lloh4:
	ldr	x28, [x28, _FW_BULKOUT_SIZE@GOTPAGEOFF]
	ldr	w8, [x28]
	add	w8, w8, #2
	lsl	x8, x8, #2
	mov	x9, x8
Lloh5:
	adrp	x16, ___chkstk_darwin@GOTPAGE
Lloh6:
	ldr	x16, [x16, ___chkstk_darwin@GOTPAGEOFF]
	blr	x16
	mov	x9, sp
	add	x8, x8, #15
	and	x8, x8, #0x7fffffff0
	sub	x21, x9, x8
	mov	sp, x21
Lloh7:
	adrp	x8, _FW_CONFIG@GOTPAGE
Lloh8:
	ldr	x8, [x8, _FW_CONFIG@GOTPAGEOFF]
Lloh9:
	ldr	w1, [x8]
	sub	x2, x29, #96
	bl	_af9005_boot_packet
	mov	x26, x0
	cbnz	w0, LBB0_17
; %bb.1:
	ldur	w1, [x29, #-96]
	cmp	w1, #1
	b.ne	LBB0_7
; %bb.2:
	stur	x22, [x29, #-104]               ; 8-byte Folded Spill
	ldr	w8, [x20]
	ldr	w2, [x28]
	sdiv	w10, w8, w2
	and	w8, w2, #0xff
	ubfx	w9, w2, #8, #8
	stp	w8, w9, [x21]
	stur	w10, [x29, #-108]               ; 4-byte Folded Spill
	subs	w27, w10, #1
	b.lt	LBB0_10
; %bb.3:
	mov	w22, #0
	add	x23, x21, #8
Lloh10:
	adrp	x24, _deb_fw@GOTPAGE
Lloh11:
	ldr	x24, [x24, _deb_fw@GOTPAGEOFF]
Lloh12:
	adrp	x25, l_.str.1@PAGE
Lloh13:
	add	x25, x25, l_.str.1@PAGEOFF
LBB0_4:                                 ; =>This Inner Loop Header: Depth=1
	ldr	x8, [x20, #8]
	mul	w9, w2, w22
	add	x1, x8, w9, sxtw
	mov	x0, x23
	bl	_memcpy
	mov	x0, x25
	bl	_deb_fw
	ldr	w8, [x28]
	add	w1, w8, #2
	mov	x0, x21
	mov	x2, x24
	bl	_debug_dump
	mov	x0, x19
	mov	w1, #2
	bl	_usb_sndbulkpipe
	mov	x1, x0
	ldr	w8, [x28]
	add	w3, w8, #2
	sub	x4, x29, #92
	mov	x0, x19
	mov	x2, x21
	mov	w5, #1000
	bl	_usb_bulk_msg
	cbnz	w0, LBB0_16
; %bb.5:                                ;   in Loop: Header=BB0_4 Depth=1
	cmp	w27, w22
	b.eq	LBB0_10
; %bb.6:                                ;   in Loop: Header=BB0_4 Depth=1
	ldr	w2, [x28]
	add	w22, w22, #1
	b	LBB0_4
LBB0_7:
Lloh14:
	adrp	x0, l_.str@PAGE
Lloh15:
	add	x0, x0, l_.str@PAGEOFF
LBB0_8:
	bl	_err
LBB0_9:
Lloh16:
	adrp	x8, _EIO@GOTPAGE
Lloh17:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
Lloh18:
	ldr	w8, [x8]
	neg	w26, w8
	b	LBB0_17
LBB0_10:
Lloh19:
	adrp	x8, _FW_CONFIRM@GOTPAGE
Lloh20:
	ldr	x8, [x8, _FW_CONFIRM@GOTPAGEOFF]
Lloh21:
	ldr	w1, [x8]
	sub	x2, x29, #96
	mov	x0, x19
	bl	_af9005_boot_packet
	mov	x26, x0
	ldur	x22, [x29, #-104]               ; 8-byte Folded Reload
Lloh22:
	adrp	x20, _FW_CONFIG@GOTPAGE
Lloh23:
	ldr	x20, [x20, _FW_CONFIG@GOTPAGEOFF]
	cbnz	w0, LBB0_17
; %bb.11:
	ldur	w8, [x29, #-96]
	ldur	w9, [x29, #-108]                ; 4-byte Folded Reload
	and	w1, w9, #0xff
	cmp	w8, w1
	b.ne	LBB0_19
; %bb.12:
Lloh24:
	adrp	x8, _FW_BOOT@GOTPAGE
Lloh25:
	ldr	x8, [x8, _FW_BOOT@GOTPAGEOFF]
Lloh26:
	ldr	w1, [x8]
	sub	x2, x29, #96
	mov	x0, x19
	bl	_af9005_boot_packet
	mov	x26, x0
	cbnz	w0, LBB0_17
; %bb.13:
	ldr	w1, [x20]
	sub	x2, x29, #96
	mov	x0, x19
	bl	_af9005_boot_packet
	mov	x26, x0
	cbnz	w0, LBB0_17
; %bb.14:
	ldur	w1, [x29, #-96]
	cmp	w1, #2
	b.ne	LBB0_20
; %bb.15:
	mov	w26, #0
	b	LBB0_17
LBB0_16:
	mov	x26, x0
	str	x26, [sp, #-16]!
Lloh27:
	adrp	x0, l_.str.2@PAGE
Lloh28:
	add	x0, x0, l_.str.2@PAGEOFF
	mov	x1, x22
	bl	_err
	add	sp, sp, #16
	ldur	x22, [x29, #-104]               ; 8-byte Folded Reload
LBB0_17:
	mov	sp, x22
	ldur	x8, [x29, #-88]
Lloh29:
	adrp	x9, ___stack_chk_guard@GOTPAGE
Lloh30:
	ldr	x9, [x9, ___stack_chk_guard@GOTPAGEOFF]
Lloh31:
	ldr	x9, [x9]
	cmp	x9, x8
	b.ne	LBB0_21
; %bb.18:
	mov	x0, x26
	sub	sp, x29, #80
	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
LBB0_19:
	str	x8, [sp, #-16]!
Lloh32:
	adrp	x0, l_.str.3@PAGE
Lloh33:
	add	x0, x0, l_.str.3@PAGEOFF
	bl	_err
	add	sp, sp, #16
	b	LBB0_9
LBB0_20:
Lloh34:
	adrp	x0, l_.str.4@PAGE
Lloh35:
	add	x0, x0, l_.str.4@PAGEOFF
	b	LBB0_8
LBB0_21:
	bl	___stack_chk_fail
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh12, Lloh13
	.loh AdrpLdrGot	Lloh10, Lloh11
	.loh AdrpAdd	Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGot	Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.loh AdrpAdd	Lloh27, Lloh28
	.loh AdrpLdrGotLdr	Lloh29, Lloh30, Lloh31
	.loh AdrpAdd	Lloh32, Lloh33
	.loh AdrpAdd	Lloh34, Lloh35
	.cfi_endproc
                                        ; -- End function
	.comm	_FW_BULKOUT_SIZE,4,2            ; @FW_BULKOUT_SIZE
	.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
