// File: /workspace/github_c_makefile_star2_O0/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
subq $0x70, %rsp
movl $0x0, -0x4(%rbp)
callq 0x1480
movl $0x5, %edi
callq 0x1c40
movl $0x0, -0x8(%rbp)
movl -0x8(%rbp), %eax
leaq 0x1e89(%rip), %rcx      # 0x30c8
movzbl 0x1(%rcx), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
jge 0x1379
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
leaq 0x1e63(%rip), %rcx      # 0x30c8
cmpl 0x4(%rcx), %eax
jae 0x1369
leaq 0x1e53(%rip), %rax      # 0x30c8
movb (%rax), %cl
movl $0x1, %eax
shll %cl, %eax
movq %rax, -0x58(%rbp)
movq %rsp, %rcx
movq %rcx, -0x18(%rbp)
movq %rax, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x50(%rbp)
movq %rcx, %rsp
movq %rax, -0x20(%rbp)
movl -0xc(%rbp), %eax
leaq 0x1e19(%rip), %rcx      # 0x30c8
movzbl 0x1(%rcx), %ecx
shll %cl, %eax
orl -0x8(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0xc(%rbp), %esi
leaq 0x1e03(%rip), %rdi      # 0x30c8
callq 0x1500
cmpl $0x0, %eax
je 0x12d8
movl $0x7, -0x2c(%rbp)
jmp 0x1347
cmpl $0x0, -0x8(%rbp)
jne 0x1305
movl -0xc(%rbp), %esi
leaq 0x1de0(%rip), %rdi      # 0x30c8
leaq -0x24(%rbp), %rdx
callq 0x15e0
cmpl $0x0, %eax
jge 0x1305
movl -0x24(%rbp), %esi
leaq 0x1db6(%rip), %rdi      # 0x30b6
callq 0x2090
movq -0x50(%rbp), %rsi
movq -0x58(%rbp), %rdx
movl -0x28(%rbp), %edi
callq 0x1f80
movq -0x50(%rbp), %rdx
movl -0x28(%rbp), %esi
leaq 0x1da5(%rip), %rdi      # 0x30c8
leaq -0x24(%rbp), %rcx
callq 0x17b0
cmpl $0x0, %eax
jge 0x1340
movl -0x24(%rbp), %esi
leaq 0x1d81(%rip), %rdi      # 0x30bc
callq 0x2090
movl $0x0, -0x2c(%rbp)
movq -0x18(%rbp), %rax
movq %rax, %rsp
movl -0x2c(%rbp), %eax
testl %eax, %eax
je 0x1359
jmp 0x1357
jmp 0x135b
jmp 0x135b
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x125b
jmp 0x136b
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x1235
movl $0x0, -0x8(%rbp)
movl -0x8(%rbp), %eax
leaq 0x1d3e(%rip), %rcx      # 0x30c8
movl 0x4(%rcx), %edx
leaq 0x1d34(%rip), %rcx      # 0x30c8
movzbl 0x1(%rcx), %ecx
shll %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
jae 0x1471
leaq 0x1d1d(%rip), %rax      # 0x30c8
movb (%rax), %cl
movl $0x1, %eax
shll %cl, %eax
movq %rax, -0x68(%rbp)
movq %rsp, %rcx
movq %rcx, -0x38(%rbp)
movq %rax, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x60(%rbp)
movq %rcx, %rsp
movq %rax, -0x40(%rbp)
movl -0x8(%rbp), %esi
leaq 0x1ce3(%rip), %rax      # 0x30c8
movzbl 0x1(%rax), %ecx
sarl %cl, %esi
leaq 0x1cd6(%rip), %rdi      # 0x30c8
callq 0x1500
cmpl $0x0, %eax
je 0x1405
movl $0xa, -0x2c(%rbp)
jmp 0x144f
movq -0x60(%rbp), %r8
movq -0x68(%rbp), %rcx
movl -0x8(%rbp), %esi
leaq 0x1cb1(%rip), %rdi      # 0x30c8
xorl %eax, %eax
movl %eax, %edx
leaq -0x44(%rbp), %r9
callq 0x1a30
cmpl $0x0, %eax
jge 0x1438
movl -0x44(%rbp), %esi
leaq 0x1c8e(%rip), %rdi      # 0x30c1
callq 0x2090
movq -0x68(%rbp), %rdx
movq -0x60(%rbp), %rsi
movl -0x8(%rbp), %edi
callq 0x1fe0
movl $0x0, -0x2c(%rbp)
movq -0x38(%rbp), %rax
movq %rax, %rsp
movl -0x2c(%rbp), %eax
testl %eax, %eax
je 0x1461
jmp 0x145f
jmp 0x1463
jmp 0x1463
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x1380
callq 0x1d70
xorl %eax, %eax
movq %rbp, %rsp
popq %rbp
retq
nopl (%rax)