	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_mtd_fixseama                   ## -- Begin function mtd_fixseama
	.p2align	4, 0x90
_mtd_fixseama:                          ## @mtd_fixseama
	.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
	movq	%rdx, -56(%rbp)                 ## 8-byte Spill
	movq	%rsi, %r14
	movq	%rdi, %r15
	movq	_quiet@GOTPCREL(%rip), %rax
	cmpl	$1, (%rax)
	jg	LBB0_2
## %bb.1:
	movq	_stderr@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str(%rip), %rsi
	movq	%r15, %rdx
	movq	%r14, %rcx
	xorl	%eax, %eax
	callq	_fprintf
LBB0_2:
	movq	_erasesize@GOTPCREL(%rip), %r12
	xorl	%ebx, %ebx
	subl	(%r12), %ebx
	movq	%r15, %rdi
	callq	_mtd_check_open
	movl	%eax, -44(%rbp)                 ## 4-byte Spill
	testl	%eax, %eax
	js	LBB0_3
## %bb.4:
	movslq	%ebx, %r13
	andq	%r14, %r13
	movslq	(%r12), %rdi
	leaq	(%rdi,%r13), %rax
	movq	_mtdsize@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rdx
	cmpq	%rdx, %rax
	ja	LBB0_5
## %bb.7:
                                        ## kill: def $edi killed $edi killed $rdi
	callq	_malloc
	testq	%rax, %rax
	movl	-44(%rbp), %edi                 ## 4-byte Reload
	je	LBB0_8
## %bb.10:
	movq	%rax, %r12
	movq	_erasesize@GOTPCREL(%rip), %rbx
	movl	(%rbx), %edx
	movq	%rax, %rsi
	movq	%r13, %rcx
	callq	_pread
	cmpl	(%rbx), %eax
	jne	LBB0_11
## %bb.12:
	subq	%r13, %r14
	movq	(%r12,%r14), %rbx
	movq	_SEAMA_MAGIC@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_htonl
	cmpq	%rax, %rbx
	jne	LBB0_13
## %bb.15:
	movq	%r12, %r15
	addq	%r14, %r15
	movl	8(%r15), %edi
	callq	_ntohl
	testq	%rax, %rax
	je	LBB0_16
## %bb.17:
	movl	12(%r15), %edi
	callq	_ntohs
	leaq	(%r14,%rax), %rbx
	addq	$16, %rbx
	movq	_mtdsize@GOTPCREL(%rip), %rax
	movq	(%rax), %r14
	subq	%rbx, %r14
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	testq	%rax, %rax
	cmovneq	%rax, %r14
	movl	8(%r15), %edi
	callq	_ntohl
	cmpq	%rax, %r14
	jbe	LBB0_19
## %bb.18:
	movl	8(%r15), %edi
	callq	_ntohl
	movq	%rax, %r14
LBB0_19:
	movq	%r15, %rdi
	movl	-44(%rbp), %r15d                ## 4-byte Reload
	movl	%r15d, %esi
	movq	%rbx, %rdx
	movq	%r14, %rcx
	callq	_seama_fix_md5
	testq	%rax, %rax
	jne	LBB0_27
## %bb.20:
	movl	%r15d, %edi
	movq	%r13, %rsi
	callq	_mtd_erase_block
	testq	%rax, %rax
	jne	LBB0_28
## %bb.21:
	movq	_quiet@GOTPCREL(%rip), %r14
	cmpl	$1, (%r14)
	jg	LBB0_23
## %bb.22:
	movq	_stderr@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str.8(%rip), %rsi
	movq	%r13, %rdx
	xorl	%eax, %eax
	callq	_fprintf
LBB0_23:
	movq	_erasesize@GOTPCREL(%rip), %rbx
	movl	(%rbx), %edx
	movl	%r15d, %edi
	movq	%r12, %rsi
	movq	%r13, %rcx
	callq	_pwrite
	cmpl	(%rbx), %eax
	jne	LBB0_24
## %bb.25:
	cmpl	$1, (%r14)
	jg	LBB0_27
## %bb.26:
	movq	_stderr@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str.10(%rip), %rsi
	xorl	%eax, %eax
	callq	_fprintf
LBB0_27:
	movl	%r15d, %edi
	callq	_close
	xorl	%eax, %eax
	callq	_sync
LBB0_9:
	xorl	%eax, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_8:
	callq	_mtd_fixseama.cold.1
	jmp	LBB0_9
LBB0_11:
	callq	_mtd_fixseama.cold.2
	jmp	LBB0_9
LBB0_3:
	movq	_stderr@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str.1(%rip), %rsi
	movq	%r15, %rdx
	jmp	LBB0_6
LBB0_5:
	movq	_stderr@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str.2(%rip), %rsi
	jmp	LBB0_6
LBB0_13:
	movq	_stderr@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str.5(%rip), %rsi
	jmp	LBB0_14
LBB0_16:
	movq	_stderr@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str.6(%rip), %rsi
LBB0_14:
	xorl	%eax, %eax
	callq	_fprintf
	movl	$1, %edi
	callq	_exit
LBB0_28:
	movq	_stderr@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	movq	_errno@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_strerror
	leaq	L_.str.7(%rip), %rsi
	movl	%ebx, %edi
	movq	%r13, %rdx
	movq	%rax, %rcx
	xorl	%eax, %eax
	callq	_fprintf
	movl	$1, %edi
	callq	_exit
LBB0_24:
	movq	_stderr@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	movq	_errno@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_strerror
	leaq	L_.str.9(%rip), %rsi
	movl	%ebx, %edi
	movq	%rax, %rdx
LBB0_6:
	xorl	%eax, %eax
	callq	_fprintf
	movl	$1, %edi
	callq	_exit
	.cfi_endproc
                                        ## -- End function
	.p2align	4, 0x90                         ## -- Begin function mtd_fixseama.cold.1
_mtd_fixseama.cold.1:                   ## @mtd_fixseama.cold.1
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	leaq	L_.str.3(%rip), %rdi
	callq	_perror
	pushq	$1
	popq	%rdi
	callq	_exit
	.cfi_endproc
                                        ## -- End function
	.p2align	4, 0x90                         ## -- Begin function mtd_fixseama.cold.2
_mtd_fixseama.cold.2:                   ## @mtd_fixseama.cold.2
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	leaq	L_.str.4(%rip), %rdi
	callq	_perror
	pushq	$1
	popq	%rdi
	callq	_exit
	.cfi_endproc
                                        ## -- End function
	.comm	_quiet,4,2                      ## @quiet
	.comm	_stderr,4,2                     ## @stderr
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Trying to fix SEAMA header in %s at 0x%x...\n"

	.comm	_erasesize,4,2                  ## @erasesize
L_.str.1:                               ## @.str.1
	.asciz	"Could not open mtd device: %s\n"

	.comm	_mtdsize,8,3                    ## @mtdsize
L_.str.2:                               ## @.str.2
	.asciz	"Offset too large, device size 0x%x\n"

L_.str.3:                               ## @.str.3
	.asciz	"malloc"

L_.str.4:                               ## @.str.4
	.asciz	"pread"

	.comm	_SEAMA_MAGIC,4,2                ## @SEAMA_MAGIC
L_.str.5:                               ## @.str.5
	.asciz	"No SEAMA header found\n"

L_.str.6:                               ## @.str.6
	.asciz	"Seama entity with empty image\n"

L_.str.7:                               ## @.str.7
	.asciz	"Can't erease block at 0x%x (%s)\n"

	.comm	_errno,4,2                      ## @errno
L_.str.8:                               ## @.str.8
	.asciz	"Rewriting block at 0x%x\n"

L_.str.9:                               ## @.str.9
	.asciz	"Error writing block (%s)\n"

L_.str.10:                              ## @.str.10
	.asciz	"Done.\n"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_mtd_fixseama                   ; -- Begin function mtd_fixseama
	.p2align	2
_mtd_fixseama:                          ; @mtd_fixseama
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x28, x27, [sp, #16]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.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
	mov	x22, x2
	mov	x23, x1
	mov	x20, x0
Lloh0:
	adrp	x25, _quiet@GOTPAGE
Lloh1:
	ldr	x25, [x25, _quiet@GOTPAGEOFF]
	ldr	w8, [x25]
	cmp	w8, #1
	b.gt	LBB0_2
; %bb.1:
Lloh2:
	adrp	x8, _stderr@GOTPAGE
Lloh3:
	ldr	x8, [x8, _stderr@GOTPAGEOFF]
Lloh4:
	ldr	w0, [x8]
	stp	x20, x23, [sp]
Lloh5:
	adrp	x1, l_.str@PAGE
Lloh6:
	add	x1, x1, l_.str@PAGEOFF
	bl	_fprintf
LBB0_2:
Lloh7:
	adrp	x26, _erasesize@GOTPAGE
Lloh8:
	ldr	x26, [x26, _erasesize@GOTPAGEOFF]
	ldr	w21, [x26]
	mov	x0, x20
	bl	_mtd_check_open
	tbnz	w0, #31, LBB0_18
; %bb.3:
	mov	x19, x0
	neg	w8, w21
	sxtw	x8, w8
	and	x20, x8, x23
	ldrsw	x0, [x26]
Lloh9:
	adrp	x27, _mtdsize@GOTPAGE
Lloh10:
	ldr	x27, [x27, _mtdsize@GOTPAGEOFF]
	ldr	x8, [x27]
	add	x9, x20, x0
	cmp	x9, x8
	b.hi	LBB0_19
; %bb.4:
                                        ; kill: def $w0 killed $w0 killed $x0
	bl	_malloc
	cbz	x0, LBB0_20
; %bb.5:
	mov	x21, x0
	ldr	w2, [x26]
	mov	x0, x19
	mov	x1, x21
	mov	x3, x20
	bl	_pread
	ldr	w8, [x26]
	cmp	w0, w8
	b.ne	LBB0_21
; %bb.6:
	sub	x24, x23, x20
	add	x23, x21, x24
	ldr	x28, [x23]
Lloh11:
	adrp	x8, _SEAMA_MAGIC@GOTPAGE
Lloh12:
	ldr	x8, [x8, _SEAMA_MAGIC@GOTPAGEOFF]
Lloh13:
	ldr	w0, [x8]
	bl	_htonl
	cmp	x28, x0
	b.ne	LBB0_22
; %bb.7:
	ldr	w0, [x23, #8]
	bl	_ntohl
	cbz	x0, LBB0_23
; %bb.8:
	ldr	w0, [x23, #12]
	bl	_ntohs
	add	x8, x24, x0
	add	x24, x8, #16
	ldr	x8, [x27]
	sub	x8, x8, x24
	cmp	x22, #0
	csel	x22, x8, x22, eq
	ldr	w0, [x23, #8]
	bl	_ntohl
	cmp	x22, x0
	b.ls	LBB0_10
; %bb.9:
	ldr	w0, [x23, #8]
	bl	_ntohl
	mov	x22, x0
LBB0_10:
	mov	x0, x23
	mov	x1, x19
	mov	x2, x24
	mov	x3, x22
	bl	_seama_fix_md5
	cbnz	x0, LBB0_17
; %bb.11:
	mov	x0, x19
	mov	x1, x20
	bl	_mtd_erase_block
	cbnz	x0, LBB0_24
; %bb.12:
	ldr	w8, [x25]
	cmp	w8, #1
	b.gt	LBB0_14
; %bb.13:
Lloh14:
	adrp	x8, _stderr@GOTPAGE
Lloh15:
	ldr	x8, [x8, _stderr@GOTPAGEOFF]
Lloh16:
	ldr	w0, [x8]
	str	x20, [sp]
Lloh17:
	adrp	x1, l_.str.8@PAGE
Lloh18:
	add	x1, x1, l_.str.8@PAGEOFF
	bl	_fprintf
LBB0_14:
	ldr	w2, [x26]
	mov	x0, x19
	mov	x1, x21
	mov	x3, x20
	bl	_pwrite
	ldr	w8, [x26]
	cmp	w0, w8
	b.ne	LBB0_25
; %bb.15:
	ldr	w8, [x25]
	cmp	w8, #1
	b.gt	LBB0_17
; %bb.16:
Lloh19:
	adrp	x8, _stderr@GOTPAGE
Lloh20:
	ldr	x8, [x8, _stderr@GOTPAGEOFF]
Lloh21:
	ldr	w0, [x8]
Lloh22:
	adrp	x1, l_.str.10@PAGE
Lloh23:
	add	x1, x1, l_.str.10@PAGEOFF
	bl	_fprintf
LBB0_17:
	mov	x0, x19
	bl	_close
	bl	_sync
	mov	w0, #0
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
LBB0_18:
Lloh24:
	adrp	x8, _stderr@GOTPAGE
Lloh25:
	ldr	x8, [x8, _stderr@GOTPAGEOFF]
Lloh26:
	ldr	w0, [x8]
	str	x20, [sp]
Lloh27:
	adrp	x1, l_.str.1@PAGE
Lloh28:
	add	x1, x1, l_.str.1@PAGEOFF
	b	LBB0_27
LBB0_19:
Lloh29:
	adrp	x9, _stderr@GOTPAGE
Lloh30:
	ldr	x9, [x9, _stderr@GOTPAGEOFF]
Lloh31:
	ldr	w0, [x9]
	str	x8, [sp]
Lloh32:
	adrp	x1, l_.str.2@PAGE
Lloh33:
	add	x1, x1, l_.str.2@PAGEOFF
	b	LBB0_27
LBB0_20:
	bl	_mtd_fixseama.cold.1
LBB0_21:
	bl	_mtd_fixseama.cold.2
LBB0_22:
Lloh34:
	adrp	x8, _stderr@GOTPAGE
Lloh35:
	ldr	x8, [x8, _stderr@GOTPAGEOFF]
Lloh36:
	ldr	w0, [x8]
Lloh37:
	adrp	x1, l_.str.5@PAGE
Lloh38:
	add	x1, x1, l_.str.5@PAGEOFF
	b	LBB0_27
LBB0_23:
Lloh39:
	adrp	x8, _stderr@GOTPAGE
Lloh40:
	ldr	x8, [x8, _stderr@GOTPAGEOFF]
Lloh41:
	ldr	w0, [x8]
Lloh42:
	adrp	x1, l_.str.6@PAGE
Lloh43:
	add	x1, x1, l_.str.6@PAGEOFF
	b	LBB0_27
LBB0_24:
Lloh44:
	adrp	x8, _stderr@GOTPAGE
Lloh45:
	ldr	x8, [x8, _stderr@GOTPAGEOFF]
Lloh46:
	ldr	w19, [x8]
Lloh47:
	adrp	x8, _errno@GOTPAGE
Lloh48:
	ldr	x8, [x8, _errno@GOTPAGEOFF]
Lloh49:
	ldr	w0, [x8]
	bl	_strerror
	stp	x20, x0, [sp]
Lloh50:
	adrp	x1, l_.str.7@PAGE
Lloh51:
	add	x1, x1, l_.str.7@PAGEOFF
	b	LBB0_26
LBB0_25:
Lloh52:
	adrp	x8, _stderr@GOTPAGE
Lloh53:
	ldr	x8, [x8, _stderr@GOTPAGEOFF]
Lloh54:
	ldr	w19, [x8]
Lloh55:
	adrp	x8, _errno@GOTPAGE
Lloh56:
	ldr	x8, [x8, _errno@GOTPAGEOFF]
Lloh57:
	ldr	w0, [x8]
	bl	_strerror
	str	x0, [sp]
Lloh58:
	adrp	x1, l_.str.9@PAGE
Lloh59:
	add	x1, x1, l_.str.9@PAGEOFF
LBB0_26:
	mov	x0, x19
LBB0_27:
	bl	_fprintf
	mov	w0, #1
	bl	_exit
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpAdd	Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpAdd	Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpAdd	Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.loh AdrpAdd	Lloh27, Lloh28
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.loh AdrpAdd	Lloh32, Lloh33
	.loh AdrpLdrGotLdr	Lloh29, Lloh30, Lloh31
	.loh AdrpAdd	Lloh37, Lloh38
	.loh AdrpLdrGotLdr	Lloh34, Lloh35, Lloh36
	.loh AdrpAdd	Lloh42, Lloh43
	.loh AdrpLdrGotLdr	Lloh39, Lloh40, Lloh41
	.loh AdrpAdd	Lloh50, Lloh51
	.loh AdrpLdrGotLdr	Lloh47, Lloh48, Lloh49
	.loh AdrpLdrGotLdr	Lloh44, Lloh45, Lloh46
	.loh AdrpAdd	Lloh58, Lloh59
	.loh AdrpLdrGotLdr	Lloh55, Lloh56, Lloh57
	.loh AdrpLdrGotLdr	Lloh52, Lloh53, Lloh54
	.cfi_endproc
                                        ; -- End function
	.p2align	2                               ; -- Begin function mtd_fixseama.cold.1
_mtd_fixseama.cold.1:                   ; @mtd_fixseama.cold.1
	.cfi_startproc
; %bb.0:
	stp	x29, x30, [sp, #-16]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 16
	mov	x29, sp
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
Lloh60:
	adrp	x0, l_.str.3@PAGE
Lloh61:
	add	x0, x0, l_.str.3@PAGEOFF
	bl	_perror
	mov	w0, #1
	bl	_exit
	.loh AdrpAdd	Lloh60, Lloh61
	.cfi_endproc
                                        ; -- End function
	.p2align	2                               ; -- Begin function mtd_fixseama.cold.2
_mtd_fixseama.cold.2:                   ; @mtd_fixseama.cold.2
	.cfi_startproc
; %bb.0:
	stp	x29, x30, [sp, #-16]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 16
	mov	x29, sp
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
Lloh62:
	adrp	x0, l_.str.4@PAGE
Lloh63:
	add	x0, x0, l_.str.4@PAGEOFF
	bl	_perror
	mov	w0, #1
	bl	_exit
	.loh AdrpAdd	Lloh62, Lloh63
	.cfi_endproc
                                        ; -- End function
	.comm	_quiet,4,2                      ; @quiet
	.comm	_stderr,4,2                     ; @stderr
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Trying to fix SEAMA header in %s at 0x%x...\n"

	.comm	_erasesize,4,2                  ; @erasesize
l_.str.1:                               ; @.str.1
	.asciz	"Could not open mtd device: %s\n"

	.comm	_mtdsize,8,3                    ; @mtdsize
l_.str.2:                               ; @.str.2
	.asciz	"Offset too large, device size 0x%x\n"

l_.str.3:                               ; @.str.3
	.asciz	"malloc"

l_.str.4:                               ; @.str.4
	.asciz	"pread"

	.comm	_SEAMA_MAGIC,4,2                ; @SEAMA_MAGIC
l_.str.5:                               ; @.str.5
	.asciz	"No SEAMA header found\n"

l_.str.6:                               ; @.str.6
	.asciz	"Seama entity with empty image\n"

l_.str.7:                               ; @.str.7
	.asciz	"Can't erease block at 0x%x (%s)\n"

	.comm	_errno,4,2                      ; @errno
l_.str.8:                               ; @.str.8
	.asciz	"Rewriting block at 0x%x\n"

l_.str.9:                               ; @.str.9
	.asciz	"Error writing block (%s)\n"

l_.str.10:                              ; @.str.10
	.asciz	"Done.\n"

.subsections_via_symbols
