// File: /workspace/github_c_makefile_star2_O2/dlbeer[P]dhara/tests/nand.c
// Function: main
int main(void)
{
	int i;

	sim_reset();
	sim_inject_bad(5);

	for (i = 0; i < (1 << sim_nand.log2_ppb); i++) {
		int j;

		for (j = 0; j < sim_nand.num_blocks; j++) {
			uint8_t block[1 << sim_nand.log2_page_size];
			dhara_error_t err;
			dhara_page_t p =
				(j << sim_nand.log2_ppb) | i;

			if (dhara_nand_is_bad(&sim_nand, j))
				continue;

			if (!i && (dhara_nand_erase(&sim_nand, j, &err) < 0))
				dabort("erase", err);

			seq_gen(p, block, sizeof(block));
			if (dhara_nand_prog(&sim_nand, p, block, &err) < 0)
				dabort("prog", err);
		}
	}

	for (i = 0; i < (sim_nand.num_blocks << sim_nand.log2_ppb); i++) {
		uint8_t block[1 << sim_nand.log2_page_size];
		dhara_error_t err;

		if (dhara_nand_is_bad(&sim_nand, i >> sim_nand.log2_ppb))
			continue;

		if (dhara_nand_read(&sim_nand, i, 0, sizeof(block),
				    block, &err) < 0)
			dabort("read", err);

		seq_assert(i, block, sizeof(block));
	}

	sim_dump();
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
callq 0x1394
pushq $0x5
popq %rdi
callq 0x17f1
leaq 0xee3(%rip), %rdx       # 0x20fc
movzbl 0x1(%rdx), %ecx
pushq $0x1
popq %rsi
movl %ecx, -0x2c(%rbp)
shll %cl, %esi
movl 0x4(%rdx), %eax
movl %eax, -0x30(%rbp)
movb (%rdx), %cl
pushq $0x1
popq %rax
shlq %cl, %rax
movq %rax, -0x48(%rbp)
xorl %ebx, %ebx
testl %esi, %esi
cmovlel %ebx, %esi
movl %esi, -0x38(%rbp)
addq $0xf, %rax
andq $-0x10, %rax
movq %rax, -0x50(%rbp)
cmpl -0x38(%rbp), %ebx
je 0x1303
xorl %r12d, %r12d
cmpl %r12d, -0x30(%rbp)
je 0x12fc
movq %rsp, %r15
movq %rsp, %r14
subq -0x50(%rbp), %r14
movq %r14, %rsp
movl %r12d, %r13d
movl -0x2c(%rbp), %ecx
shll %cl, %r13d
leaq 0xe7c(%rip), %rdi       # 0x20fc
movl %r12d, %esi
callq 0x13f2
testl %eax, %eax
jne 0x12f1
testl %ebx, %ebx
jne 0x12b6
leaq 0xe65(%rip), %rdi       # 0x20fc
movl %r12d, %esi
leaq -0x34(%rbp), %rdx
callq 0x1480
testl %eax, %eax
jns 0x12b6
movl -0x34(%rbp), %esi
leaq 0xe29(%rip), %rdi       # 0x20da
callq 0x1b03
orl %ebx, %r13d
movl %r13d, %edi
movq %r14, %rsi
movq -0x48(%rbp), %rdx
callq 0x1a74
leaq 0xe2d(%rip), %rdi       # 0x20fc
movl %r13d, %esi
movq %r14, %rdx
leaq -0x34(%rbp), %rcx
callq 0x1585
testl %eax, %eax
jns 0x12f1
movl -0x34(%rbp), %esi
leaq 0xdf4(%rip), %rdi       # 0x20e0
callq 0x1b03
movq %r15, %rsp
incl %r12d
jmp 0x1259
incl %ebx
jmp 0x124d
movl -0x2c(%rbp), %ecx
shll %cl, -0x30(%rbp)
xorl %r15d, %r15d
leaq 0xde9(%rip), %r12       # 0x20fc
movq -0x48(%rbp), %r13
cmpl %r15d, -0x30(%rbp)
je 0x137e
movq %rsp, %rbx
movq %rsp, %r14
subq -0x50(%rbp), %r14
movq %r14, %rsp
movl %r15d, %esi
movl -0x2c(%rbp), %ecx
shrl %cl, %esi
movq %r12, %rdi
callq 0x13f2
testl %eax, %eax
jne 0x1376
movq %r12, %rdi
movl %r15d, %esi
xorl %edx, %edx
movq %r13, %rcx
movq %r14, %r8
leaq -0x3c(%rbp), %r9
callq 0x16f5
testl %eax, %eax
jns 0x1368
movl -0x3c(%rbp), %esi
leaq 0xd82(%rip), %rdi       # 0x20e5
callq 0x1b03
movl %r15d, %edi
movq %r14, %rsi
movq %r13, %rdx
callq 0x1aa0
movq %rbx, %rsp
incl %r15d
jmp 0x1317
callq 0x18c0
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq