	.file	"extr_nand_ecc.c_main.c"
	.intel_syntax noprefix
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"e:o:p:"
.LC1:
	.string	"open input file"
.LC2:
	.string	"open output file"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	push	r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	push	r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	push	r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	push	r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	lea	r12, .LC0[rip]
	push	rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	mov	ebp, edi
	push	rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	mov	rbx, rsi
	sub	rsp, 8
	.cfi_def_cfa_offset 64
	.p2align 4,,10
	.p2align 3
.L2:
	mov	rdx, r12
	mov	rsi, rbx
	mov	edi, ebp
	call	getopt@PLT
	cmp	eax, -1
	je	.L24
	cmp	eax, 111
	je	.L3
	cmp	eax, 112
	je	.L4
	cmp	eax, 101
	je	.L25
	mov	rdi, QWORD PTR [rbx]
	call	usage@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L3:
	mov	edi, DWORD PTR optarg[rip]
	xor	edx, edx
	xor	esi, esi
	call	strtoul@PLT
	mov	QWORD PTR oob_size[rip], rax
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L25:
	mov	edi, DWORD PTR optarg[rip]
	xor	edx, edx
	xor	esi, esi
	call	strtoul@PLT
	mov	DWORD PTR ecc_offset[rip], eax
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L4:
	mov	edi, DWORD PTR optarg[rip]
	xor	edx, edx
	xor	esi, esi
	call	strtoul@PLT
	mov	DWORD PTR page_size[rip], eax
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L24:
	mov	rax, QWORD PTR optind[rip]
	sub	ebp, eax
	cmp	ebp, 1
	jle	.L26
.L9:
	lea	rbx, [rbx+rax*8]
	mov	esi, DWORD PTR O_RDONLY[rip]
	xor	edx, edx
	mov	rdi, QWORD PTR [rbx]
	call	open@PLT
	mov	r12d, eax
	test	eax, eax
	js	.L27
	mov	rdi, QWORD PTR 8[rbx]
	mov	esi, DWORD PTR O_WRONLY[rip]
	mov	edx, 420
	or	esi, DWORD PTR O_CREAT[rip]
	or	esi, DWORD PTR O_TRUNC[rip]
	call	open@PLT
	mov	r13d, eax
	test	eax, eax
	js	.L28
	movsx	rdi, DWORD PTR page_size[rip]
	add	rdi, QWORD PTR oob_size[rip]
	call	malloc@PLT
	mov	rbp, rax
	.p2align 4,,10
	.p2align 3
.L13:
	mov	edx, DWORD PTR page_size[rip]
	mov	rsi, rbp
	mov	edi, r12d
	call	read@PLT
	mov	ecx, DWORD PTR page_size[rip]
	cmp	ecx, eax
	jne	.L29
	movsx	rax, DWORD PTR ecc_offset[rip]
	movsx	rdx, ecx
	add	rax, rdx
	lea	rbx, 0[rbp+rax*4]
	cmp	ecx, 255
	jle	.L14
	mov	r15, rbp
	xor	r14d, r14d
	.p2align 4,,10
	.p2align 3
.L15:
	mov	rsi, rbx
	mov	rdi, r15
	add	rbx, 12
	add	r14d, 1
	call	nand_calculate_ecc@PLT
	mov	ecx, DWORD PTR page_size[rip]
	add	r15, 1024
	lea	eax, 255[rcx]
	test	ecx, ecx
	cmovns	eax, ecx
	sar	eax, 8
	cmp	eax, r14d
	jg	.L15
	movsx	rdx, ecx
.L14:
	add	rdx, QWORD PTR oob_size[rip]
	mov	rsi, rbp
	mov	edi, r13d
	call	write@PLT
	jmp	.L13
.L29:
	mov	edi, r12d
	call	close@PLT
	mov	edi, r13d
	call	close@PLT
	test	rbp, rbp
	je	.L30
	mov	rdi, rbp
	call	free@PLT
	xor	eax, eax
.L1:
	add	rsp, 8
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	pop	rbx
	.cfi_def_cfa_offset 48
	pop	rbp
	.cfi_def_cfa_offset 40
	pop	r12
	.cfi_def_cfa_offset 32
	pop	r13
	.cfi_def_cfa_offset 24
	pop	r14
	.cfi_def_cfa_offset 16
	pop	r15
	.cfi_def_cfa_offset 8
	ret
.L27:
	.cfi_restore_state
	lea	rdi, .LC1[rip]
	call	perror@PLT
	mov	eax, 1
	jmp	.L1
.L26:
	mov	rdi, QWORD PTR [rbx]
	call	usage@PLT
	mov	rax, QWORD PTR optind[rip]
	jmp	.L9
.L28:
	lea	rdi, .LC2[rip]
	call	perror@PLT
	mov	edi, r12d
	call	close@PLT
	mov	eax, 1
	jmp	.L1
.L30:
	xor	eax, eax
	jmp	.L1
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.comm	page_size,4,4
	.comm	optind,8,8
	.comm	optarg,4,4
	.comm	oob_size,8,8
	.comm	ecc_offset,4,4
	.comm	O_WRONLY,4,4
	.comm	O_TRUNC,4,4
	.comm	O_RDONLY,4,4
	.comm	O_CREAT,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	 1f - 0f
	.long	 4f - 1f
	.long	 5
0:
	.string	 "GNU"
1:
	.align 8
	.long	 0xc0000002
	.long	 3f - 2f
2:
	.long	 0x3
3:
	.align 8
4:

	.arch armv5t
	.eabi_attribute 20, 1
	.eabi_attribute 21, 1
	.eabi_attribute 23, 3
	.eabi_attribute 24, 1
	.eabi_attribute 25, 1
	.eabi_attribute 26, 2
	.eabi_attribute 30, 2
	.eabi_attribute 34, 0
	.eabi_attribute 18, 4
	.file	"extr_nand_ecc.c_main.c"
	.text
	.section	.rodata.str1.4,"aMS",%progbits,1
	.align	2
.LC0:
	.ascii	"e:o:p:\000"
	.align	2
.LC1:
	.ascii	"open input file\000"
	.align	2
.LC2:
	.ascii	"open output file\000"
	.section	.text.startup,"ax",%progbits
	.align	2
	.global	main
	.syntax unified
	.arm
	.fpu softvfp
	.type	main, %function
main:
	@ args = 0, pretend = 0, frame = 0
	@ frame_needed = 0, uses_anonymous_args = 0
	push	{r3, r4, r5, r6, r7, r8, r9, r10, fp, lr}
	mov	r5, r0
	mov	r4, r1
	ldr	r6, .L31
	ldr	r7, .L31+4
	ldr	r10, .L31+8
	ldr	r9, .L31+12
	ldr	r8, .L31+16
.L2:
	mov	r2, r6
	mov	r1, r4
	mov	r0, r5
	bl	getopt
	cmn	r0, #1
	beq	.L25
	cmp	r0, #111
	beq	.L3
	cmp	r0, #112
	beq	.L4
	cmp	r0, #101
	beq	.L26
	ldr	r0, [r4]
	bl	usage
	b	.L2
.L3:
	mov	r2, #0
	ldr	r0, [r7]
	mov	r1, r2
	bl	strtoul
	str	r0, [r10]
	b	.L2
.L26:
	mov	r2, #0
	ldr	r0, [r7]
	mov	r1, r2
	bl	strtoul
	str	r0, [r8]
	b	.L2
.L4:
	mov	r2, #0
	ldr	r0, [r7]
	mov	r1, r2
	bl	strtoul
	str	r0, [r9]
	b	.L2
.L25:
	ldr	r6, .L31+20
	ldr	r3, [r6]
	sub	r5, r5, r3
	cmp	r5, #1
	ble	.L27
.L9:
	ldr	r1, .L31+24
	ldr	r0, [r4, r3, lsl #2]
	mov	r2, #0
	ldr	r1, [r1]
	add	r4, r4, r3, lsl #2
	bl	open
	subs	r6, r0, #0
	blt	.L28
	ldr	r3, .L31+28
	ldr	r2, .L31+32
	ldr	r1, .L31+36
	ldr	r2, [r2]
	ldr	r3, [r3]
	ldr	r1, [r1]
	orr	r3, r3, r2
	ldr	r0, [r4, #4]
	mov	r2, #420
	orr	r1, r3, r1
	bl	open
	subs	r7, r0, #0
	blt	.L29
	ldr	r8, .L31+8
	ldr	r4, .L31+12
	ldr	r0, [r8]
	ldr	r3, [r4]
	add	r0, r0, r3
	bl	malloc
	mov	r5, r0
.L13:
	mov	r1, r5
	mov	r0, r6
	ldr	r2, [r4]
	bl	read
	ldr	r3, [r4]
	cmp	r3, r0
	bne	.L30
	ldr	r2, .L31+16
	cmp	r3, #255
	ldr	r1, [r2]
	add	r1, r3, r1
	add	r9, r5, r1, lsl #2
	ble	.L14
	mov	fp, r5
	mov	r10, #0
.L15:
	mov	r1, r9
	mov	r0, fp
	bl	nand_calculate_ecc
	ldr	r3, [r4]
	add	r10, r10, #1
	cmp	r3, #0
	add	r2, r3, #255
	movge	r2, r3
	cmp	r10, r2, asr #8
	add	r9, r9, #12
	add	fp, fp, #1024
	blt	.L15
.L14:
	ldr	r2, [r8]
	mov	r1, r5
	mov	r0, r7
	add	r2, r2, r3
	bl	write
	b	.L13
.L30:
	mov	r0, r6
	bl	close
	mov	r0, r7
	bl	close
	subs	r0, r5, #0
	popeq	{r3, r4, r5, r6, r7, r8, r9, r10, fp, pc}
	bl	free
	mov	r0, #0
	pop	{r3, r4, r5, r6, r7, r8, r9, r10, fp, pc}
.L28:
	ldr	r0, .L31+40
	bl	perror
	mov	r0, #1
	pop	{r3, r4, r5, r6, r7, r8, r9, r10, fp, pc}
.L27:
	ldr	r0, [r4]
	bl	usage
	ldr	r3, [r6]
	b	.L9
.L29:
	ldr	r0, .L31+44
	bl	perror
	mov	r0, r6
	bl	close
	mov	r0, #1
	pop	{r3, r4, r5, r6, r7, r8, r9, r10, fp, pc}
.L32:
	.align	2
.L31:
	.word	.LC0
	.word	optarg
	.word	oob_size
	.word	page_size
	.word	ecc_offset
	.word	optind
	.word	O_RDONLY
	.word	O_WRONLY
	.word	O_CREAT
	.word	O_TRUNC
	.word	.LC1
	.word	.LC2
	.size	main, .-main
	.comm	page_size,4,4
	.comm	optind,4,4
	.comm	optarg,4,4
	.comm	oob_size,4,4
	.comm	ecc_offset,4,4
	.comm	O_WRONLY,4,4
	.comm	O_TRUNC,4,4
	.comm	O_RDONLY,4,4
	.comm	O_CREAT,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
