	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_t3_load_fw                     ## -- Begin function t3_load_fw
	.p2align	4, 0x90
_t3_load_fw:                            ## @t3_load_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
	testb	$3, %dl
	jne	LBB0_4
## %bb.1:
	movq	_FW_MIN_SIZE@GOTPCREL(%rip), %rax
	cmpl	%edx, (%rax)
	ja	LBB0_4
## %bb.2:
	movq	_FW_FLASH_BOOT_ADDR@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movq	_FW_VERS_ADDR@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	subl	%ecx, %eax
	addl	$8, %eax
	cmpl	%edx, %eax
	jae	LBB0_6
## %bb.3:
	movq	_EFBIG@GOTPCREL(%rip), %rax
	jmp	LBB0_5
LBB0_4:
	movq	_EINVAL@GOTPCREL(%rip), %rax
LBB0_5:
	xorl	%r12d, %r12d
	jmp	LBB0_11
LBB0_6:
	movq	%rdi, %r15
	xorl	%r12d, %r12d
	movl	$0, %r14d
	cmpl	$4, %edx
	jb	LBB0_10
## %bb.7:
	movq	%rsi, %rbx
	movq	%r15, -48(%rbp)                 ## 8-byte Spill
	sarl	$16, %ecx
	movl	%ecx, -56(%rbp)                 ## 4-byte Spill
	movl	%edx, -52(%rbp)                 ## 4-byte Spill
	movl	%edx, %r13d
	shrl	$2, %r13d
	xorl	%r15d, %r15d
	xorl	%r14d, %r14d
	.p2align	4, 0x90
LBB0_8:                                 ## =>This Inner Loop Header: Depth=1
	movl	(%rbx,%r15,4), %edi
	callq	_ntohl
	addl	%eax, %r14d
	incq	%r15
	cmpq	%r15, %r13
	jne	LBB0_8
## %bb.9:
	cmpl	$-1, %r14d
	movq	-48(%rbp), %r15                 ## 8-byte Reload
	movq	_FW_FLASH_BOOT_ADDR@GOTPCREL(%rip), %r13
	movl	-56(%rbp), %edx                 ## 4-byte Reload
	je	LBB0_13
LBB0_10:
	leaq	L_.str(%rip), %rsi
	movq	%r15, %rdi
	movl	%r14d, %edx
	callq	_CH_ERR
	movq	_EINVAL@GOTPCREL(%rip), %rax
LBB0_11:
	subl	(%rax), %r12d
LBB0_12:
	movl	%r12d, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_13:
	movq	%r15, %rdi
	movl	%edx, %esi
	callq	_t3_flash_erase_sectors
	movl	%eax, %r12d
	testl	%eax, %eax
	jne	LBB0_21
## %bb.14:
	movl	-52(%rbp), %edi                 ## 4-byte Reload
	addl	$-8, %edi
	je	LBB0_18
## %bb.15:
	movl	(%r13), %r13d
LBB0_16:                                ## =>This Inner Loop Header: Depth=1
	movl	$256, %esi                      ## imm = 0x100
	movl	%edi, %r15d
	callq	_min
	movl	%eax, %r14d
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	movl	%r13d, %esi
	movl	%eax, %edx
	movq	%rbx, %rcx
	callq	_t3_write_flash
	testl	%eax, %eax
	jne	LBB0_20
## %bb.17:                              ##   in Loop: Header=BB0_16 Depth=1
	addl	%r14d, %r13d
	movl	%r14d, %eax
	leaq	(%rbx,%rax,4), %rbx
	subl	%r14d, %r15d
	movl	%r15d, %edi
	jne	LBB0_16
LBB0_18:
	movq	_FW_VERS_ADDR@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	-48(%rbp), %r15                 ## 8-byte Reload
	movq	%r15, %rdi
	movl	$4, %edx
	movq	%rbx, %rcx
	callq	_t3_write_flash
	movl	%eax, %r12d
	testl	%eax, %eax
	jne	LBB0_21
## %bb.19:
	xorl	%r12d, %r12d
	jmp	LBB0_12
LBB0_20:
	movl	%eax, %r12d
	movq	-48(%rbp), %r15                 ## 8-byte Reload
LBB0_21:
	leaq	L_.str.1(%rip), %rsi
	movq	%r15, %rdi
	movl	%r12d, %edx
	callq	_CH_ERR
	jmp	LBB0_12
	.cfi_endproc
                                        ## -- End function
	.comm	_FW_FLASH_BOOT_ADDR,4,2         ## @FW_FLASH_BOOT_ADDR
	.comm	_FW_MIN_SIZE,4,2                ## @FW_MIN_SIZE
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_FW_VERS_ADDR,4,2               ## @FW_VERS_ADDR
	.comm	_EFBIG,4,2                      ## @EFBIG
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"corrupted firmware image, checksum %u\n"

L_.str.1:                               ## @.str.1
	.asciz	"firmware download failed, error %d\n"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_t3_load_fw                     ; -- Begin function t3_load_fw
	.p2align	2
_t3_load_fw:                            ; @t3_load_fw
	.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
	tst	w2, #0x3
	b.ne	LBB0_10
; %bb.1:
	mov	x21, x2
Lloh0:
	adrp	x8, _FW_MIN_SIZE@GOTPAGE
Lloh1:
	ldr	x8, [x8, _FW_MIN_SIZE@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	cmp	w8, w2
	b.hi	LBB0_10
; %bb.2:
Lloh3:
	adrp	x24, _FW_FLASH_BOOT_ADDR@GOTPAGE
Lloh4:
	ldr	x24, [x24, _FW_FLASH_BOOT_ADDR@GOTPAGEOFF]
	ldr	w8, [x24]
Lloh5:
	adrp	x25, _FW_VERS_ADDR@GOTPAGE
Lloh6:
	ldr	x25, [x25, _FW_VERS_ADDR@GOTPAGEOFF]
	ldr	w9, [x25]
	sub	w9, w9, w8
	add	w9, w9, #8
	cmp	w9, w21
	b.hs	LBB0_4
; %bb.3:
Lloh7:
	adrp	x8, _EFBIG@GOTPAGE
Lloh8:
	ldr	x8, [x8, _EFBIG@GOTPAGEOFF]
	b	LBB0_11
LBB0_4:
	mov	x19, x0
	cmp	w21, #4
	b.hs	LBB0_6
; %bb.5:
	mov	w22, #0
	b	LBB0_9
LBB0_6:
	mov	x20, x1
	mov	x26, #0
	mov	w22, #0
	asr	w23, w8, #16
	and	w27, w21, #0xfffffffc
LBB0_7:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w0, [x20, x26]
	bl	_ntohl
	add	w22, w22, w0
	add	x26, x26, #4
	cmp	x27, x26
	b.ne	LBB0_7
; %bb.8:
	cmn	w22, #1
	b.eq	LBB0_13
LBB0_9:
Lloh9:
	adrp	x1, l_.str@PAGE
Lloh10:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x19
	mov	x2, x22
	bl	_CH_ERR
LBB0_10:
Lloh11:
	adrp	x8, _EINVAL@GOTPAGE
Lloh12:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
LBB0_11:
	ldr	w8, [x8]
	neg	w22, w8
LBB0_12:
	mov	x0, x22
	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_13:
	mov	x0, x19
	mov	x1, x23
	mov	x2, x23
	bl	_t3_flash_erase_sectors
	mov	x22, x0
	cbz	w0, LBB0_15
LBB0_14:
Lloh13:
	adrp	x1, l_.str.1@PAGE
Lloh14:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x0, x19
	mov	x2, x22
	bl	_CH_ERR
	b	LBB0_12
LBB0_15:
	subs	w21, w21, #8
	b.eq	LBB0_19
; %bb.16:
	ldr	w23, [x24]
LBB0_17:                                ; =>This Inner Loop Header: Depth=1
	mov	x0, x21
	mov	w1, #256
	bl	_min
	mov	x24, x0
	mov	x0, x19
	mov	x1, x23
	mov	x2, x24
	mov	x3, x20
	bl	_t3_write_flash
	cbnz	w0, LBB0_20
; %bb.18:                               ;   in Loop: Header=BB0_17 Depth=1
	add	w23, w24, w23
	add	x20, x20, w24, uxtw #2
	subs	w21, w21, w24
	b.ne	LBB0_17
LBB0_19:
	ldr	w1, [x25]
	mov	x0, x19
	mov	w2, #4
	mov	x3, x20
	bl	_t3_write_flash
	mov	x22, x0
	cbnz	w0, LBB0_14
	b	LBB0_12
LBB0_20:
	mov	x22, x0
	b	LBB0_14
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpAdd	Lloh9, Lloh10
	.loh AdrpLdrGot	Lloh11, Lloh12
	.loh AdrpAdd	Lloh13, Lloh14
	.cfi_endproc
                                        ; -- End function
	.comm	_FW_FLASH_BOOT_ADDR,4,2         ; @FW_FLASH_BOOT_ADDR
	.comm	_FW_MIN_SIZE,4,2                ; @FW_MIN_SIZE
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_FW_VERS_ADDR,4,2               ; @FW_VERS_ADDR
	.comm	_EFBIG,4,2                      ; @EFBIG
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"corrupted firmware image, checksum %u\n"

l_.str.1:                               ; @.str.1
	.asciz	"firmware download failed, error %d\n"

.subsections_via_symbols
