// File: /workspace/github_c_makefile_star2_O1/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 0x1500
movl $0x5, %edi
callq 0x189d
leaq 0xdd1(%rip), %rax       # 0x20fc
movzbl 0x1(%rax), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x1f, %eax
je 0x1436
movl $0x1, %eax
movl $0x1, %edx
movl -0x2c(%rbp), %ecx
shll %cl, %edx
leaq 0xdab(%rip), %rcx       # 0x20fc
movl 0x4(%rcx), %esi
movl %esi, -0x38(%rbp)
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, -0x38(%rbp)
je 0x1429
xorl %r13d, %r13d
movq %rsp, %rbx
movq %rsp, %r12
subq -0x40(%rbp), %r12
movq %r12, %rsp
movl %r13d, %r15d
movl -0x2c(%rbp), %ecx
shll %cl, %r15d
leaq 0xd55(%rip), %rdi       # 0x20fc
movl %r13d, %esi
callq 0x1563
testl %eax, %eax
jne 0x1419
testl %r14d, %r14d
jne 0x13de
leaq 0xd3d(%rip), %rdi       # 0x20fc
movl %r13d, %esi
leaq -0x30(%rbp), %rdx
callq 0x15c1
testl %eax, %eax
jns 0x13de
movl -0x30(%rbp), %esi
leaq 0xd01(%rip), %rdi       # 0x20da
callq 0x1bfd
orl %r14d, %r15d
movl %r15d, %edi
movq %r12, %rsi
movq -0x50(%rbp), %rdx
callq 0x1b68
leaq 0xd05(%rip), %rdi       # 0x20fc
movl %r15d, %esi
movq %r12, %rdx
leaq -0x30(%rbp), %rcx
callq 0x1683
testl %eax, %eax
jns 0x1419
movl -0x30(%rbp), %esi
leaq 0xccc(%rip), %rdi       # 0x20e0
callq 0x1bfd
movq %rbx, %rsp
incl %r13d
cmpl %r13d, -0x38(%rbp)
jne 0x138a
incl %r14d
cmpl -0x44(%rbp), %r14d
jne 0x137d
leaq 0xcbf(%rip), %rax       # 0x20fc
movl 0x4(%rax), %ebx
movl -0x2c(%rbp), %ecx
shll %cl, %ebx
testl %ebx, %ebx
je 0x14ea
leaq 0xca8(%rip), %rax       # 0x20fc
movb (%rax), %cl
movl $0x1, %eax
shlq %cl, %rax
xorl %r12d, %r12d
movq %rax, -0x38(%rbp)
leaq 0xf(%rax), %r14
andq $-0x10, %r14
movq %r14, -0x40(%rbp)
movq %rsp, %r15
movq %rsp, %r13
subq %r14, %r13
movq %r13, %rsp
movl %r12d, %esi
movl -0x2c(%rbp), %ecx
shrl %cl, %esi
leaq 0xc70(%rip), %rdi       # 0x20fc
callq 0x1563
testl %eax, %eax
jne 0x14df
movl %ebx, %r14d
leaq 0xc5d(%rip), %rdi       # 0x20fc
movl %r12d, %esi
xorl %edx, %edx
movq -0x38(%rbp), %rbx
movq %rbx, %rcx
movq %r13, %r8
leaq -0x48(%rbp), %r9
callq 0x17b9
testl %eax, %eax
jns 0x14ca
movl -0x48(%rbp), %esi
leaq 0xc20(%rip), %rdi       # 0x20e5
callq 0x1bfd
movl %r12d, %edi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x1b97
movl %r14d, %ebx
movq -0x40(%rbp), %r14
movq %r15, %rsp
incl %r12d
cmpl %r12d, %ebx
jne 0x1471
callq 0x19aa
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq