	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function fix_header
_fix_header:                            ## @fix_header
	.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	%rbx
	pushq	%rax
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	_EXIT_FAILURE@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	movq	_if_info@GOTPCREL(%rip), %rax
	movl	(%rax), %r15d
	cmpl	$55, %r15d
	ja	LBB0_2
## %bb.1:
	leaq	L_.str(%rip), %rdi
	callq	_ERR
	jmp	LBB0_13
LBB0_2:
	movl	%r15d, %edi
	callq	_malloc
	testq	%rax, %rax
	je	LBB0_3
## %bb.4:
	movq	%rax, %r14
	movq	_if_info@GOTPCREL(%rip), %rdi
	movq	%rax, %rsi
	callq	_read_to_buf
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_12
## %bb.5:
	movq	48(%r14), %rdi
	callq	_ntohl
	movq	_IH_MAGIC@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_6
## %bb.8:
	movq	16(%r14), %rdi
	callq	_ntohl
	movq	%rax, %rbx
	movq	$0, 16(%r14)
	movq	%r14, %rdi
	movl	$56, %esi
	callq	_cyg_ether_crc32
	cmpq	%rbx, %rax
	jne	LBB0_9
## %bb.10:
	movq	(%r14), %rax
	movq	_IH_NMLEN@GOTPCREL(%rip), %rcx
	movq	_UM_HEADER_LEN@GOTPCREL(%rip), %rdx
	movl	(%rdx), %edx
	notl	%edx
	addl	(%rcx), %edx
	movslq	%edx, %rcx
	movb	$0, (%rax,%rcx)
	movq	_UM_MAGIC@GOTPCREL(%rip), %rax
	movq	(%rax), %rdi
	callq	_htonl
	movq	%rax, 40(%r14)
	movq	_board_id@GOTPCREL(%rip), %rax
	movq	(%rax), %rdi
	callq	_htonl
	movq	%rax, 32(%r14)
	movq	_image_type@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 24(%r14)
	movq	_factory_defaults@GOTPCREL(%rip), %rax
	xorl	%ecx, %ecx
	cmpq	$0, (%rax)
	setne	%cl
	movl	%ecx, 8(%r14)
	movq	%r14, %rdi
	movl	$56, %esi
	callq	_cyg_ether_crc32
	movq	%rax, %rdi
	callq	_htonl
	movq	%rax, 16(%r14)
	movq	%r14, %rdi
	movl	%r15d, %esi
	callq	_write_fw
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_12
## %bb.11:
	movq	_ofname@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	L_.str.4(%rip), %rdi
	callq	_DBG
	movq	_EXIT_SUCCESS@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	jmp	LBB0_12
LBB0_3:
	leaq	L_.str.1(%rip), %rdi
	callq	_ERR
	jmp	LBB0_13
LBB0_6:
	leaq	L_.str.2(%rip), %rdi
	jmp	LBB0_7
LBB0_9:
	leaq	L_.str.3(%rip), %rdi
LBB0_7:
	callq	_ERR
	xorl	%ebx, %ebx
LBB0_12:
	movq	%r14, %rdi
	callq	_free
LBB0_13:
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_EXIT_FAILURE,4,2               ## @EXIT_FAILURE
	.comm	_if_info,4,2                    ## @if_info
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"invalid input file\n"

L_.str.1:                               ## @.str.1
	.asciz	"no memory for buffer\n"

	.comm	_IH_MAGIC,8,3                   ## @IH_MAGIC
L_.str.2:                               ## @.str.2
	.asciz	"invalid input file, bad magic\n"

L_.str.3:                               ## @.str.3
	.asciz	"invalid input file, bad header CRC\n"

	.comm	_IH_NMLEN,4,2                   ## @IH_NMLEN
	.comm	_UM_HEADER_LEN,4,2              ## @UM_HEADER_LEN
	.comm	_UM_MAGIC,8,3                   ## @UM_MAGIC
	.comm	_board_id,8,3                   ## @board_id
	.comm	_image_type,4,2                 ## @image_type
	.comm	_factory_defaults,8,3           ## @factory_defaults
L_.str.4:                               ## @.str.4
	.asciz	"U-Media header fixed in \"%s\""

	.comm	_ofname,4,2                     ## @ofname
	.comm	_EXIT_SUCCESS,4,2               ## @EXIT_SUCCESS
	.no_dead_strip	_fix_header
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function fix_header
_fix_header:                            ; @fix_header
	.cfi_startproc
; %bb.0:
	stp	x22, x21, [sp, #-48]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 48
	stp	x20, x19, [sp, #16]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #32]             ; 16-byte Folded Spill
	add	x29, sp, #32
	.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
Lloh0:
	adrp	x8, _EXIT_FAILURE@GOTPAGE
Lloh1:
	ldr	x8, [x8, _EXIT_FAILURE@GOTPAGEOFF]
Lloh2:
	ldr	w21, [x8]
Lloh3:
	adrp	x8, _if_info@GOTPAGE
Lloh4:
	ldr	x8, [x8, _if_info@GOTPAGEOFF]
Lloh5:
	ldr	w20, [x8]
	cmp	w20, #55
	b.hi	LBB0_2
; %bb.1:
Lloh6:
	adrp	x0, l_.str@PAGE
Lloh7:
	add	x0, x0, l_.str@PAGEOFF
	bl	_ERR
	b	LBB0_13
LBB0_2:
	mov	x0, x20
	bl	_malloc
	cbz	x0, LBB0_8
; %bb.3:
	mov	x19, x0
Lloh8:
	adrp	x0, _if_info@GOTPAGE
Lloh9:
	ldr	x0, [x0, _if_info@GOTPAGEOFF]
	mov	x1, x19
	bl	_read_to_buf
	mov	x21, x0
	cbnz	w0, LBB0_12
; %bb.4:
	ldr	x0, [x19, #48]
	bl	_ntohl
Lloh10:
	adrp	x8, _IH_MAGIC@GOTPAGE
Lloh11:
	ldr	x8, [x8, _IH_MAGIC@GOTPAGEOFF]
Lloh12:
	ldr	x8, [x8]
	cmp	x0, x8
	b.ne	LBB0_9
; %bb.5:
	ldr	x0, [x19, #16]
	bl	_ntohl
	mov	x21, x0
	str	xzr, [x19, #16]
	mov	x0, x19
	mov	w1, #56
	bl	_cyg_ether_crc32
	cmp	x0, x21
	b.ne	LBB0_10
; %bb.6:
Lloh13:
	adrp	x8, _IH_NMLEN@GOTPAGE
Lloh14:
	ldr	x8, [x8, _IH_NMLEN@GOTPAGEOFF]
	ldr	x9, [x19]
Lloh15:
	ldr	w8, [x8]
Lloh16:
	adrp	x10, _UM_HEADER_LEN@GOTPAGE
Lloh17:
	ldr	x10, [x10, _UM_HEADER_LEN@GOTPAGEOFF]
Lloh18:
	ldr	w10, [x10]
	mvn	w10, w10
	add	w8, w8, w10
	strb	wzr, [x9, w8, sxtw]
Lloh19:
	adrp	x8, _UM_MAGIC@GOTPAGE
Lloh20:
	ldr	x8, [x8, _UM_MAGIC@GOTPAGEOFF]
Lloh21:
	ldr	x0, [x8]
	bl	_htonl
	str	x0, [x19, #40]
Lloh22:
	adrp	x8, _board_id@GOTPAGE
Lloh23:
	ldr	x8, [x8, _board_id@GOTPAGEOFF]
Lloh24:
	ldr	x0, [x8]
	bl	_htonl
	str	x0, [x19, #32]
Lloh25:
	adrp	x8, _image_type@GOTPAGE
Lloh26:
	ldr	x8, [x8, _image_type@GOTPAGEOFF]
Lloh27:
	ldr	w8, [x8]
	str	w8, [x19, #24]
Lloh28:
	adrp	x8, _factory_defaults@GOTPAGE
Lloh29:
	ldr	x8, [x8, _factory_defaults@GOTPAGEOFF]
Lloh30:
	ldr	x8, [x8]
	cmp	x8, #0
	cset	w8, ne
	str	w8, [x19, #8]
	mov	x0, x19
	mov	w1, #56
	bl	_cyg_ether_crc32
	bl	_htonl
	str	x0, [x19, #16]
	mov	x0, x19
	mov	x1, x20
	bl	_write_fw
	mov	x21, x0
	cbnz	w0, LBB0_12
; %bb.7:
Lloh31:
	adrp	x8, _ofname@GOTPAGE
Lloh32:
	ldr	x8, [x8, _ofname@GOTPAGEOFF]
Lloh33:
	ldr	w1, [x8]
Lloh34:
	adrp	x0, l_.str.4@PAGE
Lloh35:
	add	x0, x0, l_.str.4@PAGEOFF
	bl	_DBG
Lloh36:
	adrp	x8, _EXIT_SUCCESS@GOTPAGE
Lloh37:
	ldr	x8, [x8, _EXIT_SUCCESS@GOTPAGEOFF]
Lloh38:
	ldr	w21, [x8]
	b	LBB0_12
LBB0_8:
Lloh39:
	adrp	x0, l_.str.1@PAGE
Lloh40:
	add	x0, x0, l_.str.1@PAGEOFF
	bl	_ERR
	b	LBB0_13
LBB0_9:
Lloh41:
	adrp	x0, l_.str.2@PAGE
Lloh42:
	add	x0, x0, l_.str.2@PAGEOFF
	b	LBB0_11
LBB0_10:
Lloh43:
	adrp	x0, l_.str.3@PAGE
Lloh44:
	add	x0, x0, l_.str.3@PAGEOFF
LBB0_11:
	bl	_ERR
	mov	w21, #0
LBB0_12:
	mov	x0, x19
	bl	_free
LBB0_13:
	mov	x0, x21
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp], #48             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh28, Lloh29, Lloh30
	.loh AdrpLdrGotLdr	Lloh25, Lloh26, Lloh27
	.loh AdrpLdrGotLdr	Lloh22, Lloh23, Lloh24
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh36, Lloh37, Lloh38
	.loh AdrpAdd	Lloh34, Lloh35
	.loh AdrpLdrGotLdr	Lloh31, Lloh32, Lloh33
	.loh AdrpAdd	Lloh39, Lloh40
	.loh AdrpAdd	Lloh41, Lloh42
	.loh AdrpAdd	Lloh43, Lloh44
	.cfi_endproc
                                        ; -- End function
	.comm	_EXIT_FAILURE,4,2               ; @EXIT_FAILURE
	.comm	_if_info,4,2                    ; @if_info
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"invalid input file\n"

l_.str.1:                               ; @.str.1
	.asciz	"no memory for buffer\n"

	.comm	_IH_MAGIC,8,3                   ; @IH_MAGIC
l_.str.2:                               ; @.str.2
	.asciz	"invalid input file, bad magic\n"

l_.str.3:                               ; @.str.3
	.asciz	"invalid input file, bad header CRC\n"

	.comm	_IH_NMLEN,4,2                   ; @IH_NMLEN
	.comm	_UM_HEADER_LEN,4,2              ; @UM_HEADER_LEN
	.comm	_UM_MAGIC,8,3                   ; @UM_MAGIC
	.comm	_board_id,8,3                   ; @board_id
	.comm	_image_type,4,2                 ; @image_type
	.comm	_factory_defaults,8,3           ; @factory_defaults
l_.str.4:                               ; @.str.4
	.asciz	"U-Media header fixed in \"%s\""

	.comm	_ofname,4,2                     ; @ofname
	.comm	_EXIT_SUCCESS,4,2               ; @EXIT_SUCCESS
	.no_dead_strip	_fix_header
.subsections_via_symbols
