	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_main                           ## -- Begin function main
	.p2align	4, 0x90
_main:                                  ## @main
	.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	%rsi, %r15
	movl	%edi, %ebx
	leaq	L_.str(%rip), %r14
	movq	_optarg@GOTPCREL(%rip), %r12
	movq	_page_size@GOTPCREL(%rip), %r13
	jmp	LBB0_1
	.p2align	4, 0x90
LBB0_8:                                 ##   in Loop: Header=BB0_1 Depth=1
	movl	(%r12), %edi
	xorl	%esi, %esi
	xorl	%edx, %edx
	callq	_strtoul
	movq	_oob_size@GOTPCREL(%rip), %rcx
	movq	%rax, (%rcx)
LBB0_1:                                 ## =>This Inner Loop Header: Depth=1
	movl	%ebx, %edi
	movq	%r15, %rsi
	movq	%r14, %rdx
	callq	_getopt
	cmpl	$110, %eax
	jle	LBB0_2
## %bb.5:                               ##   in Loop: Header=BB0_1 Depth=1
	cmpl	$111, %eax
	je	LBB0_8
## %bb.6:                               ##   in Loop: Header=BB0_1 Depth=1
	cmpl	$112, %eax
	jne	LBB0_4
## %bb.7:                               ##   in Loop: Header=BB0_1 Depth=1
	movl	(%r12), %edi
	xorl	%esi, %esi
	xorl	%edx, %edx
	callq	_strtoul
	movl	%eax, (%r13)
	jmp	LBB0_1
	.p2align	4, 0x90
LBB0_2:                                 ##   in Loop: Header=BB0_1 Depth=1
	cmpl	$101, %eax
	jne	LBB0_3
## %bb.9:                               ##   in Loop: Header=BB0_1 Depth=1
	movl	(%r12), %edi
	xorl	%esi, %esi
	xorl	%edx, %edx
	callq	_strtoul
	movq	_ecc_offset@GOTPCREL(%rip), %rcx
	movl	%eax, (%rcx)
	jmp	LBB0_1
LBB0_3:                                 ##   in Loop: Header=BB0_1 Depth=1
	cmpl	$-1, %eax
	je	LBB0_10
LBB0_4:                                 ##   in Loop: Header=BB0_1 Depth=1
	movq	(%r15), %rdi
	callq	_usage
	jmp	LBB0_1
LBB0_10:
	movq	_optind@GOTPCREL(%rip), %r12
	movq	(%r12), %r14
	subl	%r14d, %ebx
	cmpl	$1, %ebx
	jg	LBB0_12
## %bb.11:
	movq	(%r15), %rdi
	callq	_usage
	movq	(%r12), %r14
LBB0_12:
	movq	(%r15,%r14,8), %rdi
	movq	_O_RDONLY@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	xorl	%edx, %edx
	callq	_open
	testl	%eax, %eax
	js	LBB0_13
## %bb.14:
	movl	%eax, %r12d
	movq	_O_WRONLY@GOTPCREL(%rip), %rax
	movq	_O_CREAT@GOTPCREL(%rip), %rcx
	movl	(%rcx), %esi
	orl	(%rax), %esi
	movq	8(%r15,%r14,8), %rdi
	movq	_O_TRUNC@GOTPCREL(%rip), %rax
	orl	(%rax), %esi
	movl	$420, %edx                      ## imm = 0x1A4
	callq	_open
	movl	%eax, %ebx
	testl	%eax, %eax
	js	LBB0_15
## %bb.16:
	movslq	(%r13), %rdi
	movq	_oob_size@GOTPCREL(%rip), %rax
	addq	(%rax), %rdi
	callq	_malloc
	movq	%rax, %r14
	movl	(%r13), %edx
	movl	%r12d, %edi
	movq	%rax, %rsi
	callq	_read
	xorl	%r15d, %r15d
	cmpl	(%r13), %eax
	jne	LBB0_24
## %bb.17:
	movl	%r12d, -48(%rbp)                ## 4-byte Spill
	movl	%ebx, -44(%rbp)                 ## 4-byte Spill
	jmp	LBB0_18
	.p2align	4, 0x90
LBB0_22:                                ##   in Loop: Header=BB0_18 Depth=1
	movq	_oob_size@GOTPCREL(%rip), %rax
	addq	(%rax), %rdx
	movl	%ebx, %edi
	movq	%r14, %rsi
	callq	_write
	movl	(%r13), %edx
	movl	%r12d, %edi
	movq	%r14, %rsi
	callq	_read
	cmpl	(%r13), %eax
	jne	LBB0_23
LBB0_18:                                ## =>This Loop Header: Depth=1
                                        ##     Child Loop BB0_20 Depth 2
	movslq	%eax, %rdx
	cmpl	$256, %edx                      ## imm = 0x100
	jl	LBB0_22
## %bb.19:                              ##   in Loop: Header=BB0_18 Depth=1
	leaq	(%r14,%rdx,4), %rax
	movq	_ecc_offset@GOTPCREL(%rip), %rcx
	movslq	(%rcx), %rcx
	leaq	(%rax,%rcx,4), %r12
	movq	%r14, %rbx
	xorl	%r15d, %r15d
	.p2align	4, 0x90
LBB0_20:                                ##   Parent Loop BB0_18 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	movq	%rbx, %rdi
	movq	%r12, %rsi
	callq	_nand_calculate_ecc
	addq	$12, %r12
	incq	%r15
	movslq	(%r13), %rdx
	leal	255(%rdx), %eax
	testq	%rdx, %rdx
	cmovnsl	%edx, %eax
	sarl	$8, %eax
	cltq
	addq	$1024, %rbx                     ## imm = 0x400
	cmpq	%rax, %r15
	jl	LBB0_20
## %bb.21:                              ##   in Loop: Header=BB0_18 Depth=1
	movl	-48(%rbp), %r12d                ## 4-byte Reload
	movl	-44(%rbp), %ebx                 ## 4-byte Reload
	jmp	LBB0_22
LBB0_23:
	xorl	%r15d, %r15d
	testl	%r12d, %r12d
	js	LBB0_25
LBB0_24:
	movl	%r12d, %edi
	callq	_close
LBB0_25:
	testl	%ebx, %ebx
	js	LBB0_27
## %bb.26:
	movl	%ebx, %edi
	callq	_close
LBB0_27:
	testq	%r14, %r14
	je	LBB0_29
## %bb.28:
	movq	%r14, %rdi
	callq	_free
LBB0_29:
	movl	%r15d, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_13:
	leaq	L_.str.1(%rip), %rdi
	callq	_perror
	movl	$1, %r15d
	jmp	LBB0_29
LBB0_15:
	leaq	L_.str.2(%rip), %rdi
	callq	_perror
	movl	$1, %r15d
	xorl	%r14d, %r14d
	jmp	LBB0_24
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"e:o:p:"

	.comm	_optarg,4,2                     ## @optarg
	.comm	_page_size,4,2                  ## @page_size
	.comm	_oob_size,8,3                   ## @oob_size
	.comm	_ecc_offset,4,2                 ## @ecc_offset
	.comm	_optind,8,3                     ## @optind
	.comm	_O_RDONLY,4,2                   ## @O_RDONLY
L_.str.1:                               ## @.str.1
	.asciz	"open input file"

	.comm	_O_WRONLY,4,2                   ## @O_WRONLY
	.comm	_O_CREAT,4,2                    ## @O_CREAT
	.comm	_O_TRUNC,4,2                    ## @O_TRUNC
L_.str.2:                               ## @.str.2
	.asciz	"open output file"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_main                           ; -- Begin function main
	.p2align	2
_main:                                  ; @main
	.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
	mov	x19, x1
	mov	x20, x0
Lloh0:
	adrp	x22, _optarg@GOTPAGE
Lloh1:
	ldr	x22, [x22, _optarg@GOTPAGEOFF]
Lloh2:
	adrp	x24, _ecc_offset@GOTPAGE
Lloh3:
	ldr	x24, [x24, _ecc_offset@GOTPAGEOFF]
Lloh4:
	adrp	x25, _oob_size@GOTPAGE
Lloh5:
	ldr	x25, [x25, _oob_size@GOTPAGEOFF]
Lloh6:
	adrp	x21, l_.str@PAGE
Lloh7:
	add	x21, x21, l_.str@PAGEOFF
Lloh8:
	adrp	x26, _page_size@GOTPAGE
Lloh9:
	ldr	x26, [x26, _page_size@GOTPAGEOFF]
	b	LBB0_2
LBB0_1:                                 ;   in Loop: Header=BB0_2 Depth=1
	ldr	w0, [x22]
	mov	x1, #0
	mov	w2, #0
	bl	_strtoul
	str	x0, [x25]
LBB0_2:                                 ; =>This Inner Loop Header: Depth=1
	mov	x0, x20
	mov	x1, x19
	mov	x2, x21
	bl	_getopt
	cmp	w0, #110
	b.le	LBB0_6
; %bb.3:                                ;   in Loop: Header=BB0_2 Depth=1
	cmp	w0, #111
	b.eq	LBB0_1
; %bb.4:                                ;   in Loop: Header=BB0_2 Depth=1
	cmp	w0, #112
	b.ne	LBB0_9
; %bb.5:                                ;   in Loop: Header=BB0_2 Depth=1
	ldr	w0, [x22]
	mov	x1, #0
	mov	w2, #0
	bl	_strtoul
	str	w0, [x26]
	b	LBB0_2
LBB0_6:                                 ;   in Loop: Header=BB0_2 Depth=1
	cmp	w0, #101
	b.ne	LBB0_8
; %bb.7:                                ;   in Loop: Header=BB0_2 Depth=1
	ldr	w0, [x22]
	mov	x1, #0
	mov	w2, #0
	bl	_strtoul
	str	w0, [x24]
	b	LBB0_2
LBB0_8:                                 ;   in Loop: Header=BB0_2 Depth=1
	cmn	w0, #1
	b.eq	LBB0_10
LBB0_9:                                 ;   in Loop: Header=BB0_2 Depth=1
	ldr	x0, [x19]
	bl	_usage
	b	LBB0_2
LBB0_10:
Lloh10:
	adrp	x21, _optind@GOTPAGE
Lloh11:
	ldr	x21, [x21, _optind@GOTPAGEOFF]
	ldr	x8, [x21]
	sub	w9, w20, w8
	cmp	w9, #1
	b.gt	LBB0_12
; %bb.11:
	ldr	x0, [x19]
	bl	_usage
	ldr	x8, [x21]
LBB0_12:
	add	x20, x19, x8, lsl #3
	ldr	x0, [x20]
Lloh12:
	adrp	x8, _O_RDONLY@GOTPAGE
Lloh13:
	ldr	x8, [x8, _O_RDONLY@GOTPAGEOFF]
Lloh14:
	ldr	w1, [x8]
	mov	w2, #0
	bl	_open
	tbnz	w0, #31, LBB0_27
; %bb.13:
	mov	x19, x0
	ldr	x0, [x20, #8]
Lloh15:
	adrp	x8, _O_WRONLY@GOTPAGE
Lloh16:
	ldr	x8, [x8, _O_WRONLY@GOTPAGEOFF]
Lloh17:
	ldr	w8, [x8]
Lloh18:
	adrp	x9, _O_CREAT@GOTPAGE
Lloh19:
	ldr	x9, [x9, _O_CREAT@GOTPAGEOFF]
Lloh20:
	ldr	w9, [x9]
	orr	w8, w9, w8
Lloh21:
	adrp	x9, _O_TRUNC@GOTPAGE
Lloh22:
	ldr	x9, [x9, _O_TRUNC@GOTPAGEOFF]
Lloh23:
	ldr	w9, [x9]
	orr	w1, w8, w9
	mov	w2, #420
	bl	_open
	mov	x20, x0
	tbnz	w0, #31, LBB0_28
; %bb.14:
	ldrsw	x8, [x26]
	ldr	x9, [x25]
	add	x0, x9, x8
	bl	_malloc
	mov	x21, x0
	ldr	w2, [x26]
	mov	x0, x19
	mov	x1, x21
	bl	_read
                                        ; kill: def $w0 killed $w0 def $x0
	ldr	w8, [x26]
	cmp	w0, w8
	b.eq	LBB0_17
; %bb.15:
	mov	w22, #0
	b	LBB0_21
LBB0_16:                                ;   in Loop: Header=BB0_17 Depth=1
	ldr	x9, [x25]
	add	x2, x9, x8
	mov	x0, x20
	mov	x1, x21
	bl	_write
	ldr	w2, [x26]
	mov	x0, x19
	mov	x1, x21
	bl	_read
                                        ; kill: def $w0 killed $w0 def $x0
	ldr	w8, [x26]
	cmp	w0, w8
	b.ne	LBB0_20
LBB0_17:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_19 Depth 2
	sxtw	x8, w0
	cmp	w0, #256
	b.lt	LBB0_16
; %bb.18:                               ;   in Loop: Header=BB0_17 Depth=1
	mov	x27, #0
	add	x8, x21, x8, lsl #2
	ldrsw	x9, [x24]
	add	x22, x8, x9, lsl #2
	mov	x23, x21
LBB0_19:                                ;   Parent Loop BB0_17 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	mov	x0, x23
	mov	x1, x22
	bl	_nand_calculate_ecc
	add	x22, x22, #12
	add	x27, x27, #1
	ldrsw	x8, [x26]
	add	w9, w8, #255
	cmp	w8, #0
	csel	w9, w9, w8, lt
	asr	w9, w9, #8
	add	x23, x23, #1024
	cmp	x27, w9, sxtw
	b.lt	LBB0_19
	b	LBB0_16
LBB0_20:
	mov	w22, #0
	tbnz	w19, #31, LBB0_22
LBB0_21:
	mov	x0, x19
	bl	_close
LBB0_22:
	tbnz	w20, #31, LBB0_24
; %bb.23:
	mov	x0, x20
	bl	_close
LBB0_24:
	cbz	x21, LBB0_26
; %bb.25:
	mov	x0, x21
	bl	_free
LBB0_26:
	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_27:
Lloh24:
	adrp	x0, l_.str.1@PAGE
Lloh25:
	add	x0, x0, l_.str.1@PAGEOFF
	bl	_perror
	mov	w22, #1
	b	LBB0_26
LBB0_28:
Lloh26:
	adrp	x0, l_.str.2@PAGE
Lloh27:
	add	x0, x0, l_.str.2@PAGEOFF
	bl	_perror
	mov	x21, #0
	mov	w22, #1
	b	LBB0_21
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpAdd	Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpAdd	Lloh24, Lloh25
	.loh AdrpAdd	Lloh26, Lloh27
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"e:o:p:"

	.comm	_optarg,4,2                     ; @optarg
	.comm	_page_size,4,2                  ; @page_size
	.comm	_oob_size,8,3                   ; @oob_size
	.comm	_ecc_offset,4,2                 ; @ecc_offset
	.comm	_optind,8,3                     ; @optind
	.comm	_O_RDONLY,4,2                   ; @O_RDONLY
l_.str.1:                               ; @.str.1
	.asciz	"open input file"

	.comm	_O_WRONLY,4,2                   ; @O_WRONLY
	.comm	_O_CREAT,4,2                    ; @O_CREAT
	.comm	_O_TRUNC,4,2                    ; @O_TRUNC
l_.str.2:                               ; @.str.2
	.asciz	"open output file"

.subsections_via_symbols
