LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/dhara/map.c
// Function: dhara_map_sync
int dhara_map_sync(struct dhara_map *m, dhara_error_t *err)
{
	while (!dhara_journal_is_clean(&m->journal)) {
		dhara_page_t p = dhara_journal_peek(&m->journal);
		dhara_error_t my_err;
		int ret;

		if (p == DHARA_PAGE_NONE) {
			ret = pad_queue(m, &my_err);
		} else {
			ret = raw_gc(m, p, &my_err);
			if (!ret)
				dhara_journal_dequeue(&m->journal);
		}

		if ((ret < 0) && (try_recover(m, my_err, err) < 0))
			return -1;
	}

	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
xorl %ebx, %ebx
testb $0x1, 0x12(%rdi)
je 0x1aa1
movq %rsi, %r14
movq %rdi, %r15
leaq 0x4(%rsp), %r12
movq %r15, %rdi
callq 0x22ac
movq %r15, %rdi
cmpl $-0x1, %eax
je 0x1a74
movl %eax, %esi
movq %r12, %rdx
callq 0x1b23
testl %eax, %eax
jne 0x1a80
movq %r15, %rdi
callq 0x234f
jmp 0x1a93
movq %r12, %rsi
callq 0x1aaf
testl %eax, %eax
jns 0x1a93
movl 0x4(%rsp), %esi
movq %r15, %rdi
movq %r14, %rdx
callq 0x16a5
testl %eax, %eax
js 0x1a9c
testb $0x1, 0x12(%r15)
jne 0x1a4c
jmp 0x1aa1
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/dhara/map.c
// Function: pad_queue
static int pad_queue(struct dhara_map *m, dhara_error_t *err)
{
	dhara_page_t p = dhara_journal_root(&m->journal);
	uint8_t root_meta[DHARA_META_SIZE];

	ck_set_count(dhara_journal_cookie(&m->journal), m->count);

	if (p == DHARA_PAGE_NONE)
		return dhara_journal_enqueue(&m->journal, NULL, NULL, err);

	if (dhara_journal_read_meta(&m->journal, p, root_meta, err) < 0)
		return -1;

	return dhara_journal_copy(&m->journal, p, root_meta, err);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x90, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movl 0x28(%rdi), %ebp
movq 0x8(%rdi), %rax
movl 0x3c(%rdi), %ecx
movl %ecx, 0x10(%rax)
cmpl $-0x1, %ebp
je 0x1af8
movq %rsp, %rdx
movq %r14, %rdi
movl %ebp, %esi
movq %rbx, %rcx
callq 0x2226
testl %eax, %eax
js 0x1b12
movq %rsp, %rdx
movq %r14, %rdi
movl %ebp, %esi
movq %rbx, %rcx
callq 0x2809
jmp 0x1b17
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
movq %rbx, %rcx
addq $0x90, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x23f1
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x90, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/dhara/map.c
// Function: raw_gc
static int raw_gc(struct dhara_map *m, dhara_page_t src,
		  dhara_error_t *err)
{
	dhara_sector_t target;
	dhara_page_t current;
	dhara_error_t my_err;
	uint8_t meta[DHARA_META_SIZE];

	if (dhara_journal_read_meta(&m->journal, src, meta, err) < 0)
		return -1;

	/* Is the page just filler/garbage? */
	target = meta_get_id(meta);
	if (target == DHARA_SECTOR_NONE)
		return 0;

	/* Find out where the sector once represented by this page
	 * currently resides (if anywhere).
	 */
	if (trace_path(m, target, &current, meta, &my_err) < 0) {
		if (my_err == DHARA_E_NOT_FOUND)
			return 0;

		dhara_set_error(err, my_err);
		return -1;
	}

	/* Is this page still the most current representative? If not,
	 * do nothing.
	 */
	if (current != src)
		return 0;

	/* Rewrite it at the front of the journal with updated metadata */
	ck_set_count(dhara_journal_cookie(&m->journal), m->count);
	if (dhara_journal_copy(&m->journal, src, meta, err) < 0)
		return -1;

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x98, %rsp
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r14
leaq 0x10(%rsp), %rdx
movq %rbx, %rcx
callq 0x2226
testl %eax, %eax
js 0x1bac
movl 0x10(%rsp), %esi
xorl %r15d, %r15d
cmpl $-0x1, %esi
je 0x1bb2
leaq 0xc(%rsp), %rdx
leaq 0x10(%rsp), %rcx
leaq 0x8(%rsp), %r8
movq %r14, %rdi
callq 0x1379
testl %eax, %eax
js 0x1b9c
cmpl %ebp, 0xc(%rsp)
jne 0x1bb2
movq 0x8(%r14), %rax
movl 0x3c(%r14), %ecx
movl %ecx, 0x10(%rax)
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
movl %ebp, %esi
movq %rbx, %rcx
callq 0x2809
movl %eax, %r15d
sarl $0x1f, %r15d
jmp 0x1bb2
movl 0x8(%rsp), %eax
cmpl $0x6, %eax
je 0x1bb2
testq %rbx, %rbx
je 0x1bac
movl %eax, (%rbx)
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movl %r15d, %eax
addq $0x98, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/dhara/map.c
// Function: dhara_map_gc
int dhara_map_gc(struct dhara_map *m, dhara_error_t *err)
{
	if (!m->count)
		return 0;

	for (;;) {
		dhara_page_t tail = dhara_journal_peek(&m->journal);
		dhara_error_t my_err;

		if (tail == DHARA_PAGE_NONE)
			break;

		if (!raw_gc(m, tail, &my_err)) {
			dhara_journal_dequeue(&m->journal);
			break;
		}

		if (try_recover(m, my_err, err) < 0)
			return -1;
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
xorl %ebx, %ebx
cmpl $0x0, 0x3c(%rdi)
je 0x1c31
movq %rsi, %r14
movq %rdi, %r15
leaq 0xc(%rsp), %r12
movq %r15, %rdi
callq 0x22ac
movl $0x2, %ebp
cmpl $-0x1, %eax
je 0x1c23
movq %r15, %rdi
movl %eax, %esi
movq %r12, %rdx
callq 0x1b23
testl %eax, %eax
je 0x1c1b
movl 0xc(%rsp), %esi
movq %r15, %rdi
movq %r14, %rdx
callq 0x16a5
movl %eax, %ebp
shrl $0x1f, %ebp
jmp 0x1c23
movq %r15, %rdi
callq 0x234f
testl %ebp, %ebp
je 0x1be2
cmpl $0x1, %ebp
jne 0x1c31
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/dhara/journal.c
// Function: dhara_journal_init
void dhara_journal_init(struct dhara_journal *j,
			const struct dhara_nand *n,
			uint8_t *page_buf)
{
	/* Set fixed parameters */
	j->nand = n;
	j->page_buf = page_buf;
	j->log2_ppc = choose_ppc(n->log2_page_size, n->log2_ppb);

	reset_journal(j);
}

// Assembly:
movq %rdx, %rax
movq %rsi, (%rdi)
movq %rdx, 0x8(%rdi)
movb (%rsi), %cl
movl $0x1, %r8d
shll %cl, %r8d
movzbl 0x1(%rsi), %r9d
movl $0x1, %edx
movb $0x1, %cl
cmpl $0x2, %r9d
jb 0x1c8d
addl $-0x14, %r8d
movl $0x84, %r10d
movl $0x1, %ecx
leal 0x84(,%r10,2), %r10d
cmpl %r8d, %r10d
jg 0x1c8d
incl %ecx
cmpl %ecx, %r9d
jne 0x1c76
movl %r9d, %ecx
movb %cl, 0x10(%rdi)
xorl %ecx, %ecx
movb %cl, 0x11(%rdi)
movl 0x4(%rsi), %r8d
shrl $0x6, %r8d
movl %r8d, 0x18(%rdi)
movl %ecx, 0x14(%rdi)
movb %cl, 0x12(%rdi)
movl %ecx, 0x24(%rdi)
movq $0x0, 0x1c(%rdi)
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x28(%rdi)
movb (%rsi), %cl
shll %cl, %edx
movslq %edx, %rdx
movq %rax, %rdi
movl $0xff, %esi
jmp 0x1090
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/dhara/journal.c
// Function: find_checkblock
static int find_checkblock(struct dhara_journal *j,
			   dhara_block_t blk, dhara_block_t *where,
			   dhara_error_t *err)
{
	int i;

	for (i = 0; (blk < j->nand->num_blocks) &&
		    (i < DHARA_MAX_RETRIES); i++) {
		const dhara_page_t p =
			(blk << j->nand->log2_ppb) |
			((1 << j->log2_ppc) - 1);

		if (!(dhara_nand_is_bad(j->nand, blk) ||
		      dhara_nand_read(j->nand, p,
				      0, 1 << j->nand->log2_page_size,
				      j->page_buf, err)) &&
		    hdr_has_magic(j->page_buf)) {
			*where = blk;
			return 0;
		}

		blk++;
	}

	dhara_set_error(err, DHARA_E_TOO_BAD);
	return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, (%rsp)
movq %rdi, %r15
movq (%rdi), %rdi
cmpl %esi, 0x4(%rdi)
jbe 0x21a0
movl %esi, %ebp
xorl %r14d, %r14d
movzbl 0x1(%rdi), %r13d
movzbl 0x10(%r15), %r12d
movl %ebp, %esi
callq 0x323f
testl %eax, %eax
jne 0x217f
movl %ebp, %eax
movl %r13d, %ecx
shll %cl, %eax
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %r12d, %ecx
shll %cl, %esi
notl %esi
orl %eax, %esi
movq (%r15), %rdi
movq 0x8(%r15), %r8
movb (%rdi), %cl
movl $0x1, %eax
shll %cl, %eax
movslq %eax, %rcx
xorl %edx, %edx
movq %rbx, %r9
callq 0x3495
testl %eax, %eax
jne 0x217f
movq 0x8(%r15), %rax
cmpb $0x44, (%rax)
jne 0x217f
cmpb $0x68, 0x1(%rax)
jne 0x217f
cmpb $0x61, 0x2(%rax)
jne 0x217f
movq (%rsp), %rax
movl %ebp, (%rax)
xorl %eax, %eax
jmp 0x2183
incl %ebp
movb $0x1, %al
testb %al, %al
je 0x21b2
movq (%r15), %rdi
cmpl 0x4(%rdi), %ebp
jae 0x21a0
leal 0x1(%r14), %eax
cmpl $0x6, %r14d
movl %eax, %r14d
jbe 0x2115
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %rbx, %rbx
je 0x21b4
movl $0x3, (%rbx)
jmp 0x21b4
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/dhara/journal.c
// Function: dhara_journal_capacity
dhara_page_t dhara_journal_capacity(const struct dhara_journal *j)
{
	const dhara_block_t max_bad = j->bb_last > j->bb_current ?
		j->bb_last : j->bb_current;
	const dhara_block_t good_blocks = j->nand->num_blocks - max_bad - 1;
	const int log2_cpb = j->nand->log2_ppb - j->log2_ppc;
	const dhara_page_t good_cps = good_blocks << log2_cpb;

	/* Good checkpoints * (checkpoint period - 1) */
	return (good_cps << j->log2_ppc) - good_cps;
}

// Assembly:
movl 0x18(%rdi), %eax
movl 0x14(%rdi), %esi
cmpl %esi, %eax
cmoval %eax, %esi
movq (%rdi), %rax
notl %esi
addl 0x4(%rax), %esi
movzbl 0x1(%rax), %ecx
movl 0x10(%rdi), %edx
subl %edx, %ecx
shll %cl, %esi
movl %esi, %eax
movl %edx, %ecx
shll %cl, %eax
subl %esi, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/dhara/journal.c
// Function: dhara_journal_size
dhara_page_t dhara_journal_size(const struct dhara_journal *j)
{
	/* Find the number of raw pages, and the number of checkpoints
	 * between the head and the tail. The difference between the two
	 * is the number of user pages (upper limit).
	 */
	dhara_page_t num_pages = j->head;
	dhara_page_t num_cps = j->head >> j->log2_ppc;

	if (j->head < j->tail_sync) {
		const dhara_page_t total_pages =
			j->nand->num_blocks << j->nand->log2_ppb;

		num_pages += total_pages;
		num_cps += total_pages >> j->log2_ppc;
	}

	num_pages -= j->tail_sync;
	num_cps -= j->tail_sync >> j->log2_ppc;

	return num_pages - num_cps;
}

// Assembly:
movl 0x1c(%rdi), %r8d
movl 0x24(%rdi), %esi
movzbl 0x10(%rdi), %edx
movl %esi, %r9d
movl %edx, %ecx
shrl %cl, %r9d
cmpl %r8d, %esi
jae 0x2216
movq (%rdi), %rax
movl 0x4(%rax), %edi
movb 0x1(%rax), %cl
shll %cl, %edi
addl %edi, %esi
movl %edx, %ecx
shrl %cl, %edi
addl %edi, %r9d
movl %r8d, %eax
movl %edx, %ecx
shrl %cl, %eax
addl %r8d, %r9d
subl %r9d, %eax
addl %esi, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/dhara/journal.c
// Function: dhara_journal_read_meta
int dhara_journal_read_meta(struct dhara_journal *j, dhara_page_t p,
			    uint8_t *buf, dhara_error_t *err)
{
	/* Offset of metadata within the metadata page */
	const dhara_page_t ppc_mask = (1 << j->log2_ppc) - 1;
	const size_t offset = hdr_user_offset(p & ppc_mask);

	/* Special case: buffered metadata */
	if (align_eq(p, j->head, j->log2_ppc)) {
		memcpy(buf, j->page_buf + offset, DHARA_META_SIZE);
		return 0;
	}

	/* Special case: incomplete metadata dumped at start of
	 * recovery.
	 */
	if ((j->recover_meta != DHARA_PAGE_NONE) &&
	    align_eq(p, j->recover_root, j->log2_ppc))
		return dhara_nand_read(j->nand, j->recover_meta,
				       offset, DHARA_META_SIZE,
				       buf, err);

	/* General case: fetch from metadata page for checkpoint group */
	return dhara_nand_read(j->nand, p | ppc_mask,
			       offset, DHARA_META_SIZE,
			       buf, err);
}

// Assembly:
movq %rcx, %r9
movzbl 0x10(%rdi), %ecx
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
shll %cl, %r10d
movq %rdx, %r8
notl %r10d
movl %esi, %eax
andl %r10d, %eax
movzbl %al, %eax
movl %eax, %edx
shll $0x7, %edx
leal (%rdx,%rax,4), %eax
addl $0x14, %eax
movl 0x24(%rdi), %edx
xorl %esi, %edx
shrl %cl, %edx
testl %edx, %edx
je 0x2281
movl 0x34(%rdi), %edx
cmpl $-0x1, %edx
je 0x2271
movl 0x30(%rdi), %r11d
xorl %esi, %r11d
shrl %cl, %r11d
testl %r11d, %r11d
je 0x229a
movq (%rdi), %rdi
orl %esi, %r10d
movl $0x84, %ecx
movl %r10d, %esi
jmp 0x22a4
pushq %rax
addq 0x8(%rdi), %rax
movl $0x84, %edx
movq %r8, %rdi
movq %rax, %rsi
callq 0x10c0
xorl %eax, %eax
popq %rcx
retq
movq (%rdi), %rdi
movl $0x84, %ecx
movl %edx, %esi
movq %rax, %rdx
jmp 0x3495
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/dhara/journal.c
// Function: dhara_journal_peek
dhara_page_t dhara_journal_peek(struct dhara_journal *j)
{
	if (j->head == j->tail)
		return DHARA_PAGE_NONE;

	if (is_aligned(j->tail, j->nand->log2_ppb)) {
		dhara_block_t blk = j->tail >> j->nand->log2_ppb;
		int i;

		for (i = 0; i < DHARA_MAX_RETRIES; i++) {
			if ((blk == (j->head >> j->nand->log2_ppb)) ||
			    !dhara_nand_is_bad(j->nand, blk)) {
				j->tail = blk << j->nand->log2_ppb;

				if (j->tail == j->head)
					j->root = DHARA_PAGE_NONE;

				return j->tail;
			}

			blk = next_block(j->nand, blk);
		}
	}

	return j->tail;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl 0x20(%rdi), %ebp
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ebp, 0x24(%rdi)
je 0x2344
movq %rdi, %rbx
movq (%rdi), %rax
movzbl 0x1(%rax), %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
shll %cl, %eax
notl %eax
testl %eax, %ebp
jne 0x2341
shrl %cl, %ebp
movl 0x24(%rbx), %eax
movq (%rbx), %rdi
movb 0x1(%rdi), %cl
shrl %cl, %eax
xorl %r15d, %r15d
xorl %r14d, %r14d
cmpl %eax, %ebp
je 0x2320
movl %ebp, %esi
callq 0x323f
testl %eax, %eax
je 0x2320
cmpl $0x7, %r15d
setae %r14b
je 0x2339
incl %ebp
movq (%rbx), %rdi
cmpl 0x4(%rdi), %ebp
jb 0x2313
xorl %ebp, %ebp
movl 0x24(%rbx), %eax
movb 0x1(%rdi), %cl
shrl %cl, %eax
incl %r15d
jmp 0x22ee
movq (%rbx), %rax
movb 0x1(%rax), %cl
shll %cl, %ebp
movl %ebp, 0x20(%rbx)
cmpl 0x24(%rbx), %ebp
jne 0x2339
movl $0xffffffff, 0x28(%rbx) # imm = 0xFFFFFFFF
jmp 0x2339
movl %ebp, %eax
testb $0x1, %r14b
je 0x2344
movl 0x20(%rbx), %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/dhara/journal.c
// Function: dhara_journal_dequeue
void dhara_journal_dequeue(struct dhara_journal *j)
{
	if (j->head == j->tail)
		return;

	j->tail = next_upage(j, j->tail);

	/* If the journal is clean at the time of dequeue, then this
	 * data was always obsolete, and can be reused immediately.
	 */
	if (!(j->flags & (DHARA_JOURNAL_F_DIRTY | DHARA_JOURNAL_F_RECOVERY)))
		j->tail_sync = j->tail;

	const dhara_page_t chip_size = j->nand->num_blocks << j->nand->log2_ppb;
	const dhara_page_t raw_size = wrap(j->head + chip_size - j->tail,
		chip_size);
	const dhara_page_t root_offset = wrap(j->head + chip_size - j->root,
		chip_size);

	if (root_offset > raw_size)
		j->root = DHARA_PAGE_NONE;
}

// Assembly:
movl 0x20(%rdi), %edx
movl 0x24(%rdi), %eax
cmpl %edx, %eax
je 0x23bb
leal 0x1(%rdx), %esi
addl $0x2, %edx
movb 0x10(%rdi), %cl
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
shll %cl, %r8d
notl %r8d
testl %r8d, %edx
cmovnel %esi, %edx
movq (%rdi), %rcx
movl 0x4(%rcx), %esi
movb 0x1(%rcx), %cl
shll %cl, %esi
xorl %ecx, %ecx
cmpl %esi, %edx
cmovael %ecx, %edx
movl %edx, 0x20(%rdi)
testb $0x5, 0x12(%rdi)
jne 0x2392
movl %edx, 0x1c(%rdi)
addl %esi, %eax
movl %eax, %r8d
subl %edx, %r8d
cmpl %esi, %r8d
movl %esi, %edx
cmovbl %ecx, %edx
subl %edx, %r8d
subl 0x28(%rdi), %eax
cmpl %esi, %eax
cmovbl %ecx, %esi
subl %esi, %eax
cmpl %r8d, %eax
jbe 0x23bb
movl $0xffffffff, 0x28(%rdi) # imm = 0xFFFFFFFF
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/dhara/journal.c
// Function: dhara_journal_clear
void dhara_journal_clear(struct dhara_journal *j)
{
	j->tail = j->head;
	j->root = DHARA_PAGE_NONE;
	j->flags |= DHARA_JOURNAL_F_DIRTY;

	hdr_clear_user(j->page_buf, j->nand->log2_page_size);
}

// Assembly:
movl 0x24(%rdi), %eax
movl %eax, 0x20(%rdi)
movl $0xffffffff, 0x28(%rdi) # imm = 0xFFFFFFFF
orb $0x1, 0x12(%rdi)
movq (%rdi), %rax
movq 0x8(%rdi), %rdi
movb (%rax), %cl
addq $0x14, %rdi
movl $0x1, %eax
shll %cl, %eax
addl $-0x14, %eax
movslq %eax, %rdx
movl $0xff, %esi
jmp 0x1090
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/dhara/journal.c
// Function: dhara_journal_enqueue
int dhara_journal_enqueue(struct dhara_journal *j,
			  const uint8_t *data, const uint8_t *meta,
			  dhara_error_t *err)
{
	dhara_error_t my_err;
	int i;

	for (i = 0; i < DHARA_MAX_RETRIES; i++) {
		if (!(prepare_head(j, &my_err) ||
		      (data && dhara_nand_prog(j->nand, j->head, data,
					       &my_err))))
			return push_meta(j, meta, err);

		if (recover_from(j, my_err, err) < 0)
			return -1;
	}

	dhara_set_error(err, DHARA_E_TOO_BAD);
	return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r15
movl $0x8, %ebp
leaq 0x4(%rsp), %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0x2484
testl %eax, %eax
jne 0x243c
testq %r12, %r12
je 0x2467
movq (%r15), %rdi
movl 0x24(%r15), %esi
movq %r12, %rdx
movq %r13, %rcx
callq 0x335f
testl %eax, %eax
je 0x2467
movl 0x4(%rsp), %esi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x26f3
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
js 0x2475
decl %ebp
jne 0x2412
testq %rbx, %rbx
je 0x2475
movl $0x3, (%rbx)
jmp 0x2475
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x2569
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/dhara/journal.c
// Function: prepare_head
static int prepare_head(struct dhara_journal *j, dhara_error_t *err)
{
	const dhara_page_t next = next_upage(j, j->head);
	int i;

	/* We can't write if doing so would cause the head pointer to
	 * roll onto the same block as the last-synced tail.
	 */
	if (align_eq(next, j->tail_sync, j->nand->log2_ppb) &&
	    !align_eq(next, j->head, j->nand->log2_ppb)) {
		dhara_set_error(err, DHARA_E_JOURNAL_FULL);
		return -1;
	}

	j->flags |= DHARA_JOURNAL_F_DIRTY;
	if (!is_aligned(j->head, j->nand->log2_ppb))
		return 0;

	for (i = 0; i < DHARA_MAX_RETRIES; i++) {
		const dhara_block_t blk = j->head >> j->nand->log2_ppb;

		if (!dhara_nand_is_bad(j->nand, blk))
			return dhara_nand_erase(j->nand, blk, err);

		j->bb_current++;
		if (skip_block(j, err) < 0)
			return -1;
	}

	dhara_set_error(err, DHARA_E_TOO_BAD);
	return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movb 0x10(%rdi), %cl
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
shll %cl, %edi
movl 0x24(%rbx), %eax
leal 0x1(%rax), %edx
leal 0x2(%rax), %ecx
notl %edi
testl %edi, %ecx
cmovel %ecx, %edx
movq %rsi, %r14
movq (%rbx), %rcx
movl 0x4(%rcx), %esi
movzbl 0x1(%rcx), %ecx
shll %cl, %esi
xorl %ebp, %ebp
cmpl %esi, %edx
cmovael %ebp, %edx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl 0x1c(%rbx), %edi
xorl %edx, %edi
shrl %cl, %edi
testl %edi, %edi
je 0x253e
orb $0x1, 0x12(%rbx)
shll %cl, %esi
notl %esi
testl %esi, %eax
jne 0x2558
movl $0x8, %r12d
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl 0x24(%rbx), %r15d
movq (%rbx), %rdi
movb 0x1(%rdi), %cl
shrl %cl, %r15d
movl %r15d, %esi
callq 0x323f
testl %eax, %eax
je 0x251c
incl 0x14(%rbx)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2934
testl %eax, %eax
setns %al
cmovsl %r13d, %ebp
jmp 0x252e
movq (%rbx), %rdi
movl %r15d, %esi
movq %r14, %rdx
callq 0x329d
movl %eax, %ebp
xorl %eax, %eax
testb %al, %al
je 0x2558
decl %r12d
jne 0x24ea
movl $0x3, %eax
jmp 0x254b
xorl %eax, %edx
shrl %cl, %edx
testl %edx, %edx
je 0x24d2
movl $0x5, %eax
testq %r14, %r14
je 0x2553
movl %eax, (%r14)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/dhara/journal.c
// Function: recover_from
static int recover_from(struct dhara_journal *j,
			dhara_error_t write_err,
			dhara_error_t *err)
{
	const dhara_page_t old_head = j->head;

	if (write_err != DHARA_E_BAD_BLOCK) {
		dhara_set_error(err, write_err);
		return -1;
	}

	/* Advance to the next free page */
	j->bb_current++;
	if (skip_block(j, err) < 0)
		return -1;

	/* Are we already in the middle of a recovery? */
	if (dhara_journal_in_recovery(j)) {
		restart_recovery(j, old_head);
		dhara_set_error(err, DHARA_E_RECOVER);
		return -1;
	}

	/* Were we block aligned? No recovery required! */
	if (is_aligned(old_head, j->nand->log2_ppb)) {
		dhara_nand_mark_bad(j->nand, old_head >> j->nand->log2_ppb);
		return 0;
	}

	j->recover_root = j->root;
	j->recover_next =
		j->recover_root & ~((1 << j->nand->log2_ppb) - 1);

	/* Are we holding buffered metadata? Dump it first. */
	if (!is_aligned(old_head, j->log2_ppc) &&
	    dump_meta(j, err) < 0)
		return -1;

	j->flags |= DHARA_JOURNAL_F_RECOVERY;
	dhara_set_error(err, DHARA_E_RECOVER);
	return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
cmpl $0x1, %esi
jne 0x277f
movq %rdi, %r14
movl 0x24(%rdi), %r15d
incl 0x14(%rdi)
movq %rbx, %rsi
callq 0x2934
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %eax, %eax
js 0x27f5
movb 0x12(%r14), %al
testb $0x4, %al
jne 0x278d
movq (%r14), %rdi
movzbl 0x1(%rdi), %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
shll %cl, %edx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %edx, %esi
notl %esi
testl %esi, %r15d
je 0x27b8
movl 0x28(%r14), %ecx
movl %ecx, 0x30(%r14)
andl %ecx, %edx
movl %edx, 0x2c(%r14)
movb 0x10(%r14), %cl
shll %cl, %eax
notl %eax
testl %eax, %r15d
je 0x2773
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2984
testl %eax, %eax
js 0x2802
orb $0x4, 0x12(%r14)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x27ea
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rbx, %rbx
je 0x27f5
movl %esi, (%rbx)
jmp 0x27f5
movl 0x34(%r14), %edx
cmpl $-0x1, %edx
je 0x27a5
movq (%r14), %rcx
movb 0x1(%rcx), %cl
xorl %r15d, %edx
shrl %cl, %edx
testl %edx, %edx
je 0x27c7
movq (%r14), %rdi
movb 0x1(%rdi), %cl
shrl %cl, %r15d
movl %r15d, %esi
callq 0x326f
jmp 0x27cd
shrl %cl, %r15d
movl %r15d, %esi
callq 0x326f
xorl %ebp, %ebp
jmp 0x27f5
orb $0x2, %al
movb %al, 0x12(%r14)
andb $-0x9, 0x12(%r14)
movl 0x30(%r14), %eax
movq (%r14), %rcx
movb 0x1(%rcx), %cl
movl %eax, %edx
shrl %cl, %edx
shll %cl, %edx
movl %edx, 0x2c(%r14)
movl %eax, 0x28(%r14)
testq %rbx, %rbx
je 0x27f5
movl $0x4, (%rbx)
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x27f5
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/dhara/journal.c
// Function: dhara_journal_copy
int dhara_journal_copy(struct dhara_journal *j,
		       dhara_page_t p, const uint8_t *meta,
		       dhara_error_t *err)
{
	dhara_error_t my_err;
	int i;

	for (i = 0; i < DHARA_MAX_RETRIES; i++) {
		if (!(prepare_head(j, &my_err) ||
		      dhara_nand_copy(j->nand, p, j->head, &my_err)))
			return push_meta(j, meta, err);

		if (recover_from(j, my_err, err) < 0)
			return -1;
	}

	dhara_set_error(err, DHARA_E_TOO_BAD);
	return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, %r15
movl $0x8, %r13d
leaq 0x4(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x2484
testl %eax, %eax
jne 0x284e
movq (%r15), %rdi
movl 0x24(%r15), %edx
movl %ebp, %esi
movq %r12, %rcx
callq 0x3517
testl %eax, %eax
je 0x287a
movl 0x4(%rsp), %esi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x26f3
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
js 0x2888
decl %r13d
jne 0x282a
testq %rbx, %rbx
je 0x2888
movl $0x3, (%rbx)
jmp 0x2888
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x2569
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/dhara/journal.c
// Function: cp_free
static int cp_free(struct dhara_journal *j, dhara_page_t first_user)
{
	const int count = 1 << j->log2_ppc;
	int i;

	for (i = 0; i < count; i++)
		if (!dhara_nand_is_free(j->nand, first_user + i))
			return 0;

	return 1;
}

// Assembly:
movzbl 0x10(%rdi), %ecx
movl $0x1, %eax
cmpl $0x1f, %ecx
je 0x2933
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
movl $0x1, %ebp
shll %cl, %ebp
movl $0x1, %eax
cmpl $0x2, %ebp
cmovll %eax, %ebp
movq (%r14), %rdi
movl %ebx, %esi
callq 0x3459
testl %eax, %eax
je 0x292d
incl %ebx
decl %ebp
jne 0x2912
movl $0x1, %eax
jmp 0x292f
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/dhara/journal.c
// Function: skip_block
static int skip_block(struct dhara_journal *j, dhara_error_t *err)
{
	const dhara_block_t next = next_block(j->nand,
		j->head >> j->nand->log2_ppb);

	/* We can't roll onto the same block as the tail */
	if ((j->tail_sync >> j->nand->log2_ppb) == next) {
		dhara_set_error(err, DHARA_E_JOURNAL_FULL);
		return -1;
	}

	j->head = next << j->nand->log2_ppb;
	if (!j->head)
		roll_stats(j);

	return 0;
}

// Assembly:
movq (%rdi), %r8
movl 0x24(%rdi), %edx
movzbl 0x1(%r8), %ecx
shrl %cl, %edx
incl %edx
xorl %eax, %eax
cmpl 0x4(%r8), %edx
cmovael %eax, %edx
movl 0x1c(%rdi), %r8d
shrl %cl, %r8d
cmpl %edx, %r8d
jne 0x2969
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %rsi, %rsi
je 0x2972
movl $0x5, (%rsi)
retq
shll %cl, %edx
movl %edx, 0x24(%rdi)
testl %edx, %edx
je 0x2973
retq
movl 0x14(%rdi), %ecx
movl %ecx, 0x18(%rdi)
movl $0x0, 0x14(%rdi)
incb 0x11(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/dhara/journal.c
// Function: dump_meta
static int dump_meta(struct dhara_journal *j, dhara_error_t *err)
{
	int i;

	/* We've just begun recovery on a new erasable block, but we
	 * have buffered metadata from the failed block.
	 */
	for (i = 0; i < DHARA_MAX_RETRIES; i++) {
		dhara_error_t my_err;

		/* Try to dump metadata on this page */
		if (!(prepare_head(j, &my_err) ||
		      dhara_nand_prog(j->nand, j->head,
				      j->page_buf, &my_err))) {
			j->recover_meta = j->head;
			j->head = next_upage(j, j->head);
			if (!j->head)
				roll_stats(j);
			hdr_clear_user(j->page_buf, j->nand->log2_page_size);
			return 0;
		}

		/* Report fatal errors */
		if (my_err != DHARA_E_BAD_BLOCK) {
			dhara_set_error(err, my_err);
			return -1;
		}

		j->bb_current++;
		dhara_nand_mark_bad(j->nand, j->head >> j->nand->log2_ppb);

		if (skip_block(j, err) < 0)
			return -1;
	}

	dhara_set_error(err, DHARA_E_TOO_BAD);
	return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movl $0x8, %r12d
leaq 0x4(%rsp), %r15
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movq %r14, %rdi
movq %r15, %rsi
callq 0x2484
testl %eax, %eax
jne 0x29cc
movl 0x24(%r14), %esi
movq (%r14), %rdi
movq 0x8(%r14), %rdx
movq %r15, %rcx
callq 0x335f
testl %eax, %eax
je 0x2a11
movl 0x4(%rsp), %eax
cmpl $0x1, %eax
jne 0x2a03
incl 0x14(%r14)
movq (%r14), %rdi
movl 0x24(%r14), %esi
movb 0x1(%rdi), %cl
shrl %cl, %esi
callq 0x326f
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2934
testl %eax, %eax
setns %al
cmovsl %r13d, %ebp
jmp 0x2a87
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rbx, %rbx
je 0x2a85
movl %eax, (%rbx)
jmp 0x2a85
movl 0x24(%r14), %edx
movl %edx, 0x34(%r14)
leal 0x1(%rdx), %eax
addl $0x2, %edx
movb 0x10(%r14), %cl
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
shll %cl, %esi
notl %esi
testl %esi, %edx
cmovnel %eax, %edx
movq (%r14), %rax
movl 0x4(%rax), %esi
movb 0x1(%rax), %cl
shll %cl, %esi
cmpl %esi, %edx
movl $0x0, %ecx
cmovael %ecx, %edx
movl %edx, 0x24(%r14)
testl %edx, %edx
jne 0x2a62
movl 0x14(%r14), %ecx
movl %ecx, 0x18(%r14)
movl $0x0, 0x14(%r14)
incb 0x11(%r14)
movb (%rax), %cl
movl $0x1, %eax
shll %cl, %eax
movq 0x8(%r14), %rdi
addq $0x14, %rdi
addl $-0x14, %eax
movslq %eax, %rdx
movl $0xff, %esi
callq 0x1090
xorl %ebp, %ebp
xorl %eax, %eax
testb %al, %al
je 0x2aa4
decl %r12d
jne 0x29a6
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rbx, %rbx
je 0x2aa4
movl $0x3, (%rbx)
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/tests/map.c
// Function: main
int main(void)
{
	for (int i = 0; i < 1000; i++) {
		printf("--------------------------------"
		       "--------------------------------\n");
		printf("Seed: %d\n", i);
		srandom(i);
		test();
	}

	sim_dump();
	return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
leaq 0x17b5(%rip), %rbx      # 0x42a0
leaq 0x15e8(%rip), %r14      # 0x40da
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x1060
movq %r14, %rdi
movl %ebp, %esi
xorl %eax, %eax
callq 0x1070
movl %ebp, %edi
callq 0x1050
callq 0x2b2a
incl %ebp
cmpl $0x3e8, %ebp            # imm = 0x3E8
jne 0x2af4
callq 0x3686
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/tests/map.c
// Function: shuffle
static void shuffle(int seed)
{
	int i;

	srandom(seed);
	for (i = 0; i < NUM_SECTORS; i++)
		sector_list[i] = i;

	for (i = NUM_SECTORS - 1; i > 0; i--) {
		const int j = random() % i;
		const int tmp = sector_list[i];

		sector_list[i] = sector_list[j];
		sector_list[j] = tmp;
	}
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
callq 0x1050
leaq 0x41ba(%rip), %rax      # 0x7090
xorl %ecx, %ecx
movl %ecx, (%rax)
incq %rcx
addq $0x4, %rax
cmpq $0xc8, %rcx
jne 0x2ed8
movl $0xc7, %r14d
leaq 0x4199(%rip), %rbx      # 0x7090
callq 0x10d0
cqto
idivq %r14
movl (%rbx,%r14,4), %eax
movslq %edx, %rcx
movl (%rbx,%rcx,4), %edx
movl %edx, (%rbx,%r14,4)
movl %eax, (%rbx,%rcx,4)
leaq -0x1(%r14), %rax
cmpq $0x1, %r14
movq %rax, %r14
ja 0x2ef7
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/tests/map.c
// Function: mt_write
static void mt_write(struct dhara_map *m, dhara_sector_t s, int seed)
{
	const size_t page_size = 1 << m->journal.nand->log2_page_size;
	uint8_t buf[page_size];
	dhara_error_t err;

	seq_gen(seed, buf, sizeof(buf));
	if (dhara_map_write(m, s, buf, &err) < 0)
		dabort("map_write", err);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %eax
movq %rdi, %rbx
movq (%rdi), %rcx
movb (%rcx), %cl
movl $0x1, %edx
shll %cl, %edx
movl %esi, %r14d
movslq %edx, %rdx
leaq 0xf(%rdx), %rcx
andq $-0x10, %rcx
movq %rsp, %r15
subq %rcx, %r15
movq %r15, %rsp
movl %eax, %edi
movq %r15, %rsi
callq 0x3844
leaq -0x1c(%rbp), %rcx
movq %rbx, %rdi
movl %r14d, %esi
movq %r15, %rdx
callq 0x1556
testl %eax, %eax
jns 0x2f88
movl -0x1c(%rbp), %esi
leaq 0x1196(%rip), %rdi      # 0x4119
callq 0x38d9
leaq -0x18(%rbp), %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/tests/map.c
// Function: mt_check
static void mt_check(struct dhara_map *m)
{
	int count;

	sim_freeze();
	count = check_recurse(m, m->journal.head,
		dhara_journal_root(&m->journal), 0, 0);
	sim_thaw();

	assert(m->count == count);
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x3678
movl 0x24(%rbx), %esi
movl 0x28(%rbx), %edx
movq %rbx, %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x3046
movl %eax, %ebp
callq 0x367f
cmpl %ebp, 0x3c(%rbx)
jne 0x2fc4
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x1158(%rip), %rdi      # 0x4123
leaq 0x1163(%rip), %rsi      # 0x4135
leaq 0x1168(%rip), %rcx      # 0x4141
movl $0x68, %edx
callq 0x1080
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/tests/map.c
// Function: mt_assert
static void mt_assert(struct dhara_map *m, dhara_sector_t s, int seed)
{
	const size_t page_size = 1 << m->journal.nand->log2_page_size;
	uint8_t buf[page_size];
	dhara_error_t err;

	if (dhara_map_read(m, s, buf, &err) < 0)
		dabort("map_read", err);

	seq_assert(seed, buf, sizeof(buf));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebx
movq (%rdi), %rax
movb (%rax), %cl
movl $0x1, %eax
shll %cl, %eax
movslq %eax, %r14
leaq 0xf(%r14), %rax
andq $-0x10, %rax
movq %rsp, %r15
subq %rax, %r15
movq %r15, %rsp
leaq -0x1c(%rbp), %rcx
movq %r15, %rdx
callq 0x14ce
testl %eax, %eax
jns 0x302e
movl -0x1c(%rbp), %esi
leaq 0x120d(%rip), %rdi      # 0x4236
callq 0x38d9
movl %ebx, %edi
movq %r15, %rsi
movq %r14, %rdx
callq 0x3873
leaq -0x18(%rbp), %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/tests/sim.c
// Function: sim_reset
void sim_reset(void)
{
	int i;

	memset(&stats, 0, sizeof(stats));
	memset(blocks, 0, sizeof(blocks));
	memset(pages, 0x55, sizeof(pages));

	for (i = 0; i < NUM_BLOCKS; i++)
		blocks[i].next_page = PAGES_PER_BLOCK;
}

// Assembly:
pushq %rbx
xorps %xmm0, %xmm0
movups %xmm0, 0x41d9(%rip)     # 0x73c0
movups %xmm0, 0x41c2(%rip)     # 0x73b0
movq $0x0, 0x41d7(%rip) # 0x73d0
leaq 0x41e0(%rip), %rbx      # 0x73e0
movl $0x54c, %edx            # imm = 0x54C
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1090
leaq 0x471a(%rip), %rdi      # 0x7930
movl $0x71000, %edx          # imm = 0x71000
movl $0x55, %esi
callq 0x1090
movl $0x4, %eax
movl $0x8, (%rax,%rbx)
addq $0xc, %rax
cmpq $0x550, %rax            # imm = 0x550
jne 0x322a
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/tests/sim.c
// Function: dhara_nand_is_bad
int dhara_nand_is_bad(const struct dhara_nand *n, dhara_block_t bno)
{
	if (bno >= NUM_BLOCKS) {
		fprintf(stderr, "sim: NAND_is_bad called on "
			"invalid block: %d\n", bno);
		abort();
	}

	if (!stats.frozen)
		stats.is_bad++;
	return blocks[bno].flags & BLOCK_BAD_MARK;
}

// Assembly:
cmpl $0x71, %esi
jae 0x3267
cmpl $0x0, 0x4165(%rip)      # 0x73b0
jne 0x3253
incl 0x4161(%rip)            # 0x73b4
movl %esi, %eax
leaq (%rax,%rax,2), %rax
leaq 0x4180(%rip), %rcx      # 0x73e0
movl (%rcx,%rax,4), %eax
andl $0x1, %eax
retq
pushq %rax
movl %esi, %edi
callq 0x10f0
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/tests/sim.c
// Function: dhara_nand_mark_bad
void dhara_nand_mark_bad(const struct dhara_nand *n, dhara_block_t bno)
{
	if (bno >= NUM_BLOCKS) {
		fprintf(stderr, "sim: NAND_mark_bad called on "
			"invalid block: %d\n", bno);
		abort();
	}

	if (!stats.frozen)
		stats.mark_bad++;
	blocks[bno].flags |= BLOCK_BAD_MARK;
}

// Assembly:
cmpl $0x71, %esi
jae 0x3295
cmpl $0x0, 0x4135(%rip)      # 0x73b0
jne 0x3283
incl 0x4135(%rip)            # 0x73b8
movl %esi, %eax
leaq (%rax,%rax,2), %rax
leaq 0x4150(%rip), %rcx      # 0x73e0
orb $0x1, (%rcx,%rax,4)
retq
pushq %rax
movl %esi, %edi
callq 0x1110
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/tests/sim.c
// Function: dhara_nand_erase
int dhara_nand_erase(const struct dhara_nand *n, dhara_block_t bno,
		     dhara_error_t *err)
{
	uint8_t *blk = pages + (bno << LOG2_BLOCK_SIZE);

	if (bno >= NUM_BLOCKS) {
		fprintf(stderr, "sim: NAND_erase called on "
			"invalid block: %d\n", bno);
		abort();
	}

	if (blocks[bno].flags & BLOCK_BAD_MARK) {
		fprintf(stderr, "sim: NAND_erase called on "
			"block which is marked bad: %d\n", bno);
		abort();
	}

	if (!stats.frozen)
		stats.erase++;
	blocks[bno].next_page = 0;

	timebomb_tick(bno);

	if (blocks[bno].flags & BLOCK_FAILED) {
		if (!stats.frozen)
			stats.erase_fail++;
		seq_gen(bno * 57 + 29, blk, BLOCK_SIZE);
		dhara_set_error(err, DHARA_E_BAD_BLOCK);
		return -1;
	}

	memset(blk, 0xff, BLOCK_SIZE);
	return 0;
}

// Assembly:
pushq %rbx
cmpl $0x71, %esi
jae 0x3351
movq %rdx, %rbx
movl %esi, %eax
leaq (%rax,%rax,2), %rax
leaq 0x4129(%rip), %rdx      # 0x73e0
movl (%rdx,%rax,4), %ecx
testb $0x1, %cl
jne 0x3358
movl %esi, %edi
shll $0xc, %edi
leaq (%rdx,%rax,4), %r8
movl 0x40de(%rip), %edx      # 0x73b0
testl %edx, %edx
jne 0x32dc
incl 0x40e0(%rip)            # 0x73bc
leaq 0x464d(%rip), %rax      # 0x7930
movl $0x0, 0x4(%r8)
movl 0x8(%r8), %r9d
testl %r9d, %r9d
je 0x3303
decl %r9d
movl %r9d, 0x8(%r8)
jne 0x3303
orl $0x2, %ecx
movl %ecx, (%r8)
addq %rdi, %rax
testb $0x2, (%r8)
jne 0x3322
movl $0x1000, %edx           # imm = 0x1000
movq %rax, %rdi
movl $0xff, %esi
callq 0x1090
xorl %eax, %eax
jmp 0x334f
testl %edx, %edx
jne 0x332c
incl 0x4094(%rip)            # 0x73c0
imull $0x39, %esi, %edi
addl $0x1d, %edi
movl $0x1000, %edx           # imm = 0x1000
movq %rax, %rsi
callq 0x3844
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %rbx, %rbx
je 0x334f
movl $0x1, (%rbx)
popq %rbx
retq
movl %esi, %edi
callq 0x1150
movl %esi, %edi
callq 0x1130
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/tests/sim.c
// Function: dhara_nand_prog
int dhara_nand_prog(const struct dhara_nand *n, dhara_page_t p,
		    const uint8_t *data, dhara_error_t *err)
{
	const int bno = p >> LOG2_PAGES_PER_BLOCK;
	const int pno = p & ((1 << LOG2_PAGES_PER_BLOCK) - 1);
	uint8_t *page = pages + (p << LOG2_PAGE_SIZE);

	if ((bno < 0) || (bno >= NUM_BLOCKS)) {
		fprintf(stderr, "sim: NAND_prog called on "
			"invalid block: %d\n", bno);
		abort();
	}

	if (blocks[bno].flags & BLOCK_BAD_MARK) {
		fprintf(stderr, "sim: NAND_prog called on "
			"block which is marked bad: %d\n", bno);
		abort();
	}

	if (pno < blocks[bno].next_page) {
		fprintf(stderr, "sim: NAND_prog: out-of-order "
			"page programming. Block %d, page %d "
			"(expected %d)\n",
			bno, pno, blocks[bno].next_page);
		abort();
	}

	if (!stats.frozen)
		stats.prog++;
	blocks[bno].next_page = pno + 1;

	timebomb_tick(bno);

	if (blocks[bno].flags & BLOCK_FAILED) {
		if (!stats.frozen)
			stats.prog_fail++;
		seq_gen(p * 57 + 29, page, PAGE_SIZE);
		dhara_set_error(err, DHARA_E_BAD_BLOCK);
		return -1;
	}

	memcpy(page, data, PAGE_SIZE);
	return 0;
}

// Assembly:
pushq %rbx
movq %rdx, %rax
movl %esi, %edx
shrl $0x3, %edx
cmpl $0x388, %esi            # imm = 0x388
jae 0x342e
movq %rcx, %rbx
movl %edx, %ecx
leaq (%rcx,%rcx,2), %r8
leaq 0x405c(%rip), %r9       # 0x73e0
movl (%r9,%r8,4), %edi
testb $0x1, %dil
jne 0x3435
movl %esi, %ecx
andl $0x7, %ecx
leaq (%r9,%r8,4), %r9
movl 0x4(%r9), %r8d
cmpl %r8d, %ecx
jl 0x343c
movl %esi, %r10d
shll $0x9, %r10d
movl 0x3ffb(%rip), %edx      # 0x73b0
testl %edx, %edx
jne 0x33bf
incl 0x4009(%rip)            # 0x73c8
leaq 0x456a(%rip), %r8       # 0x7930
incl %ecx
movl %ecx, 0x4(%r9)
movl 0x8(%r9), %ecx
testl %ecx, %ecx
je 0x33e2
decl %ecx
movl %ecx, 0x8(%r9)
jne 0x33e2
orl $0x2, %edi
movl %edi, (%r9)
addq %r10, %r8
testb $0x2, (%r9)
jne 0x33ff
movl $0x200, %edx            # imm = 0x200
movq %r8, %rdi
movq %rax, %rsi
callq 0x10c0
xorl %eax, %eax
jmp 0x342c
testl %edx, %edx
jne 0x3409
incl 0x3fc3(%rip)            # 0x73cc
imull $0x39, %esi, %edi
addl $0x1d, %edi
movl $0x200, %edx            # imm = 0x200
movq %r8, %rsi
callq 0x3844
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %rbx, %rbx
je 0x342c
movl $0x1, (%rbx)
popq %rbx
retq
movl %edx, %edi
callq 0x1190
movl %edx, %edi
callq 0x1170
movq 0x3bb5(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x1027(%rip), %rsi      # 0x4474
xorl %eax, %eax
callq 0x10b0
callq 0x1040
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/tests/sim.c
// Function: dhara_nand_is_free
int dhara_nand_is_free(const struct dhara_nand *n, dhara_page_t p)
{
	const int bno = p >> LOG2_PAGES_PER_BLOCK;
	const int pno = p & ((1 << LOG2_PAGES_PER_BLOCK) - 1);

	if ((bno < 0) || (bno >= NUM_BLOCKS)) {
		fprintf(stderr, "sim: NAND_is_free called on "
			"invalid block: %d\n", bno);
		abort();
	}

	if (!stats.frozen)
		stats.is_erased++;
	return blocks[bno].next_page <= pno;
}

// Assembly:
movl %esi, %edi
shrl $0x3, %edi
cmpl $0x388, %esi            # imm = 0x388
jae 0x348f
cmpl $0x0, 0x3f43(%rip)      # 0x73b0
jne 0x3475
incl 0x3f4f(%rip)            # 0x73c4
andl $0x7, %esi
movl %edi, %eax
leaq (%rax,%rax,2), %rcx
leaq 0x3f5b(%rip), %rdx      # 0x73e0
xorl %eax, %eax
cmpl %esi, 0x4(%rdx,%rcx,4)
setle %al
retq
pushq %rax
callq 0x11b0
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/tests/sim.c
// Function: dhara_nand_read
int dhara_nand_read(const struct dhara_nand *n, dhara_page_t p,
		    size_t offset, size_t length,
		    uint8_t *data, dhara_error_t *err)
{
	const int bno = p >> LOG2_PAGES_PER_BLOCK;
	uint8_t *page = pages + (p << LOG2_PAGE_SIZE);

	if ((bno < 0) || (bno >= NUM_BLOCKS)) {
		fprintf(stderr, "sim: NAND_read called on "
			"invalid block: %d\n", bno);
		abort();
	}

	if ((offset > PAGE_SIZE) || (length > PAGE_SIZE) ||
	    (offset + length > PAGE_SIZE)) {
		fprintf(stderr, "sim: NAND_read called on "
			"invalid range: offset = %ld, length = %ld\n",
			offset, length);
		abort();
	}

	if (!stats.frozen) {
		stats.read++;
		stats.read_bytes += length;
	}

	memcpy(data, page + offset, length);
	return 0;
}

// Assembly:
pushq %rax
cmpl $0x388, %esi            # imm = 0x388
jae 0x34f3
cmpq $0x200, %rdx            # imm = 0x200
ja 0x34fa
cmpq $0x200, %rcx            # imm = 0x200
ja 0x34fa
leaq (%rcx,%rdx), %rax
cmpq $0x201, %rax            # imm = 0x201
jae 0x34fa
cmpl $0x0, 0x3eed(%rip)      # 0x73b0
jne 0x34d1
incl 0x3f05(%rip)            # 0x73d0
addl %ecx, 0x3f03(%rip)      # 0x73d4
shll $0x9, %esi
leaq 0x4455(%rip), %rax      # 0x7930
addq %rsi, %rax
addq %rdx, %rax
movq %r8, %rdi
movq %rax, %rsi
movq %rcx, %rdx
callq 0x10c0
xorl %eax, %eax
popq %rcx
retq
movl %esi, %edi
callq 0x11d0
movq 0x3af7(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x1014(%rip), %rsi      # 0x451f
xorl %eax, %eax
callq 0x10b0
callq 0x1040
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/tests/sim.c
// Function: sim_inject_bad
void sim_inject_bad(int count)
{
	int i;

	for (i = 0; i < count; i++) {
		const int bno = random() % NUM_BLOCKS;

		blocks[bno].flags |= BLOCK_BAD_MARK | BLOCK_FAILED;
	}
}

// Assembly:
testl %edi, %edi
jle 0x35c7
pushq %r15
pushq %r14
pushq %rbx
movl %edi, %ebx
movabsq $0x487ede0487ede049, %r14 # imm = 0x487EDE0487EDE049
leaq 0x3e4b(%rip), %r15      # 0x73e0
callq 0x10d0
movq %rax, %rcx
imulq %r14
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x5, %rdx
addq %rax, %rdx
imulq $0x71, %rdx, %rax
subq %rax, %rcx
leaq (%rcx,%rcx,2), %rax
orb $0x3, (%r15,%rax,4)
decl %ebx
jne 0x3595
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/tests/sim.c
// Function: sim_inject_timebombs
void sim_inject_timebombs(int count, int max_ttl)
{
	int i;

	for (i = 0; i < count; i++)
		sim_set_timebomb(random() % NUM_BLOCKS,
				 random() % max_ttl + 1);
}

// Assembly:
testl %edi, %edi
jle 0x3677
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %edi, %ebx
movslq %esi, %r15
movabsq $0x487ede0487ede049, %r12 # imm = 0x487EDE0487EDE049
leaq 0x3da9(%rip), %r13      # 0x73e0
callq 0x10d0
movq %rax, %r14
imulq %r12
movq %rdx, %rax
shrq $0x3f, %rax
shrq $0x5, %rdx
addl %eax, %edx
imull $0x71, %edx, %eax
subl %eax, %r14d
callq 0x10d0
cqto
idivq %r15
incl %edx
leaq (%r14,%r14,2), %rax
movl %edx, 0x8(%r13,%rax,4)
decl %ebx
jne 0x3637
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/tests/sim.c
// Function: sim_dump
void sim_dump(void)
{
	int i;

	printf("NAND operation counts:\n");
	printf("    is_bad:         %d\n", stats.is_bad);
	printf("    mark_bad        %d\n", stats.mark_bad);
	printf("    erase:          %d\n", stats.erase);
	printf("    erase failures: %d\n", stats.erase_fail);
	printf("    is_erased:      %d\n", stats.is_erased);
	printf("    prog:           %d\n", stats.prog);
	printf("    prog failures:  %d\n", stats.prog_fail);
	printf("    read:           %d\n", stats.read);
	printf("    read (bytes):   %d\n", stats.read_bytes);
	printf("\n");

	printf("Block status:\n");
	i = 0;
	while (i < NUM_BLOCKS) {
		int j = NUM_BLOCKS - i;
		int k;

		if (j > 64)
			j = 64;

		printf("    ");
		for (k = 0; k < j; k++)
			fputc(rep_status(&blocks[i + k]), stdout);
		fputc('\n', stdout);

		i += j;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0xfa8(%rip), %rdi       # 0x4640
callq 0x1060
movl 0x3d11(%rip), %esi      # 0x73b4
leaq 0xeb9(%rip), %rdi       # 0x4563
xorl %eax, %eax
callq 0x1070
movl 0x3d01(%rip), %esi      # 0x73b8
leaq 0xebd(%rip), %rdi       # 0x457b
xorl %eax, %eax
callq 0x1070
movl 0x3cf1(%rip), %esi      # 0x73bc
leaq 0xec1(%rip), %rdi       # 0x4593
xorl %eax, %eax
callq 0x1070
movl 0x3ce1(%rip), %esi      # 0x73c0
leaq 0xec5(%rip), %rdi       # 0x45ab
xorl %eax, %eax
callq 0x1070
movl 0x3cd1(%rip), %esi      # 0x73c4
leaq 0xec9(%rip), %rdi       # 0x45c3
xorl %eax, %eax
callq 0x1070
movl 0x3cc1(%rip), %esi      # 0x73c8
leaq 0xecd(%rip), %rdi       # 0x45db
xorl %eax, %eax
callq 0x1070
movl 0x3cb1(%rip), %esi      # 0x73cc
leaq 0xed1(%rip), %rdi       # 0x45f3
xorl %eax, %eax
callq 0x1070
movl 0x3ca1(%rip), %esi      # 0x73d0
leaq 0xed5(%rip), %rdi       # 0x460b
xorl %eax, %eax
callq 0x1070
movl 0x3c91(%rip), %esi      # 0x73d4
leaq 0xed9(%rip), %rdi       # 0x4623
xorl %eax, %eax
callq 0x1070
movl $0xa, %edi
callq 0x1030
leaq 0xef5(%rip), %rdi       # 0x4657
callq 0x1060
leaq 0xbc6(%rip), %r15       # 0x4334
xorl %r14d, %r14d
movl $0x71, %ebp
subl %r14d, %ebp
cmpl $0x40, %ebp
movl $0x40, %eax
cmovgel %eax, %ebp
leaq 0xeb0(%rip), %rdi       # 0x463b
xorl %eax, %eax
callq 0x1070
cmpl $0x70, %r14d
jg 0x3814
movslq %r14d, %rax
cmpl $0x2, %ebp
movl $0x1, %ecx
cmovgel %ebp, %ecx
leaq (%rax,%rax,2), %rax
leaq 0x3c2f(%rip), %rdx      # 0x73e0
leaq (%rdx,%rax,4), %rbx
addq $0x4, %rbx
shlq $0x2, %rcx
leaq (%rcx,%rcx,2), %r12
xorl %r13d, %r13d
movl -0x4(%rbx,%r13), %eax
andl $0x3, %eax
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
cmpl $0x0, (%rbx,%r13)
movl $0x3a, %edi
movl $0x2e, %eax
cmovel %eax, %edi
jmp 0x37fc
movl $0x62, %edi
jmp 0x37fc
movl $0x42, %edi
jmp 0x37fc
movl $0x3f, %edi
movq 0x37d5(%rip), %rax      # 0x6fd8
movq (%rax), %rsi
callq 0x10a0
addq $0xc, %r13
cmpq %r13, %r12
jne 0x37c4
movq 0x37bd(%rip), %rax      # 0x6fd8
movq (%rax), %rsi
movl $0xa, %edi
callq 0x10a0
addl %ebp, %r14d
cmpl $0x71, %r14d
jl 0x3771
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/tests/util.c
// Function: seq_gen
void seq_gen(unsigned int seed, uint8_t *buf, size_t length)
{
	size_t i;

	srandom(seed);
	for (i = 0; i < length; i++)
		buf[i] = random();
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
callq 0x1050
testq %rbx, %rbx
je 0x386d
xorl %r15d, %r15d
callq 0x10d0
movb %al, (%r14,%r15)
incq %r15
cmpq %r15, %rbx
jne 0x385c
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/tests/util.c
// Function: seq_assert
void seq_assert(unsigned int seed, const uint8_t *buf, size_t length)
{
	size_t i;

	srandom(seed);
	for (i = 0; i < length; i++) {
		const uint8_t expect = random();

		if (buf[i] != expect) {
			fprintf(stderr, "seq_assert: mismatch at %ld in "
				"sequence %d: 0x%02x (expected 0x%02x)\n",
				i, seed, buf[i], expect);
			abort();
		}
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %r15
movl %edi, %ebx
callq 0x1050
testq %r14, %r14
je 0x38ab
xorl %r12d, %r12d
callq 0x10d0
movzbl (%r15,%r12), %r8d
movzbl %al, %r9d
cmpl %r8d, %r9d
jne 0x38b7
incq %r12
cmpq %r12, %r14
jne 0x3890
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0x373a(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0xd9d(%rip), %rsi       # 0x4665
movq %r12, %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x10b0
callq 0x1040
// File: /workspace/github_c_makefile_star2_O1/PARKINHYO[P]BlackjackGame/shm/./common.h
// Function: calc_sum
int calc_sum(const int hand_values[], int ncards)
{
	int i;
	int sum = 0;

	for (i = 0; i < ncards; ++i)
		if (hand_values[i] < 10)
			sum += hand_values[i];
		else
			sum += 10;

	for (i = 0; i < ncards; ++i)
		if (hand_values[i] == 1)
			if (sum + 10 <= 21)
				sum += 10;

	return sum;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %esi, %ecx
testl %esi, %esi
jle 0x1478
xorl %eax, %eax
movl $0xa, %r8d
xorl %edx, %edx
movl (%rdi,%rax,4), %r9d
cmpl $0xa, %r9d
cmovgel %r8d, %r9d
addl %r9d, %edx
incq %rax
cmpq %rax, %rcx
jne 0x145f
jmp 0x147a
xorl %edx, %edx
testl %esi, %esi
jle 0x149c
xorl %esi, %esi
leal 0xa(%rdx), %eax
cmpl $0xc, %edx
cmovgel %edx, %eax
cmpl $0x1, (%rdi,%rsi,4)
cmovnel %edx, %eax
incq %rsi
movl %eax, %edx
cmpq %rsi, %rcx
jne 0x1480
jmp 0x149e
movl %edx, %eax
popq %rbp
retq