	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_build_fw                       ## -- Begin function build_fw
	.p2align	4, 0x90
_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), %ebx
	movq	_kernel_info@GOTPCREL(%rip), %rax
	cmpl	$0, 8(%rax)
	je	LBB0_14
## %bb.1:
	movq	_rootfs_info@GOTPCREL(%rip), %rax
	cmpl	$0, 8(%rax)
	je	LBB0_14
## %bb.2:
	movq	_kernel_info@GOTPCREL(%rip), %r15
	movq	%r15, %rdi
	callq	_get_file_stat
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_14
## %bb.3:
	movq	_rootfs_info@GOTPCREL(%rip), %r12
	movq	%r12, %rdi
	callq	_get_file_stat
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_14
## %bb.4:
	movq	_firmware_size@GOTPCREL(%rip), %rax
	movq	(%rax), %rbx
	movq	%rbx, %rdi
	callq	_malloc
	testq	%rax, %rax
	je	LBB0_5
## %bb.7:
	movq	%rax, %r14
	movq	(%r15), %rax
	addq	(%r12), %rax
	movq	_ALL_HEADERS_SIZE@GOTPCREL(%rip), %rcx
	addq	(%rcx), %rax
	cmpq	%rbx, %rax
	jle	LBB0_9
## %bb.8:
	leaq	L_.str.1(%rip), %rdi
	jmp	LBB0_6
LBB0_5:
	leaq	L_.str(%rip), %rdi
LBB0_6:
	callq	_ERR
	xorl	%ebx, %ebx
	jmp	LBB0_14
LBB0_9:
	movq	%r14, %rdi
	movl	$255, %esi
	movq	%rbx, %rdx
	callq	_memset
	movq	_STAG_SIZE@GOTPCREL(%rip), %rax
	movslq	(%rax), %r15
	addq	%r14, %r15
	movq	_SCH2_SIZE@GOTPCREL(%rip), %rax
	movslq	(%rax), %r12
	addq	%r15, %r12
	movq	_kernel_info@GOTPCREL(%rip), %rdi
	movq	%r12, %rsi
	callq	_read_to_buf
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_13
## %bb.10:
	movq	_kernel_info@GOTPCREL(%rip), %rax
	movq	(%rax), %r13
	addq	%r12, %r13
	movq	_rootfs_info@GOTPCREL(%rip), %rdi
	movq	%r13, %rsi
	callq	_read_to_buf
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_13
## %bb.11:
	movq	_rootfs_info@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	addl	%r13d, %ebx
	subl	%r14d, %ebx
	movq	%r15, %rdi
	movq	%r12, %rsi
	movq	%r13, %rdx
	callq	_fill_sch2
	movq	_kernel_info@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r14, %rdi
	callq	_fill_stag
	movq	_ofname@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	%r14, %rsi
	movl	%ebx, %edx
	callq	_write_fw
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_13
## %bb.12:
	movq	_EXIT_SUCCESS@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
LBB0_13:
	movq	%r14, %rdi
	callq	_free
LBB0_14:
	movl	%ebx, %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	_kernel_info,16,3               ## @kernel_info
	.comm	_rootfs_info,16,3               ## @rootfs_info
	.comm	_firmware_size,8,3              ## @firmware_size
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"no memory for buffer\n"

	.comm	_ALL_HEADERS_SIZE,8,3           ## @ALL_HEADERS_SIZE
L_.str.1:                               ## @.str.1
	.asciz	"data is bigger than firmware_size!\n"

	.comm	_STAG_SIZE,4,2                  ## @STAG_SIZE
	.comm	_SCH2_SIZE,4,2                  ## @SCH2_SIZE
	.comm	_ofname,4,2                     ## @ofname
	.comm	_EXIT_SUCCESS,4,2               ## @EXIT_SUCCESS
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_build_fw                       ; -- Begin function build_fw
	.p2align	2
_build_fw:                              ; @build_fw
	.cfi_startproc
; %bb.0:
	stp	x26, x25, [sp, #-80]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.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
Lloh0:
	adrp	x8, _kernel_info@GOTPAGE
Lloh1:
	ldr	x8, [x8, _kernel_info@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8, #8]
Lloh3:
	adrp	x9, _rootfs_info@GOTPAGE
Lloh4:
	ldr	x9, [x9, _rootfs_info@GOTPAGEOFF]
Lloh5:
	ldr	w9, [x9, #8]
	cmp	w8, #0
	ccmp	w9, #0, #4, ne
	b.ne	LBB0_2
; %bb.1:
Lloh6:
	adrp	x8, _EXIT_FAILURE@GOTPAGE
Lloh7:
	ldr	x8, [x8, _EXIT_FAILURE@GOTPAGEOFF]
Lloh8:
	ldr	w20, [x8]
	b	LBB0_13
LBB0_2:
Lloh9:
	adrp	x21, _kernel_info@GOTPAGE
Lloh10:
	ldr	x21, [x21, _kernel_info@GOTPAGEOFF]
	mov	x0, x21
	bl	_get_file_stat
	mov	x20, x0
	cbnz	w0, LBB0_13
; %bb.3:
Lloh11:
	adrp	x22, _rootfs_info@GOTPAGE
Lloh12:
	ldr	x22, [x22, _rootfs_info@GOTPAGEOFF]
	mov	x0, x22
	bl	_get_file_stat
	mov	x20, x0
	cbnz	w0, LBB0_13
; %bb.4:
Lloh13:
	adrp	x8, _firmware_size@GOTPAGE
Lloh14:
	ldr	x8, [x8, _firmware_size@GOTPAGEOFF]
Lloh15:
	ldr	x20, [x8]
	mov	x0, x20
	bl	_malloc
	cbz	x0, LBB0_7
; %bb.5:
	ldr	x8, [x22]
	ldr	x9, [x21]
Lloh16:
	adrp	x10, _ALL_HEADERS_SIZE@GOTPAGE
Lloh17:
	ldr	x10, [x10, _ALL_HEADERS_SIZE@GOTPAGEOFF]
Lloh18:
	ldr	x10, [x10]
	add	x8, x9, x8
	add	x8, x8, x10
	cmp	x8, x20
	b.le	LBB0_9
; %bb.6:
Lloh19:
	adrp	x0, l_.str.1@PAGE
Lloh20:
	add	x0, x0, l_.str.1@PAGEOFF
	b	LBB0_8
LBB0_7:
Lloh21:
	adrp	x0, l_.str@PAGE
Lloh22:
	add	x0, x0, l_.str@PAGEOFF
LBB0_8:
	bl	_ERR
	mov	w20, #0
	b	LBB0_13
LBB0_9:
	mov	x19, x0
	mov	w1, #255
	mov	x2, x20
	bl	_memset
Lloh23:
	adrp	x8, _STAG_SIZE@GOTPAGE
Lloh24:
	ldr	x8, [x8, _STAG_SIZE@GOTPAGEOFF]
Lloh25:
	ldrsw	x8, [x8]
Lloh26:
	adrp	x9, _SCH2_SIZE@GOTPAGE
Lloh27:
	ldr	x9, [x9, _SCH2_SIZE@GOTPAGEOFF]
Lloh28:
	ldrsw	x9, [x9]
	add	x23, x19, x8
	add	x22, x23, x9
Lloh29:
	adrp	x21, _kernel_info@GOTPAGE
Lloh30:
	ldr	x21, [x21, _kernel_info@GOTPAGEOFF]
	mov	x0, x21
	mov	x1, x22
	bl	_read_to_buf
	mov	x20, x0
	cbnz	w0, LBB0_12
; %bb.10:
	ldr	x8, [x21]
	add	x24, x22, x8
Lloh31:
	adrp	x25, _rootfs_info@GOTPAGE
Lloh32:
	ldr	x25, [x25, _rootfs_info@GOTPAGEOFF]
	mov	x0, x25
	mov	x1, x24
	bl	_read_to_buf
	mov	x20, x0
	cbnz	w0, LBB0_12
; %bb.11:
	ldr	w8, [x25]
	add	w8, w24, w8
	sub	w20, w8, w19
	mov	x0, x23
	mov	x1, x22
	mov	x2, x24
	bl	_fill_sch2
	ldr	w1, [x21]
	mov	x0, x19
	bl	_fill_stag
Lloh33:
	adrp	x8, _ofname@GOTPAGE
Lloh34:
	ldr	x8, [x8, _ofname@GOTPAGEOFF]
Lloh35:
	ldr	w0, [x8]
	mov	x1, x19
	mov	x2, x20
	bl	_write_fw
Lloh36:
	adrp	x8, _EXIT_SUCCESS@GOTPAGE
Lloh37:
	ldr	x8, [x8, _EXIT_SUCCESS@GOTPAGEOFF]
Lloh38:
	ldr	w8, [x8]
	cmp	w0, #0
	csel	w20, w8, w0, eq
LBB0_12:
	mov	x0, x19
	bl	_free
LBB0_13:
	mov	x0, x20
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp], #80             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh9, Lloh10
	.loh AdrpLdrGot	Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpAdd	Lloh19, Lloh20
	.loh AdrpAdd	Lloh21, Lloh22
	.loh AdrpLdrGot	Lloh29, Lloh30
	.loh AdrpLdrGotLdr	Lloh26, Lloh27, Lloh28
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh25
	.loh AdrpLdrGot	Lloh31, Lloh32
	.loh AdrpLdrGotLdr	Lloh36, Lloh37, Lloh38
	.loh AdrpLdrGotLdr	Lloh33, Lloh34, Lloh35
	.cfi_endproc
                                        ; -- End function
	.comm	_EXIT_FAILURE,4,2               ; @EXIT_FAILURE
	.comm	_kernel_info,16,3               ; @kernel_info
	.comm	_rootfs_info,16,3               ; @rootfs_info
	.comm	_firmware_size,8,3              ; @firmware_size
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"no memory for buffer\n"

	.comm	_ALL_HEADERS_SIZE,8,3           ; @ALL_HEADERS_SIZE
l_.str.1:                               ; @.str.1
	.asciz	"data is bigger than firmware_size!\n"

	.comm	_STAG_SIZE,4,2                  ; @STAG_SIZE
	.comm	_SCH2_SIZE,4,2                  ; @SCH2_SIZE
	.comm	_ofname,4,2                     ; @ofname
	.comm	_EXIT_SUCCESS,4,2               ; @EXIT_SUCCESS
.subsections_via_symbols
