// File: /workspace/github_c_makefile_star2_O0/dlbeer[P]dhara/tests/map.c
// Function: test
static void test(void)
{
	const size_t page_size = 1 << sim_nand.log2_page_size;
	uint8_t page_buf[page_size];
	struct dhara_map map;
	int i;

	printf("%d\n", (int)sizeof(map));

	sim_reset();
	sim_inject_bad(10);
	sim_inject_timebombs(30, 20);

	printf("Map init\n");
	dhara_map_init(&map, &sim_nand, page_buf, GC_RATIO);
	dhara_map_resume(&map, NULL);
	printf("  capacity: %d\n", dhara_map_capacity(&map));
	printf("  sector count: %d\n", NUM_SECTORS);
	printf("\n");

	printf("Sync...\n");
	dhara_map_sync(&map, NULL);
	printf("Resume...\n");
	dhara_map_init(&map, &sim_nand, page_buf, GC_RATIO);
	dhara_map_resume(&map, NULL);

	printf("Writing sectors...\n");
	shuffle(0);
	for (i = 0; i < NUM_SECTORS; i++) {
		const dhara_sector_t s = sector_list[i];

		mt_write(&map, s, s);
		mt_check(&map);
	}

	printf("Sync...\n");
	dhara_map_sync(&map, NULL);
	printf("Resume...\n");
	dhara_map_init(&map, &sim_nand, page_buf, GC_RATIO);
	dhara_map_resume(&map, NULL);
	printf("  capacity: %d\n", dhara_map_capacity(&map));
	printf("  use count: %d\n", dhara_map_size(&map));
	printf("\n");

	printf("Read back...\n");
	shuffle(1);
	for (i = 0; i < NUM_SECTORS; i++) {
		const dhara_sector_t s = sector_list[i];

		mt_assert(&map, s, s);
	}

	printf("Rewrite/trim half...\n");
	shuffle(2);
	for (i = 0; i < NUM_SECTORS; i += 2) {
		const dhara_sector_t s0 = sector_list[i];
		const dhara_sector_t s1 = sector_list[i + 1];

		mt_write(&map, s0, ~s0);
		mt_check(&map);
		mt_trim(&map, s1);
		mt_check(&map);
	}

	printf("Sync...\n");
	dhara_map_sync(&map, NULL);
	printf("Resume...\n");
	dhara_map_init(&map, &sim_nand, page_buf, GC_RATIO);
	dhara_map_resume(&map, NULL);
	printf("  capacity: %d\n", dhara_map_capacity(&map));
	printf("  use count: %d\n", dhara_map_size(&map));
	printf("\n");

	printf("Read back...\n");
	for (i = 0; i < NUM_SECTORS; i += 2) {
		const dhara_sector_t s0 = sector_list[i];
		const dhara_sector_t s1 = sector_list[i + 1];

		mt_assert(&map, s0, ~s0);
		mt_assert_blank(&map, s1);
	}

	printf("\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
leaq 0x2002(%rip), %rax      # 0x6314
movb (%rax), %cl
movl $0x1, %eax
shll %cl, %eax
cltq
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rsp, %rcx
movq %rcx, -0x10(%rbp)
movq %rax, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x80(%rbp)
movq %rcx, %rsp
movq %rax, -0x18(%rbp)
leaq 0x22b8(%rip), %rdi      # 0x6607
movl $0x40, %esi
movb $0x0, %al
callq 0x1050
callq 0x4d20
movl $0xa, %edi
callq 0x54e0
movl $0x1e, %edi
movl $0x14, %esi
callq 0x5580
leaq 0x1d82(%rip), %rdi      # 0x6102
movb $0x0, %al
callq 0x1050
movq -0x80(%rbp), %rdx
leaq -0x58(%rbp), %rdi
leaq 0x1f7e(%rip), %rsi      # 0x6314
movl $0x4, %ecx
callq 0x11c0
leaq -0x58(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1210
leaq -0x58(%rbp), %rdi
callq 0x12e0
movl %eax, %esi
leaq 0x1d4d(%rip), %rdi      # 0x610c
movb $0x0, %al
callq 0x1050
leaq 0x1d4f(%rip), %rdi      # 0x611c
movl $0xc8, %esi
movb $0x0, %al
callq 0x1050
leaq 0x20b2(%rip), %rdi      # 0x6492
movb $0x0, %al
callq 0x1050
leaq 0x1d42(%rip), %rdi      # 0x6130
movb $0x0, %al
callq 0x1050
leaq -0x58(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1ec0
leaq 0x1d30(%rip), %rdi      # 0x6139
movb $0x0, %al
callq 0x1050
movq -0x80(%rbp), %rdx
leaq -0x58(%rbp), %rdi
leaq 0x1ef5(%rip), %rsi      # 0x6314
movl $0x4, %ecx
callq 0x11c0
leaq -0x58(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1210
leaq 0x1d07(%rip), %rdi      # 0x6144
movb $0x0, %al
callq 0x1050
xorl %edi, %edi
callq 0x4720
movl $0x0, -0x5c(%rbp)
cmpl $0xc8, -0x5c(%rbp)
jge 0x448f
movslq -0x5c(%rbp), %rcx
leaq 0x4c1a(%rip), %rax      # 0x9080
movl (%rax,%rcx,4), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %esi
movl -0x60(%rbp), %edx
leaq -0x58(%rbp), %rdi
callq 0x47e0
leaq -0x58(%rbp), %rdi
callq 0x4870
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x4452
leaq 0x1c9a(%rip), %rdi      # 0x6130
movb $0x0, %al
callq 0x1050
leaq -0x58(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1ec0
leaq 0x1c88(%rip), %rdi      # 0x6139
movb $0x0, %al
callq 0x1050
movq -0x80(%rbp), %rdx
leaq -0x58(%rbp), %rdi
leaq 0x1e4d(%rip), %rsi      # 0x6314
movl $0x4, %ecx
callq 0x11c0
leaq -0x58(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1210
leaq -0x58(%rbp), %rdi
callq 0x12e0
movl %eax, %esi
leaq 0x1c1c(%rip), %rdi      # 0x610c
movb $0x0, %al
callq 0x1050
leaq -0x58(%rbp), %rdi
callq 0x48f0
movl %eax, %esi
leaq 0x1c4f(%rip), %rdi      # 0x6158
movb $0x0, %al
callq 0x1050
leaq 0x1f7b(%rip), %rdi      # 0x6492
movb $0x0, %al
callq 0x1050
leaq 0x1c44(%rip), %rdi      # 0x6169
movb $0x0, %al
callq 0x1050
movl $0x1, %edi
callq 0x4720
movl $0x0, -0x5c(%rbp)
cmpl $0xc8, -0x5c(%rbp)
jge 0x4571
movslq -0x5c(%rbp), %rcx
leaq 0x4b2f(%rip), %rax      # 0x9080
movl (%rax,%rcx,4), %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %esi
movl -0x64(%rbp), %edx
leaq -0x58(%rbp), %rdi
callq 0x4900
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x453d
leaq 0x1bff(%rip), %rdi      # 0x6177
movb $0x0, %al
callq 0x1050
movl $0x2, %edi
callq 0x4720
movl $0x0, -0x5c(%rbp)
cmpl $0xc8, -0x5c(%rbp)
jge 0x45fb
movslq -0x5c(%rbp), %rcx
leaq 0x4adc(%rip), %rax      # 0x9080
movl (%rax,%rcx,4), %eax
movl %eax, -0x68(%rbp)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0x4ac6(%rip), %rax      # 0x9080
movl (%rax,%rcx,4), %eax
movl %eax, -0x6c(%rbp)
movl -0x68(%rbp), %esi
movl -0x68(%rbp), %edx
xorl $-0x1, %edx
leaq -0x58(%rbp), %rdi
callq 0x47e0
leaq -0x58(%rbp), %rdi
callq 0x4870
movl -0x6c(%rbp), %esi
leaq -0x58(%rbp), %rdi
callq 0x49a0
leaq -0x58(%rbp), %rdi
callq 0x4870
movl -0x5c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x5c(%rbp)
jmp 0x4590
leaq 0x1b2e(%rip), %rdi      # 0x6130
movb $0x0, %al
callq 0x1050
leaq -0x58(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1ec0
leaq 0x1b1c(%rip), %rdi      # 0x6139
movb $0x0, %al
callq 0x1050
movq -0x80(%rbp), %rdx
leaq -0x58(%rbp), %rdi
leaq 0x1ce1(%rip), %rsi      # 0x6314
movl $0x4, %ecx
callq 0x11c0
leaq -0x58(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1210
leaq -0x58(%rbp), %rdi
callq 0x12e0
movl %eax, %esi
leaq 0x1ab0(%rip), %rdi      # 0x610c
movb $0x0, %al
callq 0x1050
leaq -0x58(%rbp), %rdi
callq 0x48f0
movl %eax, %esi
leaq 0x1ae3(%rip), %rdi      # 0x6158
movb $0x0, %al
callq 0x1050
leaq 0x1e0f(%rip), %rdi      # 0x6492
movb $0x0, %al
callq 0x1050
leaq 0x1ad8(%rip), %rdi      # 0x6169
movb $0x0, %al
callq 0x1050
movl $0x0, -0x5c(%rbp)
cmpl $0xc8, -0x5c(%rbp)
jge 0x46f8
movslq -0x5c(%rbp), %rcx
leaq 0x49cd(%rip), %rax      # 0x9080
movl (%rax,%rcx,4), %eax
movl %eax, -0x70(%rbp)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0x49b7(%rip), %rax      # 0x9080
movl (%rax,%rcx,4), %eax
movl %eax, -0x74(%rbp)
movl -0x70(%rbp), %esi
movl -0x70(%rbp), %edx
xorl $-0x1, %edx
leaq -0x58(%rbp), %rdi
callq 0x4900
movl -0x74(%rbp), %esi
leaq -0x58(%rbp), %rdi
callq 0x49e0
movl -0x5c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x5c(%rbp)
jmp 0x469f
leaq 0x1d93(%rip), %rdi      # 0x6492
movb $0x0, %al
callq 0x1050
movq -0x10(%rbp), %rax
movq %rax, %rsp
movq %rbp, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)