// File: /workspace/github_c_makefile_star2_O3/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 0x14f0
movl $0x5, %edi
callq 0x1889
leaq 0xdd1(%rip), %rax       # 0x20fc
movzbl 0x1(%rax), %ecx
movl 0x4(%rax), %eax
movl %eax, -0x2c(%rbp)
movl %ecx, -0x30(%rbp)
cmpl $0x1f, %ecx
je 0x1436
movl $0x1, %edx
movl -0x30(%rbp), %ecx
shll %cl, %edx
movl $0x1, %eax
leaq 0xda5(%rip), %rcx       # 0x20fc
movb (%rcx), %cl
movl $0x1, %esi
shlq %cl, %rsi
cmpl $0x2, %edx
cmovll %eax, %edx
movl %edx, -0x44(%rbp)
xorl %r14d, %r14d
movq %rsi, -0x50(%rbp)
leaq 0xf(%rsi), %rax
andq $-0x10, %rax
movq %rax, -0x40(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x1429
xorl %r13d, %r13d
movq %rsp, %rbx
movq %rsp, %r12
subq -0x40(%rbp), %r12
movq %r12, %rsp
movl %r13d, %r15d
movl -0x30(%rbp), %ecx
shll %cl, %r15d
leaq 0xd55(%rip), %rdi       # 0x20fc
movl %r13d, %esi
callq 0x1553
testl %eax, %eax
jne 0x1419
testl %r14d, %r14d
jne 0x13de
leaq 0xd3d(%rip), %rdi       # 0x20fc
movl %r13d, %esi
leaq -0x34(%rbp), %rdx
callq 0x15b1
testl %eax, %eax
jns 0x13de
movl -0x34(%rbp), %esi
leaq 0xd01(%rip), %rdi       # 0x20da
callq 0x1bcd
orl %r14d, %r15d
movl %r15d, %edi
movq %r12, %rsi
movq -0x50(%rbp), %rdx
callq 0x1b38
leaq 0xd05(%rip), %rdi       # 0x20fc
movl %r15d, %esi
movq %r12, %rdx
leaq -0x34(%rbp), %rcx
callq 0x1672
testl %eax, %eax
jns 0x1419
movl -0x34(%rbp), %esi
leaq 0xccc(%rip), %rdi       # 0x20e0
callq 0x1bcd
movq %rbx, %rsp
incl %r13d
cmpl %r13d, -0x2c(%rbp)
jne 0x138a
incl %r14d
cmpl -0x44(%rbp), %r14d
jne 0x137d
movl -0x30(%rbp), %ecx
movl -0x2c(%rbp), %eax
shll %cl, %eax
movl %eax, -0x2c(%rbp)
testl %eax, %eax
je 0x14d9
leaq 0xcac(%rip), %rax       # 0x20fc
movb (%rax), %cl
movl $0x1, %eax
shlq %cl, %rax
xorl %r12d, %r12d
movq %rax, -0x40(%rbp)
leaq 0xf(%rax), %rbx
andq $-0x10, %rbx
movq -0x40(%rbp), %r15
movq %rsp, %r14
movq %rsp, %r13
subq %rbx, %r13
movq %r13, %rsp
movl %r12d, %esi
movl -0x30(%rbp), %ecx
shrl %cl, %esi
leaq 0xc74(%rip), %rdi       # 0x20fc
callq 0x1553
testl %eax, %eax
jne 0x14cd
leaq 0xc64(%rip), %rdi       # 0x20fc
movl %r12d, %esi
xorl %edx, %edx
movq %r15, %rcx
movq %r13, %r8
leaq -0x48(%rbp), %r9
callq 0x17a8
testl %eax, %eax
jns 0x14bf
movl -0x48(%rbp), %esi
leaq 0xc2b(%rip), %rdi       # 0x20e5
callq 0x1bcd
movl %r12d, %edi
movq %r13, %rsi
movq %r15, %rdx
callq 0x1b67
movq %r14, %rsp
incl %r12d
cmpl %r12d, -0x2c(%rbp)
jne 0x146d
callq 0x1996
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop