	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function build_fw
_build_fw:                              ## @build_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
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	_EXIT_FAILURE@GOTPCREL(%rip), %rax
	movl	(%rax), %r12d
	movq	_layout@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movl	(%rax), %ebx
	movl	%ebx, %edi
	callq	_malloc
	testq	%rax, %rax
	je	LBB0_1
## %bb.2:
	movq	%rax, %r15
	movq	%rax, %rdi
	movl	$255, %esi
	movl	%ebx, %edx
	callq	_memset
	movq	%r15, %r14
	addq	$16, %r14
	movq	_firmware_info@GOTPCREL(%rip), %rdi
	movq	%r14, %rsi
	callq	_read_to_buf
	movl	%eax, %r12d
	testl	%eax, %eax
	jne	LBB0_5
## %bb.3:
	movq	_firmware_len@GOTPCREL(%rip), %r13
	movl	(%r13), %ebx
	leal	6(%rbx), %r12d
	movq	%r15, %rdi
	callq	_fill_header
	movl	(%r13), %esi
	movq	%r14, %rdi
	callq	_checksum_fw
	movzbl	%al, %ecx
	sarl	$8, %eax
	leal	5(%rbx), %edx
	movslq	%edx, %rdx
	movl	%eax, (%r15,%rdx,4)
	addl	$4, %ebx
	movslq	%ebx, %rax
	movl	%ecx, (%r15,%rax,4)
	movl	(%r13), %esi
	addl	$2, %esi
	movq	%r14, %rdi
	callq	_xor_fw
	movq	%r15, %rdi
	movl	%r12d, %esi
	callq	_write_fw
	movl	%eax, %r12d
	testl	%eax, %eax
	jne	LBB0_5
## %bb.4:
	movq	_EXIT_SUCCESS@GOTPCREL(%rip), %rax
	movl	(%rax), %r12d
LBB0_5:
	movq	%r15, %rdi
	callq	_free
	jmp	LBB0_6
LBB0_1:
	leaq	L_.str(%rip), %rdi
	callq	_ERR
LBB0_6:
	movl	%r12d, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_EXIT_FAILURE,4,2               ## @EXIT_FAILURE
	.comm	_layout,8,3                     ## @layout
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"no memory for buffer\n"

	.comm	_firmware_info,4,2              ## @firmware_info
	.comm	_firmware_len,4,2               ## @firmware_len
	.comm	_EXIT_SUCCESS,4,2               ## @EXIT_SUCCESS
	.no_dead_strip	_build_fw
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function build_fw
_build_fw:                              ; @build_fw
	.cfi_startproc
; %bb.0:
	stp	x24, x23, [sp, #-64]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.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
Lloh0:
	adrp	x8, _EXIT_FAILURE@GOTPAGE
Lloh1:
	ldr	x8, [x8, _EXIT_FAILURE@GOTPAGEOFF]
Lloh2:
	ldr	w21, [x8]
Lloh3:
	adrp	x8, _layout@GOTPAGE
Lloh4:
	ldr	x8, [x8, _layout@GOTPAGEOFF]
Lloh5:
	ldr	x8, [x8]
	ldr	w20, [x8]
	mov	x0, x20
	bl	_malloc
	cbz	x0, LBB0_4
; %bb.1:
	mov	x19, x0
	mov	w1, #255
	mov	x2, x20
	bl	_memset
	add	x20, x19, #16
Lloh6:
	adrp	x0, _firmware_info@GOTPAGE
Lloh7:
	ldr	x0, [x0, _firmware_info@GOTPAGEOFF]
	mov	x1, x20
	bl	_read_to_buf
	mov	x21, x0
	cbnz	w0, LBB0_3
; %bb.2:
Lloh8:
	adrp	x22, _firmware_len@GOTPAGE
Lloh9:
	ldr	x22, [x22, _firmware_len@GOTPAGEOFF]
	ldr	w23, [x22]
	add	w21, w23, #6
	mov	x0, x19
	bl	_fill_header
	ldr	w1, [x22]
	mov	x0, x20
	bl	_checksum_fw
	asr	w8, w0, #8
	add	w9, w23, #5
	str	w8, [x19, w9, sxtw #2]
	and	w8, w0, #0xff
	add	w9, w23, #4
	str	w8, [x19, w9, sxtw #2]
	ldr	w8, [x22]
	add	w1, w8, #2
	mov	x0, x20
	bl	_xor_fw
	mov	x0, x19
	mov	x1, x21
	bl	_write_fw
Lloh10:
	adrp	x8, _EXIT_SUCCESS@GOTPAGE
Lloh11:
	ldr	x8, [x8, _EXIT_SUCCESS@GOTPAGEOFF]
Lloh12:
	ldr	w8, [x8]
	cmp	w0, #0
	csel	w21, w8, w0, eq
LBB0_3:
	mov	x0, x19
	bl	_free
	b	LBB0_5
LBB0_4:
Lloh13:
	adrp	x0, l_.str@PAGE
Lloh14:
	add	x0, x0, l_.str@PAGEOFF
	bl	_ERR
LBB0_5:
	mov	x0, x21
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp], #64             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpAdd	Lloh13, Lloh14
	.cfi_endproc
                                        ; -- End function
	.comm	_EXIT_FAILURE,4,2               ; @EXIT_FAILURE
	.comm	_layout,8,3                     ; @layout
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"no memory for buffer\n"

	.comm	_firmware_info,4,2              ; @firmware_info
	.comm	_firmware_len,4,2               ; @firmware_len
	.comm	_EXIT_SUCCESS,4,2               ; @EXIT_SUCCESS
	.no_dead_strip	_build_fw
.subsections_via_symbols
