LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/nmmmnu[P]HM2/hm_dir.c
// Function: hm_dir_it_next
const hm_pair_t *hm_dir_it_next(hm_dir_it_t *it)
{
	const hm_pair_t *pair = NULL;

	size_t i;

	// step 1: find minimal in reverse order to find most recent.
	for(i = it->dir->count; i > 0; --i){
		const hm_pair_t *pair2 = it->p[i - 1].pair;

		// skip pair
		if (pair2 == NULL)
			continue;

		// initialize pair
		if (pair == NULL){
			pair = pair2;
			continue;
		}

		// compare and swap pair
		if (hm_pair_cmppair(pair, pair2) > 0)
			pair = pair2;
	}

	if (pair == NULL)
		return NULL;

	// step 2: increase all duplicates
	for(i = 0; i < it->dir->count; ++i){
		const hm_pair_t *pair2 = it->p[i].pair;

		if (pair2 && hm_pair_cmppair(pair, pair2) == 0){
			const hm_disktable_t *file = & it->dir->files[i];

			it->p[i].pair = hm_disktable_getat(file, ++it->p[i].pos);
		}
	}

	return pair;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rax
movq 0x8(%rax), %r12
xorl %r15d, %r15d
movq %r15, %r14
movq %r12, %rcx
negq %rcx
shlq $0x4, %r12
addq %rbx, %r12
movq %r12, %rax
movq %rcx, %r12
incq %r12
cmpq $0x1, %r12
je 0x179b
movq (%rax), %r15
addq $-0x10, %rax
testq %r15, %r15
je 0x176b
negq %r12
testq %r14, %r14
je 0x1755
movq %r14, %rdi
movq %r15, %rsi
callq 0x1998
testl %eax, %eax
cmovleq %r14, %r15
jmp 0x1755
testq %r14, %r14
je 0x17f1
leaq 0x10(%rbx), %r15
xorl %r12d, %r12d
xorl %r13d, %r13d
movq (%rbx), %rax
cmpq 0x8(%rax), %r13
jae 0x17f1
movq (%r15), %rsi
testq %rsi, %rsi
je 0x17e4
movq %r14, %rdi
callq 0x1998
testl %eax, %eax
jne 0x17e4
movq (%rbx), %rax
movq 0x10(%rax), %rdi
addq %r12, %rdi
movq -0x8(%r15), %rsi
incq %rsi
movq %rsi, -0x8(%r15)
callq 0x1bb8
movq %rax, (%r15)
incq %r13
addq $0x10, %r15
addq $0x28, %r12
jmp 0x17aa
movq %r14, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/nmmmnu[P]HM2/hm_dir.c
// Function: hm_dir_printf
void hm_dir_printf(const hm_dir_t *dir)
{
	size_t i;
	for(i = 0; i < dir->count; ++i){
		hm_disktable_t *file = & dir->files[i];

		printf("%5zu : %s\n", i, file->filename);
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x18d6(%rip), %r14      # 0x30e6
xorl %r12d, %r12d
xorl %r15d, %r15d
cmpq 0x8(%rbx), %r15
jae 0x183a
movq 0x10(%rbx), %rax
movq (%rax,%r12), %rdx
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x1090
incq %r15
addq $0x28, %r12
jmp 0x1816
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop
// File: /workspace/github_c_makefile_star2_O2/nmmmnu[P]HM2/hm_pair.c
// Function: hm_pair_createnx
hm_pair_t *hm_pair_createnx(const char*key, const char*val, hm_valsize_t vallen, uint32_t expires){
	/*
	Assumptions:
	1. key   is string, up to uint16_t
	2. value is blob up to uint32_t
	3. after the key we store \0 byte, so we can use it as C string.
	4. after the value we store \0 byte, so we can use it as C string.
	*/

	if (key == NULL)
		return NULL;

	// because we need to to thombstones someday, we allow empty values
	// we do not need to change the val
	if (val == NULL)
		vallen = 0;

	hm_keysize_t keylen = strlen(key);

	if (keylen >= MAX_KEYSIZE || vallen >= MAX_VALSIZE)
		return NULL;

	hm_pair_t *pair = xmalloc(sizeof(hm_pair_t) + keylen + 1 + vallen + 1);

	if (pair == NULL)
		return NULL;

#ifdef HM_PAIR_EXPIRATION
	pair->created	= htobe64(_hm_pair_now());
	pair->expires	= htobe32(expires);
#endif

	pair->keylen	= htobe16(keylen);
	pair->vallen	= htobe32(vallen);

	// memcpy so we can switch to blobs later...
	memcpy(& pair->buffer[0], key, keylen);
	pair->buffer[keylen] = '\0';

	// this is safe with NULL pointer.
	memcpy(& pair->buffer[keylen + 1], val, vallen);
	pair->buffer[keylen + 1 + vallen] = '\0';

	// this is dummy method if no checksum
	hm_pair_checksummake(pair);

#if 0
	printf("hm_pair_t @ %12p\nbuffer %12p\nkey %u\nval %u\n", pair, pair->buffer, keylen, vallen);
	size_t i;
	for(i = 0; i < keylen + 1 + vallen + 1; i++)
		printf("%3zu | %3u | %2X | %c\n", i, pair->buffer[i], pair->buffer[i], pair->buffer[i]);
#endif

	return pair;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
xorl %ebx, %ebx
testq %rdi, %rdi
je 0x1913
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %r12
testq %rsi, %rsi
cmovel %ebx, %r14d
callq 0x1070
movq %rax, %rbp
movl $0xffff, %eax           # imm = 0xFFFF
movl %ebp, %r13d
andl %eax, %r13d
cmpl %eax, %r13d
sete %al
cmpl $-0x1, %r14d
sete %cl
orb %al, %cl
jne 0x1913
movzwl %bp, %ecx
movl %r14d, %eax
movq %rax, 0x10(%rsp)
movq %rcx, 0x8(%rsp)
leaq (%rax,%rcx), %rdi
addq $0x9, %rdi
callq 0x1130
testq %rax, %rax
je 0x1911
movq %rax, %rbx
rolw $0x8, %bp
movw %bp, 0x4(%rax)
movl %r14d, %eax
bswapl %eax
movl %eax, (%rbx)
leaq 0x7(%rbx), %rdi
movq %r12, %rsi
movq 0x8(%rsp), %r12
movq %r12, %rdx
callq 0x1100
xorl %ebp, %ebp
movb %bpl, 0x7(%rbx,%r12)
movl %r13d, %eax
leaq (%rax,%rbx), %rdi
addq $0x8, %rdi
movq %r15, %rsi
movq 0x10(%rsp), %rdx
callq 0x1100
leal (%r14,%r13), %eax
incl %eax
movb %bpl, 0x7(%rbx,%rax)
movq %rbx, %rdi
callq 0x1925
jmp 0x1913
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/nmmmnu[P]HM2/hm_pair.c
// Function: hm_pair_printf
int hm_pair_printf(const hm_pair_t *pair){
	printf("| %s | %-12p | %-20s | %-20s |\n",
			"hm_pair_t",
			pair,
			hm_pair_getkey(pair),
			hm_pair_getval(pair)
	);

	return 0;
}

// Assembly:
movq %rdi, %rdx
leaq 0x7(%rdi), %rcx
cmpl $0x0, (%rdi)
je 0x1a2b
movzwl 0x4(%rdx), %eax
rolw $0x8, %ax
movzwl %ax, %eax
leaq (%rax,%rcx), %r8
incq %r8
jmp 0x1a2e
xorl %r8d, %r8d
pushq %rax
leaq 0x16bb(%rip), %rdi      # 0x30f1
leaq 0x16d4(%rip), %rsi      # 0x3111
xorl %eax, %eax
callq 0x1090
xorl %eax, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O2/nmmmnu[P]HM2/hm_disktable.c
// Function: hm_disktable_open
hm_disktable_t *hm_disktable_open(hm_disktable_t *mmf, const char *filename)
{
	FILE *F = fopen(filename, "r");

	if (F == NULL)
		return NULL;

	fseek(F, 0, SEEK_END);

	off_t size = ftello(F);

	char *mem = mmap(NULL, size, PROT_READ, MAP_SHARED, fileno(F), /* offset */ 0);

	if (mem == MAP_FAILED){
		fclose(F);
		return NULL;
	}

	//printf("%s %llu %p\n", filename, size, mem);

	mmf->F = F;
	mmf->filename = filename;
	mmf->size = size;
	mmf->mem = mem;

	// memoize count instead to read it from the disk each time
	mmf->count = _hm_disktable_getcount(mem);

	return mmf;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x16be(%rip), %rsi      # 0x311b
movq %r14, %rdi
callq 0x10e0
testq %rax, %rax
je 0x1acb
movq %rax, %r15
pushq $0x2
popq %rdx
movq %rax, %rdi
xorl %esi, %esi
callq 0x1140
movq %r15, %rdi
callq 0x10b0
movq %rax, %r12
movq %r15, %rdi
callq 0x1110
pushq $0x1
popq %rcx
xorl %edi, %edi
movq %r12, %rsi
movl %ecx, %edx
movl %eax, %r8d
xorl %r9d, %r9d
callq 0x1120
cmpq $-0x1, %rax
je 0x1ac3
movq %r15, 0x10(%rbx)
movq %r14, (%rbx)
movq %r12, 0x8(%rbx)
movq %rax, 0x20(%rbx)
movq (%rax), %rax
bswapq %rax
movq %rax, 0x18(%rbx)
jmp 0x1acd
movq %r15, %rdi
callq 0x1050
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/nmmmnu[P]HM2/hm_disktable.c
// Function: hm_disktable_opena
hm_disktable_t *hm_disktable_opena(const char *filename)
{
	hm_disktable_t *mmf = malloc(sizeof(hm_disktable_t));

	if (mmf == NULL)
		return NULL;

	if (hm_disktable_open(mmf, filename))
		return mmf;

	free(mmf);

	return NULL;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
pushq $0x28
popq %rdi
callq 0x1130
testq %rax, %rax
je 0x1b0b
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
callq 0x1a48
testq %rax, %rax
jne 0x1b0d
movq %rbx, %rdi
callq 0x1030
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/nmmmnu[P]HM2/hm_disktable.c
// Function: hm_disktable_get
static const void *_hm_disktable_locate_bsearch(const hm_disktable_t *mmf, const char *key, uint64_t *ppos)
{
	if (key == NULL)
		return NULL;

	uint64_t start = 0;
	uint64_t end = mmf->count;

	while (start < end){
		uint64_t mid = start + ((end - start) >> 1);

		const void *pair = hm_disktable_getat(mmf, mid);

		// This is highly unlikely, but better check it.
		if (pair == NULL)
			return NULL;

		//printf("| %lu %lu %lu | %lu | %lx | %s\n", start, mid, end, ptr, ptr, hm_pair_getkey(pair));

		const int cmp = strcmp(hm_pair_getkey(pair), key);

		if (cmp == 0){
			if (ppos)
				*ppos = mid;

			return pair;
		}

		if (cmp < 0){
			// go right
			start = mid + 1;
		}else{
			// go left
			end = mid;
		}
	}

	return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rsi, %rsi
je 0x1ba3
movq %rsi, %rbx
movq %rdi, %r14
movq 0x18(%rdi), %r12
xorl %r13d, %r13d
movq %r12, %rbp
subq %r13, %rbp
jbe 0x1ba3
shrq %rbp
addq %r13, %rbp
cmpq %rbp, 0x18(%r14)
jbe 0x1ba3
movq 0x20(%r14), %rax
testq %rax, %rax
je 0x1ba3
movq 0x8(%rax,%rbp,8), %r15
bswapq %r15
addq %rax, %r15
movq %r15, %rdi
callq 0x1966
movq %rax, %rdi
movq %rbx, %rsi
callq 0x10c0
testl %eax, %eax
je 0x1ba6
js 0x1b9b
movq %rbp, %r12
jmp 0x1b55
incq %rbp
movq %rbp, %r13
jmp 0x1b55
xorl %r15d, %r15d
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/nmmmnu[P]HM2/hm_disktable.c
// Function: hm_disktable_it_open
hm_disktable_it_t *hm_disktable_it_open(const hm_disktable_t *mmf)
{
	hm_disktable_it_t *it = malloc(sizeof(hm_disktable_it_t));

	if (it == NULL)
		return NULL;

	it->mmf = mmf;
	it->pos = 0;

	return it;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
pushq $0x10
popq %rdi
callq 0x1130
testq %rax, %rax
je 0x1bea
movq %rbx, (%rax)
andq $0x0, 0x8(%rax)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/nmmmnu[P]HM2/hm_disktable.c
// Function: hm_disktable_createfrommemtable
int hm_disktable_createfrommemtable(const hm_memtable_t *memtable, const char *filename_to_write)
{
	FILE *F = fopen(filename_to_write, "w");
	if (F == NULL){
		printf("Can not create a file %s...\n", filename_to_write);
		return 1;
	}

	int result = hm_disktable_createfrommemtablef(memtable, F);

	fclose(F);

	return result;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x14e8(%rip), %rsi      # 0x311d
movq %rbx, %rdi
callq 0x10e0
testq %rax, %rax
je 0x1c5e
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
callq 0x1c78
movl %eax, %ebx
movq %r15, %rdi
callq 0x1050
movl %ebx, %eax
jmp 0x1c72
leaq 0x14ba(%rip), %rdi      # 0x311f
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1090
pushq $0x1
popq %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/nmmmnu[P]HM2/hm_disktable.c
// Function: hm_disktable_createfrommemtablef
int hm_disktable_createfrommemtablef(const hm_memtable_t *memtable, FILE *F)
{
	uint64_t be;

	const uint64_t datacount = hm_memtable_count(memtable);
	const size_t header_size = sizeof(hm_disktable_fileformat_t);
	const size_t table_size  = sizeof(uint64_t) * datacount;

	/* preallocating the file do not really speed up the fwrite process.

	const size_t total_size  = header_size + table_size + hm_memtable_sizeof(memtable);
	posix_fallocate(fileno(F), 0, total_size);
	*/

	size_t current_place = header_size + table_size;


	// write table header (currently size only)
	hm_disktable_fileformat_t header;
	header.size = htobe64(datacount);
	fwrite(& header, sizeof(header), 1, F);

	hm_memtable_it_t *it = hm_memtable_it_open(memtable);

	if (it == NULL)
		return 1;

	const hm_pair_t *pair;

	// traverse and write the table.
	for(pair = hm_memtable_it_first(it); pair; pair = hm_memtable_it_next(it)){
		be = htobe64(current_place);
		fwrite(& be, sizeof(uint64_t), 1, F);

		current_place += hm_pair_sizeof(pair);
	}

	// traverse and write the data.
	for(pair = hm_memtable_it_first(it); pair; pair = hm_memtable_it_next(it)){
		hm_pair_fwrite(pair, F);
	}

	hm_memtable_it_close(it);

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r14
callq 0x21f9
movq %rax, %r15
bswapq %rax
leaq 0x10(%rsp), %rdi
movq %rax, (%rdi)
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x1170
movq %r14, %rdi
callq 0x2202
testq %rax, %rax
je 0x1d45
movq %rax, %r14
leaq 0x8(,%r15,8), %r15
movq %rax, %rdi
callq 0x220c
movq %rax, %rbp
pushq $0x8
popq %r12
pushq $0x1
popq %r13
testq %rbp, %rbp
je 0x1d17
movq %r15, %rax
bswapq %rax
movq %rax, 0x8(%rsp)
leaq 0x8(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x1170
movq %rbp, %rdi
callq 0x194d
addq %rax, %r15
movq %r14, %rdi
callq 0x2226
movq %rax, %rbp
jmp 0x1cdc
movq %r14, %rdi
callq 0x220c
testq %rax, %rax
je 0x1d39
movq %rax, %rdi
movq %rbx, %rsi
callq 0x19e4
movq %r14, %rdi
callq 0x2226
jmp 0x1d1f
movq %r14, %rdi
callq 0x2207
xorl %eax, %eax
jmp 0x1d48
pushq $0x1
popq %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O2/nmmmnu[P]HM2/hm_skiplist.c
// Function: hm_skiplist_create
hm_skiplist_t *hm_skiplist_create(hm_skiplist_t *l, hm_skiplist_height_t height)
{
	if (height == 0 || height > MAX_HEIGHT)
		height = DEF_HEIGHT;


	l->height = height;

	l->heads = malloc(2 * sizeof(void *) * (height + 1));

	if (l->heads == NULL)
		return NULL;

	l->loc = & l->heads[height];

	return _hm_skiplist_clear(l);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leal -0x41(%rsi), %eax
cmpb $-0x40, %al
pushq $0x20
popq %r14
cmovael %esi, %r14d
movb %r14b, 0x10(%rdi)
leal 0x1(%r14), %eax
movzbl %al, %edi
shll $0x4, %edi
callq 0x1130
movq %rax, 0x18(%rbx)
testq %rax, %rax
je 0x1dab
movzbl %r14b, %edx
shll $0x3, %edx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, 0x20(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq %rax, %rdi
xorl %esi, %esi
callq 0x10a0
jmp 0x1dad
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/nmmmnu[P]HM2/hm_skiplist.c
// Function: hm_skiplist_createa
hm_skiplist_t *hm_skiplist_createa(hm_skiplist_height_t height)
{
	hm_skiplist_t *l = malloc(sizeof(hm_skiplist_t));

	if (l == NULL)
		return NULL;

	if (hm_skiplist_create(l, height))
		return l;

	free(l);

	return NULL;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %edi, %ebp
pushq $0x28
popq %rdi
callq 0x1130
testq %rax, %rax
je 0x1de6
movq %rax, %rbx
movzbl %bpl, %esi
movq %rax, %rdi
callq 0x1d58
testq %rax, %rax
jne 0x1de8
movq %rbx, %rdi
callq 0x1030
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/nmmmnu[P]HM2/hm_skiplist.c
// Function: hm_skiplist_removeall
void hm_skiplist_removeall(hm_skiplist_t *l)
{
	hm_skiplist_node_t *copy;
	hm_skiplist_node_t *node;
	for(node = l->heads[0]; node; ){
		copy = node;

		node = node->next[0];

		hm_pair_free(copy->data);
		free(copy);
	}

	_hm_skiplist_clear(l);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x18(%rdi), %rax
movq (%rax), %r14
testq %r14, %r14
je 0x1e32
movq (%r14), %rdi
movq 0x10(%r14), %r15
callq 0x1933
movq %r14, %rdi
callq 0x1030
movq %r15, %r14
jmp 0x1e14
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq 0x18(%rbx), %rdi
movzbl 0x10(%rbx), %edx
shll $0x3, %edx
xorl %esi, %esi
popq %rbx
popq %r14
popq %r15
jmp 0x10a0
// File: /workspace/github_c_makefile_star2_O2/nmmmnu[P]HM2/hm_skiplist.c
// Function: hm_skiplist_put
int hm_skiplist_put(hm_skiplist_t *l, hm_pair_t *newdata)
{
	if (newdata == NULL)
		return 0;

	const char *key = hm_pair_getkey(newdata);

	hm_skiplist_node_t *node = (hm_skiplist_node_t *) _hm_skiplist_locate(l, key, 0);

	if (node){
		// update in place. node MUST be not NULL...

		hm_pair_t *olddata = node->data;

		// check if the data in database is valid
		if (! hm_pair_valid(newdata, olddata)){
			// prevent memory leak
			hm_pair_free(newdata);
			return 0;
		}

		// leave node, update only the data
		node->data = newdata;

		l->datasize = l->datasize
			- hm_pair_sizeof(olddata)
			+ hm_pair_sizeof(newdata);

		// release old data
		hm_pair_free(olddata);

		return 1;
	}

	// create new node

	unsigned char height = _hm_skiplist_height(l);

	hm_skiplist_node_t *newnode = malloc(sizeof(hm_skiplist_node_t) + height * sizeof(void *) );
	if (newnode == NULL){
		// prevent memory leak
		hm_pair_free(newdata);
		return 0;
	}

	newnode->height = height;
	newnode->data = newdata;

	// place new node where it belongs

	hm_skiplist_height_t i;
	for(i = 0; i < height; ++i){
		if (l->loc[i]){
			// we are at the middle
			hm_skiplist_node_t *node = l->loc[i];

			newnode->next[i] = node->next[i];
			node->next[i] = newnode;
		}else{
			newnode->next[i] = l->heads[i];
			l->heads[i] = newnode;
		}
	}

	l->datasize += hm_pair_sizeof(newdata);
	l->datacount++;

	return 1;
}

// Assembly:
testq %rsi, %rsi
je 0x1ec2
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x1966
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x1f76
testq %rax, %rax
je 0x1ec5
movq %rax, %r12
movq (%rax), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x19a5
testl %eax, %eax
je 0x1f39
movq %r14, (%r12)
movq (%rbx), %r12
movq %r15, %rdi
callq 0x194d
subq %rax, %r12
movq %r14, %rdi
callq 0x194d
addq %r12, %rax
movq %rax, (%rbx)
movq %r15, %rdi
callq 0x1933
jmp 0x1f67
xorl %eax, %eax
retq
pushq $0x1
popq %r12
pushq $0x18
popq %r15
cmpb 0x10(%rbx), %r12b
jae 0x1ee8
callq 0x1190
cmpl $0x40000000, %eax       # imm = 0x40000000
jl 0x1ee8
incq %r12
addq $0x8, %r15
jmp 0x1ecd
movq %r15, %rdi
callq 0x1130
testq %rax, %rax
je 0x1f39
movb %r12b, 0x8(%rax)
movq %r14, (%rax)
pushq $0x10
popq %rcx
xorl %edx, %edx
subq $0x1, %r12
jb 0x1f45
movq 0x20(%rbx), %rsi
movq -0x10(%rsi,%rcx), %rsi
testq %rsi, %rsi
je 0x1f1a
addq %rcx, %rsi
jmp 0x1f26
leaq (,%rdx,8), %rsi
addq 0x18(%rbx), %rsi
movq (%rsi), %rdi
movq %rdi, (%rax,%rcx)
movq %rax, (%rsi)
incq %rdx
addq $0x8, %rcx
jmp 0x1f01
movq %r14, %rdi
callq 0x1933
xorl %eax, %eax
jmp 0x1f6a
movq %r14, %rdi
callq 0x194d
movq %rax, %xmm0
shufpd $0x2, 0x11e5(%rip), %xmm0 # xmm0 = xmm0[0],mem[1]
movdqu (%rbx), %xmm1
paddq %xmm1, %xmm0
movdqu %xmm0, (%rbx)
pushq $0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/nmmmnu[P]HM2/hm_skiplist.c
// Function: hm_skiplist_locate
static const hm_skiplist_node_t *_hm_skiplist_locate(const hm_skiplist_t *l, const char *key, int complete_evaluation)
{
	// it is extremly dangerous to have key == NULL here.
	if (key == NULL){
		_hm_error("FATAL ERROR", __FILE__, __LINE__);
	}

	// smart over-optimizations, such skip NULL lanes or
	// start from the middle of the list did not pay off.

	int cmp = 1;

	const hm_skiplist_node_t *node = NULL;
	const hm_skiplist_node_t *prev = NULL;

	hm_skiplist_height_t height = l->height;
	while(height){
		node = prev ? prev : l->heads[height - 1];

		while(node){
			cmp = strcmp(hm_pair_getkey(node->data), key);

			if (cmp >= 0)
				break;

			prev = node;
			node = node->next[height - 1];
		}


		if (cmp == 0 && complete_evaluation == 0)
			return node;

		l->loc[height - 1] = (void *) prev;

		--height;
	}

	return cmp ? NULL : node;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, 0x4(%rsp)
testq %rsi, %rsi
je 0x2022
movq %rsi, %r14
movq %rdi, %r15
movzbl 0x10(%rdi), %ebp
pushq $0x1
popq %rax
xorl %r12d, %r12d
xorl %ebx, %ebx
movq %rbp, %r13
subq $0x1, %r13
jb 0x2008
testq %rbx, %rbx
je 0x1fba
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
addl %ecx, %ebp
movq %rbx, %rcx
jmp 0x1fc9
movq 0x18(%r15), %rcx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
addl %edx, %ebp
movq (%rcx,%rbp,8), %rcx
movq %rcx, %r12
testq %rcx, %rcx
je 0x1ff3
movq (%r12), %rdi
callq 0x1966
movq %rax, %rdi
movq %r14, %rsi
callq 0x10c0
testl %eax, %eax
jns 0x1ff3
movq 0x10(%r12,%rbp,8), %rcx
movq %r12, %rbx
jmp 0x1fc9
movl %eax, %ecx
orl 0x4(%rsp), %ecx
je 0x2010
movq 0x20(%r15), %rcx
movq %rbx, (%rcx,%rbp,8)
movq %r13, %rbp
jmp 0x1fa3
xorl %ecx, %ecx
testl %eax, %eax
cmovneq %rcx, %r12
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x3fcf(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
leaq 0x1145(%rip), %rsi      # 0x3178
leaq 0x1124(%rip), %rdx      # 0x315e
leaq 0x1129(%rip), %rcx      # 0x316a
movl $0x110, %r8d            # imm = 0x110
xorl %eax, %eax
callq 0x10d0
pushq $0x64
popq %rdi
callq 0x1160
// File: /workspace/github_c_makefile_star2_O2/nmmmnu[P]HM2/hm_skiplist.c
// Function: hm_skiplist_get
const hm_pair_t *hm_skiplist_get(const hm_skiplist_t *l, const char *key)
{
	if (key == NULL)
		return NULL;

	const hm_skiplist_node_t *node = _hm_skiplist_locate(l, key, 0);

	if (node)
		return node->data;

	return NULL;
}

// Assembly:
pushq %rbx
xorl %ebx, %ebx
testq %rsi, %rsi
je 0x206d
xorl %edx, %edx
callq 0x1f76
testq %rax, %rax
je 0x206d
movq (%rax), %rbx
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/nmmmnu[P]HM2/hm_skiplist.c
// Function: hm_skiplist_remove
int hm_skiplist_remove(hm_skiplist_t *l, const char *key)
{
	if (key == NULL)
		return 0;

	hm_skiplist_node_t *node = (hm_skiplist_node_t *) _hm_skiplist_locate(l, key, 1);

	if ( ! node){
		// the key does not exists in the list.
		return 1;
	}

	hm_skiplist_height_t i;
	for(i = 0; i < l->height; ++i){
		hm_skiplist_node_t *prev = l->loc[i];

		if (prev){
			// check if lane go to this node...
			if (prev->next[i] == node)
				prev->next[i] = node->next[i];
		}else{
			// must be first
			if (l->heads[i] == node)
				l->heads[i] = node->next[i];
		}
	}

	l->datasize -= hm_pair_sizeof(node->data);
	l->datacount--;

	hm_pair_free(node->data);
	free(node);

	return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
testq %rsi, %rsi
je 0x2103
movq %rdi, %r14
pushq $0x1
popq %rbx
movl %ebx, %edx
callq 0x1f76
testq %rax, %rax
je 0x2105
movq %rax, %r15
movzbl 0x10(%r14), %eax
shll $0x3, %eax
xorl %ecx, %ecx
xorl %edx, %edx
cmpq %rcx, %rax
je 0x20e2
movq 0x20(%r14), %rsi
movq (%rsi,%rcx), %rsi
testq %rsi, %rsi
je 0x20c3
cmpq %r15, 0x10(%rsi,%rcx)
jne 0x20d9
addq %rcx, %rsi
addq $0x10, %rsi
jmp 0x20d1
movq 0x18(%r14), %rsi
cmpq %r15, (%rsi,%rcx)
jne 0x20d9
leaq (%rsi,%rdx,8), %rsi
movq 0x10(%r15,%rcx), %rdi
movq %rdi, (%rsi)
incq %rdx
addq $0x8, %rcx
jmp 0x20a1
movq (%r15), %rdi
callq 0x194d
subq %rax, (%r14)
decq 0x8(%r14)
movq (%r15), %rdi
callq 0x1933
movq %r15, %rdi
callq 0x1030
jmp 0x2105
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/nmmmnu[P]HM2/hm_skiplist.c
// Function: hm_skiplist_printf_lanes
void hm_skiplist_printf_lanes(const hm_skiplist_t *l)
{
	hm_skiplist_height_t i;
	for(i = l->height; i >= 0; --i){
		printf("Lane # %5u :\n", i - 1);
		_hm_skiplist_printf_lane(l, i - 1);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movb 0x10(%rdi), %r15b
leaq 0x1021(%rip), %r14      # 0x3150
movzbl %r15b, %ebp
decl %ebp
movq %r14, %rdi
movl %ebp, %esi
xorl %eax, %eax
callq 0x1090
movzbl %bpl, %r12d
movl %r12d, %eax
shll $0x3, %eax
addq 0x18(%rbx), %rax
movb $0x11, %bpl
movq (%rax), %r13
testq %r13, %r13
je 0x2176
movq (%r13), %rdi
callq 0x1a0b
subb $0x1, %bpl
jb 0x2176
leaq 0x10(,%r12,8), %rax
addq %r13, %rax
jmp 0x2152
decb %r15b
jmp 0x212f
// File: /workspace/github_c_makefile_star2_O2/nmmmnu[P]HM2/hm_skiplist.c
// Function: hm_skiplist_it_open
const hm_skiplist_it_t *hm_skiplist_it_open(const hm_skiplist_t *l)
{
	hm_skiplist_it_t *it = malloc(sizeof(hm_skiplist_it_t));
	if (it == NULL)
		return NULL;

	it->l = l;
	it->node = NULL;

	return it;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
pushq $0x10
popq %rdi
callq 0x1130
testq %rax, %rax
je 0x2194
movq %rbx, (%rax)
andq $0x0, 0x8(%rax)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/nmmmnu[P]HM2/hm_skiplist.c
// Function: hm_skiplist_it_next
const hm_pair_t *hm_skiplist_it_next(hm_skiplist_it_t *it)
{
	if (it->node == NULL)
		return NULL;

	const hm_skiplist_node_t *node = it->node;
	node = node->next[0];
	it->node = node;

	return node ? node->data : NULL;
}

// Assembly:
movq 0x8(%rdi), %rax
testq %rax, %rax
je 0x21cf
movq 0x10(%rax), %rax
movq %rax, 0x8(%rdi)
testq %rax, %rax
je 0x21cf
movq (%rax), %rax
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/Carben-dev[P]ext2fs-simple-utilities/ext2_restore.c
// Function: main
int main(int argc, const char * argv[]) {
    if(argc != 3) {
        fprintf(stderr, "Usage: <image file name> <absolute path of rm file>\n");
        exit(1);
    }
    int fd = open(argv[1], O_RDWR);
    
    // map disk img into memory
    disk = mmap(NULL, 128 * 1024, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
    if(disk == MAP_FAILED) {
        perror("mmap");
        exit(1);
    }
    
    // Init utils
    ext2_utils_init();
    
    //
    unsigned long path_len = strlen(argv[2]) + 1;
    char path[path_len];
    char path_parent[path_len];
    char path_name[EXT2_NAME_LEN];
    
    strcpy(path, argv[2]);
    clear_end_slash(path);
    cut_path(path, path_parent, path_name);
    
    // check if exist
    int parent_inode_num = get_inode_number_by_path(path_parent);
    if (parent_inode_num < 0) {
        return ENOENT;
    }
    
    struct ext2_inode *parent_inode = inode_table + parent_inode_num - 1;
    
    if (restore_from_dir_entry(parent_inode, path_name)) {
        return ENOENT;
    }
    
    
    
    
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x100, %rsp            # imm = 0x100
cmpl $0x3, %edi
jne 0x1318
movq %rsi, %r14
movq 0x8(%rsi), %rdi
pushq $0x2
popq %rbx
movl %ebx, %esi
xorl %eax, %eax
callq 0x10f0
pushq $0x3
popq %rdx
pushq $0x1
popq %rcx
movl $0x20000, %esi          # imm = 0x20000
xorl %edi, %edi
movl %eax, %r8d
xorl %r9d, %r9d
callq 0x1080
movq %rax, 0x3e37(%rip)      # 0x50b0
cmpq $-0x1, %rax
je 0x1336
callq 0x134c
movq 0x10(%r14), %r14
movq %r14, %rdi
callq 0x1070
movq %rsp, %r15
addq $0x10, %rax
andq $-0x10, %rax
subq %rax, %r15
movq %r15, %rsp
movq %rsp, %r12
subq %rax, %r12
movq %r12, %rsp
movq %r15, %rdi
movq %r14, %rsi
callq 0x1060
movq %r15, %rdi
callq 0x1f87
leaq -0x120(%rbp), %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x1f9e
movq %r12, %rdi
callq 0x15d3
testl %eax, %eax
js 0x1309
movq 0x3dd2(%rip), %rcx      # 0x50b8
movl %eax, %eax
shlq $0x7, %rax
leaq (%rcx,%rax), %rdi
addq $-0x80, %rdi
leaq -0x120(%rbp), %rsi
callq 0x1af2
xorl %ebx, %ebx
testl %eax, %eax
setne %bl
addl %ebx, %ebx
movl %ebx, %eax
leaq -0x20(%rbp), %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x3cd9(%rip), %rax      # 0x4ff8
movq (%rax), %rcx
leaq 0x1cdb(%rip), %rdi      # 0x3004
pushq $0x34
popq %rsi
pushq $0x1
popq %rdx
callq 0x1120
jmp 0x1342
leaq 0x1cfc(%rip), %rdi      # 0x3039
callq 0x1100
pushq $0x1
popq %rdi
callq 0x1110
nop
// File: /workspace/github_c_makefile_star2_O2/Carben-dev[P]ext2fs-simple-utilities/ext2_utils.c
// Function: ext2_utils_init
void ext2_utils_init() {
    // Init global varible.
    // setup sb, gdt, block_bitmap, inode_bitmap, inode_table
    sb = (struct ext2_super_block *)(disk + EXT2_BLOCK_SIZE);
    gdt = (struct ext2_group_desc *)(disk + EXT2_BLOCK_SIZE + sizeof(struct ext2_super_block));
    block_bitmap = (unsigned char *)(disk + (gdt->bg_block_bitmap * EXT2_BLOCK_SIZE));
    inode_bitmap = (unsigned char *)(disk + (gdt->bg_inode_bitmap * EXT2_BLOCK_SIZE));
    inode_table = (struct ext2_inode *)(disk + (gdt->bg_inode_table * EXT2_BLOCK_SIZE));
    return;
}

// Assembly:
leaq 0x3d5d(%rip), %rax      # 0x50b0
movq (%rax), %rax
leaq 0x400(%rax), %rcx
leaq 0x3d5c(%rip), %rdx      # 0x50c0
movq %rcx, (%rdx)
leaq 0x800(%rax), %rcx
leaq 0x3d53(%rip), %rdx      # 0x50c8
movq %rcx, (%rdx)
movl 0x800(%rax), %ecx
shll $0xa, %ecx
addq %rax, %rcx
leaq 0x3d45(%rip), %rdx      # 0x50d0
movq %rcx, (%rdx)
movl 0x804(%rax), %ecx
shll $0xa, %ecx
addq %rax, %rcx
leaq 0x3d37(%rip), %rdx      # 0x50d8
movq %rcx, (%rdx)
movl 0x808(%rax), %ecx
shll $0xa, %ecx
addq %rax, %rcx
leaq 0x3d01(%rip), %rax      # 0x50b8
movq %rcx, (%rax)
retq
// File: /workspace/github_c_makefile_star2_O2/Carben-dev[P]ext2fs-simple-utilities/ext2_utils.c
// Function: get_inode_number_by_name
int get_inode_number_by_name(int in_which_dir_num,
                             char *name)
{
    // Inode index = inode number - 1
    // Get inode by inode index.
    struct ext2_inode *in_which_inode = inode_table + in_which_dir_num - 1;
    
    int curr_i_block = 0;
    int *in_which_inode_i_block_array = read_i_block_into_array(in_which_inode);
    // walk through each datablock of parent dir
    while (in_which_inode_i_block_array[curr_i_block] != -1) {
        unsigned char *in_which_inode_data = disk + EXT2_BLOCK_SIZE * in_which_inode_i_block_array[curr_i_block];
        
        // Dir entry struct
        struct ext2_dir_entry *entry;
        // Offset in data block
        int curr_entry_off = 0;
        // walk through datablock
        while (curr_entry_off < EXT2_BLOCK_SIZE) {
            entry = (struct ext2_dir_entry *)(in_which_inode_data + curr_entry_off);
            if (strncmp(entry->name, name, entry->name_len) == 0) {
                return entry->inode;
            }
            curr_entry_off += entry->rec_len;
        }
        curr_i_block++;
    }
    // If reach here no match found
    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
leaq 0x3ce8(%rip), %rax      # 0x50b8
movq (%rax), %rax
movslq %edi, %rcx
shlq $0x7, %rcx
leaq (%rax,%rcx), %rdi
addq $-0x80, %rdi
callq 0x1460
leaq 0x3cc2(%rip), %rcx      # 0x50b0
movq (%rcx), %rcx
xorl %r12d, %r12d
movq %rax, (%rsp)
movslq (%rax,%r12,4), %r13
cmpq $-0x1, %r13
je 0x145b
shlq $0xa, %r13
movq %rcx, %r15
addq %rcx, %r13
xorl %ebp, %ebp
cmpl $0x3ff, %ebp            # imm = 0x3FF
ja 0x143d
movl %ebp, %eax
leaq (%rax,%r13), %r14
leaq (%rax,%r13), %rdi
addq $0x8, %rdi
movzbl -0x2(%rdi), %edx
movq %rbx, %rsi
callq 0x1050
testl %eax, %eax
je 0x1449
movzwl 0x4(%r14), %eax
addl %eax, %ebp
jmp 0x140e
incq %r12
movq (%rsp), %rax
movq %r15, %rcx
jmp 0x13f8
movl (%r14), %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $-0x1
popq %rax
jmp 0x144c
// File: /workspace/github_c_makefile_star2_O2/Carben-dev[P]ext2fs-simple-utilities/ext2_utils.c
// Function: read_i_block_into_array
int *read_i_block_into_array(struct ext2_inode *inode)
{
    int total_blocks = inode->i_blocks/2;
    int *result = malloc(sizeof(int) * (total_blocks + 1));
    int num_block_read = 0;
    int i;
    
    for (i = 0; i < 12; i++) {
        result[i] = inode->i_block[i];
        num_block_read++;
        if (num_block_read == total_blocks) {
            result[i + 1] = -1;
            return result;
        }
    }
    
    // If reach here, go into indirect_block
    num_block_read++;
    
    // Since disk size is 128kb, only consider the cases that
    //      there is only one indirect block.
    unsigned int *indirect_block = (unsigned int *)(disk + EXT2_BLOCK_SIZE * inode->i_block[12]);
    for (i = 0; i < EXT2_BLOCK_SIZE/4; i++) {
        result[12 + i] = indirect_block[i];
        num_block_read++;
        if (num_block_read == total_blocks) {
            result[12 + i + 1] = -1;
            return result;
        }
    }
    
    // If reach here, error
    free(result);
    return NULL;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x1c(%rdi), %r14d
shrl %r14d
leaq 0x4(,%r14,4), %rdi
callq 0x10e0
xorl %ecx, %ecx
cmpq $0xc, %rcx
je 0x1498
movl 0x28(%rbx,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
incq %rcx
cmpq %rcx, %r14
jne 0x147d
orl $-0x1, (%rax,%rcx,4)
jmp 0x14d7
leaq 0x3c11(%rip), %rdx      # 0x50b0
movl 0x58(%rbx), %ecx
shll $0xa, %ecx
addq (%rdx), %rcx
addq $-0xd, %r14
xorl %edx, %edx
cmpq $0x100, %rdx            # imm = 0x100
je 0x14cd
movl (%rcx,%rdx,4), %esi
movl %esi, 0x30(%rax,%rdx,4)
incq %rdx
cmpl %edx, %r14d
jne 0x14ae
orl $-0x1, 0x30(%rax,%rdx,4)
jmp 0x14d7
movq %rax, %rdi
callq 0x1030
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/Carben-dev[P]ext2fs-simple-utilities/ext2_utils.c
// Function: get_inode_number_by_path_helper
int get_inode_number_by_path_helper(char *path,
                                    int curr_inode_num)
{
    // Inode index = inode number - 1
    // Get inode by inode index.
    struct ext2_inode *curr_inode = inode_table + curr_inode_num - 1;
    
    // Prepare path
    // For example.
    // "d1/d2/d3" -> path_next_call: "d2/d3", dir_name: "d1"
    // "d3"       -> path_next_call: NULL   , dir_name: "d3"
    char *path_next_call = strchr(path, '/');
    char dir_name[EXT2_NAME_LEN];
    
    
    /*
     *  Base case:
     *      inode ref an reg file and not reach end return -1
     *          or
     *      reach end of path
     */
    
    if ((curr_inode->i_mode & EXT2_S_IFREG) &&
        path_next_call != NULL) {
        return -1;
    }
    
    // reach end of path, then search the inode number current dir.
    if (path_next_call == NULL) {
        memcpy(dir_name, path, strlen(path));
        return get_inode_number_by_name(curr_inode_num, dir_name);
    }
    
    
    /*
     *  Recursive part
     */
    
    // Prepare dir_name
    int i;
    int first_slash_index = 0;
    for (i = 0; i < strlen(path); i++) {
        if (path[i] == '/') {
            first_slash_index = i;
            break;
        }
    }
    memcpy(dir_name, path, first_slash_index);
    dir_name[first_slash_index] = '\0';
    
    // Enter next level dir
    // Before enter next level, check if entry exist.
    int next_level_inode = get_inode_number_by_name(curr_inode_num, dir_name);
    if (next_level_inode == -1) {
        return -1;
    }
    
    return get_inode_number_by_path_helper(path_next_call + 1, next_level_inode);
    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movl %esi, %ebx
movq %rdi, %r15
leaq 0x3bbc(%rip), %rax      # 0x50b8
movq (%rax), %r12
movslq %esi, %r13
shlq $0x7, %r13
pushq $0x2f
popq %rsi
callq 0x1090
movq %rax, %r14
cmpw $0x0, -0x80(%r12,%r13)
sets %al
testq %r14, %r14
setne %cl
pushq $-0x1
popq %rbp
testb %cl, %al
jne 0x15bf
movq %r15, %rdi
callq 0x1070
testq %r14, %r14
je 0x155a
negq %rax
pushq $-0x1
popq %rcx
leaq (%rax,%rcx), %rdx
cmpq $-0x1, %rdx
je 0x1579
leaq 0x1(%rcx), %r12
cmpb $0x2f, 0x1(%r15,%rcx)
movq %r12, %rcx
jne 0x153f
jmp 0x157c
movq %rsp, %r14
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x10c0
movl %ebx, %edi
movq %r14, %rsi
callq 0x13bb
movl %eax, %ebp
jmp 0x15bf
xorl %r12d, %r12d
movq %rsp, %r13
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x10c0
movb $0x0, (%rsp,%r12)
movl %ebx, %edi
movq %r13, %rsi
callq 0x13bb
cmpl $-0x1, %eax
je 0x15bf
incq %r14
movq %r14, %rdi
movl %eax, %esi
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x14df
movl %ebp, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Carben-dev[P]ext2fs-simple-utilities/ext2_utils.c
// Function: get_inode_number_by_path
int get_inode_number_by_path(char *path)
{
    // Invaild path not start with '/'
    if (path[0] != '/') {
        return -1;
    }
    
    // Case: path = "/"
    if (strlen(path) == 1) {
        return 2;
    }
    
    return get_inode_number_by_path_helper(path + 1, 2);
}

// Assembly:
pushq %rbx
cmpb $0x2f, (%rdi)
jne 0x15eb
movq %rdi, %rbx
callq 0x1070
cmpq $0x1, %rax
jne 0x15f0
pushq $0x2
jmp 0x15ed
pushq $-0x1
popq %rax
popq %rbx
retq
incq %rbx
pushq $0x2
popq %rsi
movq %rbx, %rdi
popq %rbx
jmp 0x14df
// File: /workspace/github_c_makefile_star2_O2/Carben-dev[P]ext2fs-simple-utilities/ext2_utils.c
// Function: inode_mkdir
int inode_mkdir(int parent,
                char *new_dir_name)
{
    struct ext2_inode *parent_inode = inode_table + parent - 1;
    
    int new_dir_inode_num = ialloc();
    int new_dir_datablock_idx = dalloc();
    if (new_dir_inode_num < 0 || new_dir_datablock_idx < 0) {
        return ENOSPC;
    }
    
    // Build inode and datablock for new dir
    struct ext2_inode *new_dir_inode = inode_table + new_dir_inode_num - 1;
    unsigned char *new_dir_datablock = disk + (EXT2_BLOCK_SIZE * new_dir_datablock_idx);
    
    new_dir_inode->i_mode           = 0x0000 | EXT2_S_IFDIR;
    new_dir_inode->i_uid            = 0;
    new_dir_inode->i_size           = EXT2_BLOCK_SIZE;
    new_dir_inode->i_ctime          = 0;
    new_dir_inode->i_mtime          = 0;
    new_dir_inode->i_dtime          = 0;
    new_dir_inode->i_gid            = 0;
    new_dir_inode->i_links_count    = 0;
    new_dir_inode->i_blocks         = new_dir_inode->i_size/512;
    new_dir_inode->i_flags          = 0;
    new_dir_inode->osd1             = 0;
    new_dir_inode->i_block[0]       = new_dir_datablock_idx;
    new_dir_inode->i_generation     = 0;
    new_dir_inode->i_file_acl       = 0;
    new_dir_inode->i_dir_acl        = 0;
    // padding
    memset(new_dir_inode->extra, 0, 3);
    
    // Init dir_entry datablock for new dir
    init_dir_entry(new_dir_datablock, new_dir_inode_num, parent);
    
    // Add inode back to parent dir entry
    add_to_dir_entry(parent_inode, new_dir_inode_num, new_dir_name, EXT2_FT_DIR);
    
    // Update gdt
    gdt->bg_used_dirs_count++;
    
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %rbx
movl %edi, %r14d
leaq 0x3aa4(%rip), %r12      # 0x50b8
movq (%r12), %r15
callq 0x16cc
movl %eax, %ebp
callq 0x1754
movl %ebp, %ecx
orl %eax, %ecx
jns 0x1632
pushq $0x1c
popq %rax
jmp 0x16c3
movslq %r14d, %rdx
movq (%r12), %rcx
movl %ebp, %esi
shlq $0x7, %rsi
leaq 0x3a6a(%rip), %r8       # 0x50b0
movl %eax, %edi
shll $0xa, %edi
addq (%r8), %rdi
movabsq $0x40000004000, %r8     # imm = 0x40000004000
movq %r8, -0x80(%rcx,%rsi)
movq %rdx, %r8
shlq $0x7, %r8
xorps %xmm0, %xmm0
movups %xmm0, -0x74(%rcx,%rsi)
movq $0x2, -0x64(%rcx,%rsi)
andl $0x0, -0x5c(%rcx,%rsi)
movl %eax, -0x58(%rcx,%rsi)
andq $0x0, -0x1c(%rcx,%rsi)
leaq (%r15,%r8), %r14
addq $-0x80, %r14
andl $0x0, -0x14(%rcx,%rsi)
andw $0x0, -0xc(%rcx,%rsi)
movb $0x0, -0xa(%rcx,%rsi)
movl %ebp, %esi
callq 0x17d4
pushq $0x2
popq %rcx
movq %r14, %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0x1814
leaq 0x3a0e(%rip), %rax      # 0x50c8
movq (%rax), %rax
incw 0x10(%rax)
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Carben-dev[P]ext2fs-simple-utilities/ext2_utils.c
// Function: ialloc
int ialloc(void) {
    if (gdt->bg_free_inodes_count == 0) {
        return -1;
    }
    
    unsigned char *inode_bitmap_ptr;
    int curr_byte = 0;
    int vaild_byte_count = sb->s_inodes_count/8;
    int curr_inode_num = 0;
    int i;
    
    while (curr_byte < vaild_byte_count) {
        inode_bitmap_ptr = inode_bitmap + curr_byte;
        for (i = 0; i < 8; i++) {
            curr_inode_num++;
            if (!((*inode_bitmap_ptr)>>i & 1)){
                // Set inode bitmap
                *inode_bitmap_ptr = *inode_bitmap_ptr | (1 << i);
                // Set gdt
                gdt->bg_free_inodes_count--;
                sb->s_free_inodes_count--;
                return curr_inode_num;
            }
            
        }
        curr_byte++;
    }
    
    return -1;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
leaq 0x39f1(%rip), %rdx      # 0x50c8
movq (%rdx), %rcx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpw $0x0, 0xe(%rcx)
je 0x174f
leaq 0x39d3(%rip), %rsi      # 0x50c0
movq (%rsi), %rcx
movl (%rcx), %r8d
shrl $0x3, %r8d
leaq 0x39da(%rip), %rcx      # 0x50d8
movq (%rcx), %r9
xorl %edi, %edi
movl $0x1, %r11d
xorl %r10d, %r10d
cmpq %r8, %r10
je 0x174f
movzbl (%r9,%r10), %ebx
xorl %ecx, %ecx
cmpl $0x8, %ecx
je 0x172f
movl %r11d, %r14d
shll %cl, %r14d
leal 0x1(%rcx), %ebp
btl %ecx, %ebx
movl %ebp, %ecx
jb 0x1718
jmp 0x1737
incq %r10
addl $-0x8, %edi
jmp 0x170c
orl %r14d, %ebx
movb %bl, (%r9,%r10)
movq (%rdx), %rax
decw 0xe(%rax)
movq (%rsi), %rax
decl 0x10(%rax)
subl %edi, %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Carben-dev[P]ext2fs-simple-utilities/ext2_utils.c
// Function: dalloc
int dalloc(void) {
    if (gdt->bg_free_blocks_count == 0) {
        return -1;
    }
    
    unsigned char *block_bitmap_ptr;
    int curr_byte = 0;
    int vaild_byte_count = sb->s_blocks_count/8;
    int curr_inode_num = 0;
    int i;
    
    while (curr_byte < vaild_byte_count) {
        block_bitmap_ptr = block_bitmap + curr_byte;
        for (i = 0; i < 8; i++) {
            if (!((*block_bitmap_ptr)>>i & 1)){
                // Update block bitmap
                *block_bitmap_ptr = *block_bitmap_ptr | (1 << i);
                // Update gdt
                gdt->bg_free_blocks_count--;
                sb->s_free_blocks_count--;
                return curr_inode_num;
            }
            curr_inode_num++;
        }
        curr_byte++;
    }
    
    return -1;
}

// Assembly:
pushq %rbp
pushq %rbx
leaq 0x396b(%rip), %rdx      # 0x50c8
movq (%rdx), %rcx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpw $0x0, 0xc(%rcx)
je 0x17d1
leaq 0x394d(%rip), %rsi      # 0x50c0
movq (%rsi), %rcx
movl 0x4(%rcx), %r8d
shrl $0x3, %r8d
leaq 0x394b(%rip), %rcx      # 0x50d0
movq (%rcx), %r9
xorl %edi, %edi
movl $0x1, %r11d
xorl %r10d, %r10d
cmpq %r8, %r10
je 0x17d1
movzbl (%r9,%r10), %ebx
xorl %ecx, %ecx
cmpl $0x8, %ecx
je 0x17b2
movl %r11d, %ebp
shll %cl, %ebp
btl %ecx, %ebx
jae 0x17ba
incl %ecx
jmp 0x179f
incq %r10
addl $-0x8, %edi
jmp 0x1793
orl %ebp, %ebx
movb %bl, (%r9,%r10)
movq (%rdx), %rax
decw 0xc(%rax)
movq (%rsi), %rax
decl 0xc(%rax)
subl %edi, %ecx
movl %ecx, %eax
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Carben-dev[P]ext2fs-simple-utilities/ext2_utils.c
// Function: remove_from_dir_entry
int remove_from_dir_entry(struct ext2_inode * parent_inode,
                          char *name)
{
    int *parent_inode_iblock_array = read_i_block_into_array(parent_inode);
    struct ext2_dir_entry *prev_entry;
    struct ext2_dir_entry *curr_entry;
    
    int i = -1;
    int curr_offset = 1024;
    while (parent_inode_iblock_array[i] != -1) {
        if (curr_offset == EXT2_BLOCK_SIZE) {
            i++;
            curr_offset = 0;
            prev_entry = (struct ext2_dir_entry *)(disk + EXT2_BLOCK_SIZE * parent_inode_iblock_array[i] + curr_offset);
            curr_entry = (struct ext2_dir_entry *)(disk + EXT2_BLOCK_SIZE * parent_inode_iblock_array[i] + curr_offset);
        }
        
        if (strncmp(name, curr_entry->name, curr_entry->name_len) == 0) {
            // do entry del
            prev_entry->rec_len += curr_entry->rec_len;
            // update inode link count
            struct ext2_inode *curr_inode = inode_table + curr_entry->inode - 1;
            curr_inode->i_links_count--;
            
            // inode link count drop to 0
            if (curr_inode->i_links_count == 0) {
                free_inode(curr_entry->inode);
            }
            
            free(parent_inode_iblock_array);
            return 0;
        }
        
        prev_entry = curr_entry;
        curr_offset += curr_entry->rec_len;
        curr_entry = (struct ext2_dir_entry *)(disk + EXT2_BLOCK_SIZE * parent_inode_iblock_array[i] + curr_offset);
    }
    
    free(parent_inode_iblock_array);
    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, 0x10(%rsp)
callq 0x1460
leaq 0x3705(%rip), %rcx      # 0x50b0
movq (%rcx), %r15
movq %rax, 0x8(%rsp)
movl -0x4(%rax), %r12d
movl $0x400, %r13d           # imm = 0x400
pushq $-0x1
popq %rbp
cmpl $-0x1, %r12d
je 0x1a28
cmpl $0x400, %r13d           # imm = 0x400
jne 0x19f0
movslq %ebp, %rax
incl %ebp
movq 0x8(%rsp), %rcx
movslq 0x4(%rcx,%rax,4), %r12
movq %r12, %rbx
shlq $0xa, %rbx
addq %r15, %rbx
xorl %r13d, %r13d
movq %rbx, %r14
jmp 0x19f6
movq %r14, %rbx
movq %rax, %r14
leaq 0x8(%r14), %rsi
movzbl 0x6(%r14), %edx
movq 0x10(%rsp), %rdi
callq 0x1050
movzwl 0x4(%r14), %ecx
testl %eax, %eax
je 0x1a37
movslq %r13d, %r13
addq %rcx, %r13
movl %r12d, %eax
shll $0xa, %eax
cltq
addq %r15, %rax
addq %r13, %rax
jmp 0x19c0
movq 0x8(%rsp), %rdi
callq 0x1030
pushq $-0x1
popq %rax
jmp 0x1a67
addw %cx, 0x4(%rbx)
leaq 0x3676(%rip), %rax      # 0x50b8
movq (%rax), %rax
movl (%r14), %edi
movq %rdi, %rcx
shlq $0x7, %rcx
decw -0x66(%rax,%rcx)
jne 0x1a5b
callq 0x1a76
movq 0x8(%rsp), %rdi
callq 0x1030
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Carben-dev[P]ext2fs-simple-utilities/ext2_utils.c
// Function: free_inode
void free_inode(int inode_num){
    struct ext2_inode *inode = inode_table +  inode_num - 1;
    int *inode_datablock_array = read_i_block_into_array(inode);
    
    // set del time
    inode->i_dtime = (unsigned int)time(NULL);
    
    // Mark bitmap as free
    
    int i = 0;
    while (inode_datablock_array[i] != -1) {
        dfree(inode_datablock_array[i]);
        i++;
    }
    if (i >= 12) { // free indirect block
        dfree(inode->i_block[12]);
    }
    
    // free inode
    ifree(inode_num);
    
    free(inode_datablock_array);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %edi, %ebx
leaq 0x3630(%rip), %rax      # 0x50b8
movq (%rax), %rax
movslq %edi, %rcx
shlq $0x7, %rcx
leaq (%rax,%rcx), %r12
leaq (%rax,%rcx), %r15
addq $-0x80, %r15
movq %r15, %rdi
callq 0x1460
movq %rax, %r14
xorl %r13d, %r13d
xorl %edi, %edi
callq 0x10d0
movl %eax, 0x14(%r15)
movl (%r14,%r13,4), %edi
cmpl $-0x1, %edi
je 0x1aca
callq 0x1ead
incq %r13
jmp 0x1ab7
cmpq $0xc, %r13
jb 0x1ada
movl -0x28(%r12), %edi
callq 0x1ead
movl %ebx, %edi
callq 0x1e5c
movq %r14, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x1030
// File: /workspace/github_c_makefile_star2_O2/Carben-dev[P]ext2fs-simple-utilities/ext2_utils.c
// Function: restore_inode_bitmap
int restore_inode_bitmap(int inode_num) {
    unsigned char *ptr;
    int in_which_byte;
    int off;
    
    in_which_byte = inode_num/8;
    if (inode_num%8) {
        in_which_byte++;
        off = inode_num%8;
    } else {
        off = 8;
    }
    
    
    ptr = inode_bitmap + (in_which_byte - 1);
    
    // check if in use
    if ((*ptr)>>(off - 1) & 1) {
        return -1;
    }
    
    // mark it back to used
    
    *ptr = *ptr | (1<<(off - 1));
    
    //update superblock and gdt
    gdt->bg_free_inodes_count--;
    sb->s_free_inodes_count--;
    
    return 0;
}

// Assembly:
movl %edi, %eax
pushq $0x8
popq %rcx
cltd
idivl %ecx
movl %edx, %ecx
subl $0x1, %ecx
sbbl $0x0, %eax
pushq $0x1
popq %rdi
shll %cl, %edi
cmpl $0x1, %edx
leaq 0x338a(%rip), %rcx      # 0x50d8
movq (%rcx), %rcx
cltq
movzbl (%rcx,%rax), %esi
movl $0x80, %edx
cmovael %edi, %edx
testl %esi, %edx
je 0x1d67
pushq $-0x1
popq %rax
retq
orb %sil, %dl
movb %dl, (%rcx,%rax)
leaq 0x3354(%rip), %rax      # 0x50c8
movq (%rax), %rax
decw 0xe(%rax)
leaq 0x333e(%rip), %rax      # 0x50c0
movq (%rax), %rax
decl 0x10(%rax)
xorl %eax, %eax
retq