LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/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 0x15ce(%rip), %rsi      # 0x311b
movq %r14, %rdi
callq 0x10e0
testq %rax, %rax
je 0x1bc2
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x1140
movq %r15, %rdi
callq 0x10b0
movq %rax, %r12
movq %r15, %rdi
callq 0x1110
xorl %edi, %edi
movq %r12, %rsi
movl $0x1, %edx
movl $0x1, %ecx
movl %eax, %r8d
xorl %r9d, %r9d
callq 0x1120
cmpq $-0x1, %rax
je 0x1bba
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 0x1bc4
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_O3/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
movl $0x28, %edi
callq 0x1130
testq %rax, %rax
je 0x1c04
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
callq 0x1b38
testq %rax, %rax
jne 0x1c06
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_O3/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 0x1ca2
movq %rdi, %r14
movq 0x18(%rdi), %r12
testq %r12, %r12
je 0x1ca2
movq %rsi, %rbx
xorl %r13d, %r13d
movq %r12, %rbp
subq %r13, %rbp
shrq %rbp
addq %r13, %rbp
cmpq %rbp, 0x18(%r14)
jbe 0x1ca2
movq 0x20(%r14), %rax
testq %rax, %rax
je 0x1ca2
movq 0x8(%rax,%rbp,8), %r15
bswapq %r15
addq %rax, %r15
movq %r15, %rdi
callq 0x1a57
movq %rax, %rdi
movq %rbx, %rsi
callq 0x10c0
testl %eax, %eax
je 0x1ca5
js 0x1c97
movq %rbp, %r12
jmp 0x1c9d
incq %rbp
movq %rbp, %r13
cmpq %r12, %r13
jb 0x1c53
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_O3/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 0x13ca(%rip), %rsi      # 0x311d
movq %rbx, %rdi
callq 0x10e0
testq %rax, %rax
je 0x1d7c
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
callq 0x1d98
movl %eax, %ebx
movq %r15, %rdi
callq 0x1050
movl %ebx, %eax
jmp 0x1d92
leaq 0x139c(%rip), %rdi      # 0x311f
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1090
movl $0x1, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq %rdi, %r14
callq 0x239e
movq %rax, %r15
bswapq %rax
leaq 0x8(%rsp), %rdi
movq %rax, (%rdi)
movl $0x8, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x1170
movq %r14, %rdi
callq 0x23a7
testq %rax, %rax
je 0x1e67
movq %rax, %r14
movq %rax, %rdi
callq 0x23cc
testq %rax, %rax
je 0x1e39
movq %rax, %r12
leaq 0x8(,%r15,8), %r13
movq %rsp, %r15
movq %r13, %rax
bswapq %rax
movq %rax, (%rsp)
movl $0x8, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x1170
movq %r12, %rdi
callq 0x1a3e
addq %rax, %r13
movq %r14, %rdi
callq 0x23e6
movq %rax, %r12
testq %rax, %rax
jne 0x1dff
movq %r14, %rdi
callq 0x23cc
testq %rax, %rax
je 0x1e5b
movq %rax, %rdi
movq %rbx, %rsi
callq 0x1ad5
movq %r14, %rdi
callq 0x23e6
jmp 0x1e41
movq %r14, %rdi
callq 0x23c7
xorl %eax, %eax
jmp 0x1e6c
movl $0x1, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
nop
// File: /workspace/github_c_makefile_star2_O3/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
movl $0x20, %r14d
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 0x1ed1
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 0x1ed3
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/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
movl $0x28, %edi
callq 0x1130
testq %rax, %rax
je 0x1f0e
movq %rax, %rbx
movzbl %bpl, %esi
movq %rax, %rdi
callq 0x1e7c
testq %rax, %rax
jne 0x1f10
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_O3/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), %rdi
movq (%rdi), %r14
testq %r14, %r14
je 0x1f61
movq (%r14), %rdi
movq 0x10(%r14), %r15
callq 0x1a24
movq %r14, %rdi
callq 0x1030
movq %r15, %r14
testq %r15, %r15
jne 0x1f41
movq 0x18(%rbx), %rdi
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movzbl 0x10(%rbx), %edx
shll $0x3, %edx
xorl %esi, %esi
popq %rbx
popq %r14
popq %r15
jmp 0x10a0
// File: /workspace/github_c_makefile_star2_O3/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 0x1fed
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x1a57
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x20a8
testq %rax, %rax
je 0x1ff0
movq %rax, %r12
movq (%rax), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x1a98
testl %eax, %eax
je 0x2095
movq %r14, (%r12)
movq (%rbx), %r12
movq %r15, %rdi
callq 0x1a3e
subq %rax, %r12
movq %r14, %rdi
callq 0x1a3e
addq %r12, %rax
movq %rax, (%rbx)
movq %r15, %rdi
callq 0x1a24
jmp 0x208e
xorl %eax, %eax
retq
movb $0x1, %bpl
cmpb $0x2, 0x10(%rbx)
jb 0x200e
callq 0x1190
cmpl $0x40000000, %eax       # imm = 0x40000000
jl 0x200e
incb %bpl
cmpb 0x10(%rbx), %bpl
jb 0x1ff9
movzbl %bpl, %r15d
leaq 0x10(,%r15,8), %rdi
callq 0x1130
testq %rax, %rax
je 0x2095
movb %bpl, 0x8(%rax)
movq %r14, (%rax)
shll $0x3, %r15d
xorl %ecx, %ecx
xorl %edx, %edx
movq 0x20(%rbx), %rsi
movq (%rsi,%rcx), %rsi
testq %rsi, %rsi
je 0x2049
addq %rcx, %rsi
addq $0x10, %rsi
jmp 0x2055
leaq (,%rdx,8), %rsi
addq 0x18(%rbx), %rsi
movq (%rsi), %rdi
movq %rdi, 0x10(%rax,%rcx)
movq %rax, (%rsi)
incq %rdx
addq $0x8, %rcx
cmpq %rcx, %r15
jne 0x2033
movq %r14, %rdi
callq 0x1a3e
movq %rax, %xmm0
shufpd $0x2, 0x10be(%rip), %xmm0 # xmm0 = xmm0[0],mem[1]
movdqu (%rbx), %xmm1
paddq %xmm1, %xmm0
movdqu %xmm0, (%rbx)
movl $0x1, %eax
jmp 0x209f
movq %r14, %rdi
callq 0x1a24
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x218d
movq %rdi, %r15
movzbl 0x10(%rdi), %r13d
testq %r13, %r13
je 0x2178
movq %rsi, %r14
movl $0x1, %eax
xorl %ebp, %ebp
movq %rbp, %r12
testq %rbp, %rbp
jne 0x20f8
movq 0x18(%r15), %rcx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
addl %r13d, %edx
movq (%rcx,%rdx,8), %r12
testq %r12, %r12
je 0x2145
movq (%r12), %rdi
callq 0x1a57
movq %rax, %rdi
movq %r14, %rsi
callq 0x10c0
testl %eax, %eax
jns 0x214a
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
leal (%rcx,%r13), %ebx
movq %r12, %rbp
movq 0x10(%r12,%rbx,8), %r12
testq %r12, %r12
je 0x2140
movq (%r12), %rdi
callq 0x1a57
movq %rax, %rdi
movq %r14, %rsi
callq 0x10c0
testl %eax, %eax
js 0x2119
jmp 0x214a
xorl %r12d, %r12d
jmp 0x214a
xorl %r12d, %r12d
xorl %ebp, %ebp
movl %eax, %ecx
orl 0x4(%rsp), %ecx
je 0x217b
movq 0x20(%r15), %rcx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
addl %r13d, %edx
movq %rbp, (%rcx,%rdx,8)
decq %r13
testb %r13b, %r13b
jne 0x20db
xorl %ecx, %ecx
testl %eax, %eax
cmovneq %rcx, %r12
jmp 0x217b
xorl %r12d, %r12d
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x11b0
// File: /workspace/github_c_makefile_star2_O3/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 0x21a9
xorl %edx, %edx
callq 0x20a8
testq %rax, %rax
je 0x21a9
movq (%rax), %rbx
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x2247
movq %rdi, %r14
movl $0x1, %ebx
movl $0x1, %edx
callq 0x20a8
testq %rax, %rax
je 0x2249
movq %rax, %r15
movzbl 0x10(%r14), %eax
testq %rax, %rax
je 0x2226
shll $0x3, %eax
xorl %ecx, %ecx
xorl %edx, %edx
movq 0x20(%r14), %rsi
movq (%rsi,%rcx), %rsi
testq %rsi, %rsi
je 0x2204
cmpq %r15, 0x10(%rsi,%rcx)
jne 0x221a
addq %rcx, %rsi
addq $0x10, %rsi
jmp 0x2212
movq 0x18(%r14), %rsi
cmpq %r15, (%rsi,%rcx)
jne 0x221a
leaq (%rsi,%rdx,8), %rsi
movq 0x10(%r15,%rcx), %rdi
movq %rdi, (%rsi)
incq %rdx
addq $0x8, %rcx
cmpq %rcx, %rax
jne 0x21e7
movq (%r15), %rdi
callq 0x1a3e
subq %rax, (%r14)
decq 0x8(%r14)
movq (%r15), %rdi
callq 0x1a24
movq %r15, %rdi
callq 0x1030
jmp 0x2249
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/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 0xedd(%rip), %r14       # 0x3150
movzbl %r15b, %ebp
decl %ebp
movq %r14, %rdi
movl %ebp, %esi
xorl %eax, %eax
callq 0x1090
movq 0x18(%rbx), %rax
movzbl %bpl, %r12d
movq (%rax,%r12,8), %r13
testq %r13, %r13
je 0x22b1
movb $0x12, %bpl
movq (%r13), %rdi
callq 0x1afb
decb %bpl
je 0x22b1
movq 0x10(%r13,%r12,8), %r13
testq %r13, %r13
jne 0x2299
decb %r15b
jmp 0x2273
// File: /workspace/github_c_makefile_star2_O3/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
movl $0x10, %edi
callq 0x1130
testq %rax, %rax
je 0x22d4
movq %rbx, (%rax)
movq $0x0, 0x8(%rax)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x230f
movq 0x10(%rax), %rax
movq %rax, 0x8(%rdi)
testq %rax, %rax
je 0x230f
movq (%rax), %rax
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x1361
movq %rsi, %r14
movq 0x8(%rsi), %rdi
movl $0x2, %ebx
movl $0x2, %esi
xorl %eax, %eax
callq 0x10f0
movl $0x20000, %esi          # imm = 0x20000
xorl %edi, %edi
movl $0x3, %edx
movl $0x1, %ecx
movl %eax, %r8d
xorl %r9d, %r9d
callq 0x1080
movq %rax, 0x3dee(%rip)      # 0x50b0
cmpq $-0x1, %rax
je 0x1366
callq 0x136c
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 0x21af
leaq -0x120(%rbp), %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x21c6
movq %r12, %rdi
callq 0x1611
testl %eax, %eax
js 0x1352
movq 0x3d89(%rip), %rcx      # 0x50b8
movl %eax, %eax
shlq $0x7, %rax
leaq (%rcx,%rax), %rdi
addq $-0x80, %rdi
leaq -0x120(%rbp), %rsi
callq 0x1b7a
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
callq 0x1140
callq 0x1165
nop
// File: /workspace/github_c_makefile_star2_O3/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 0x3cc8(%rip), %rax      # 0x50b8
movq (%rax), %rax
movslq %edi, %rcx
shlq $0x7, %rcx
leaq (%rax,%rcx), %rdi
addq $-0x80, %rdi
callq 0x148d
movq %rax, %r14
movl (%rax), %edx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl $-0x1, %edx
je 0x147e
leaq 0x3c93(%rip), %rcx      # 0x50b0
movq (%rcx), %rax
xorl %r12d, %r12d
movq %rax, (%rsp)
movslq %edx, %r13
shlq $0xa, %r13
addq %rax, %r13
xorl %r15d, %r15d
movl %r15d, %eax
leaq (%rax,%r13), %rbp
leaq (%rax,%r13), %rdi
addq $0x8, %rdi
movzbl -0x2(%rdi), %edx
movq %rbx, %rsi
callq 0x1050
testl %eax, %eax
je 0x147b
movzwl 0x4(%rbp), %eax
addl %eax, %r15d
cmpl $0x400, %r15d           # imm = 0x400
jb 0x1434
movl 0x4(%r14,%r12,4), %edx
incq %r12
cmpl $-0x1, %edx
movq (%rsp), %rax
jne 0x1427
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x147e
movl (%rbp), %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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
leal -0x1(%r14), %edx
cmpl $0xb, %edx
movl $0xb, %ecx
cmovbl %edx, %ecx
xorl %esi, %esi
movl 0x28(%rbx,%rsi,4), %edi
movl %edi, (%rax,%rsi,4)
cmpq %rsi, %rdx
je 0x150b
incq %rsi
cmpq $0xc, %rsi
jne 0x14b9
leaq 0x3bdb(%rip), %rsi      # 0x50b0
movl 0x58(%rbx), %edx
shll $0xa, %edx
addq (%rsi), %rdx
subl %ecx, %r14d
addl $-0x3, %r14d
xorl %ecx, %ecx
movl (%rdx,%rcx,4), %esi
movl %esi, 0x30(%rax,%rcx,4)
cmpl %ecx, %r14d
je 0x1515
incq %rcx
cmpq $0x100, %rcx            # imm = 0x100
jne 0x14e7
movq %rax, %rdi
callq 0x1030
xorl %eax, %eax
jmp 0x151d
movl $0xffffffff, 0x4(%rax,%rdx,4) # imm = 0xFFFFFFFF
jmp 0x151d
movl $0xffffffff, 0x34(%rax,%rcx,4) # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x3b76(%rip), %rax      # 0x50b8
movq (%rax), %r12
movslq %esi, %r13
shlq $0x7, %r13
movl $0x2f, %esi
callq 0x1090
movq %rax, %r14
cmpw $0x0, -0x80(%r12,%r13)
sets %al
testq %r14, %r14
setne %cl
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testb %cl, %al
jne 0x15fd
movq %r15, %rdi
callq 0x1070
testq %r14, %r14
je 0x15e0
testq %rax, %rax
je 0x159a
xorl %r12d, %r12d
cmpb $0x2f, (%r15,%r12)
je 0x159d
incq %r12
cmpq %r12, %rax
jne 0x158b
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 0x13db
cmpl $-0x1, %eax
je 0x15fd
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 0x1525
movq %rsp, %r14
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x10c0
movl %ebx, %edi
movq %r14, %rsi
callq 0x13db
movl %eax, %ebp
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_O3/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 %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl %edi, %r15d
leaq 0x3a5b(%rip), %r13      # 0x50b8
movq (%r13), %r12
callq 0x1753
movl %eax, %ebp
callq 0x17d8
movl $0x1c, %r14d
movl %ebp, %ecx
orl %eax, %ecx
js 0x1741
movslq %r15d, %rcx
movq (%r13), %rdx
movl %ebp, %esi
shlq $0x7, %rsi
leaq 0x3a1f(%rip), %rdi      # 0x50b0
movq (%rdi), %r8
movl %eax, %r9d
shll $0xa, %r9d
movabsq $0x40000004000, %rdi    # imm = 0x40000004000
movq %rdi, -0x80(%rdx,%rsi)
xorps %xmm0, %xmm0
movups %xmm0, -0x74(%rdx,%rsi)
movq $0x2, -0x64(%rdx,%rsi)
xorl %r14d, %r14d
movl %r14d, -0x5c(%rdx,%rsi)
movl %eax, -0x58(%rdx,%rsi)
movq $0x0, -0x1c(%rdx,%rsi)
movl %r14d, -0x14(%rdx,%rsi)
movb $0x0, -0xa(%rdx,%rsi)
movw $0x0, -0xc(%rdx,%rsi)
movl %ebp, (%r8,%r9)
movb $0x2e, 0x8(%r8,%r9)
movl $0x201000c, 0x4(%r8,%r9) # imm = 0x201000C
movq (%r13), %rax
incw -0x66(%rax,%rsi)
movl %ecx, 0xc(%r8,%r9)
shlq $0x7, %rcx
leaq (%r12,%rcx), %rdi
addq $-0x80, %rdi
movl $0x2e2e0202, 0x12(%r8,%r9) # imm = 0x2E2E0202
movw $0x3f4, 0x10(%r8,%r9)   # imm = 0x3F4
incw -0x66(%rax,%rcx)
movl %ebp, %esi
movq %rbx, %rdx
movl $0x2, %ecx
callq 0x1899
leaq 0x398e(%rip), %rax      # 0x50c8
movq (%rax), %rax
incw 0x10(%rax)
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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:
leaq 0x396e(%rip), %rax      # 0x50c8
movq (%rax), %rdx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpw $0x0, 0xe(%rdx)
je 0x17d5
leaq 0x3950(%rip), %rdx      # 0x50c0
movq (%rdx), %rsi
movl (%rsi), %esi
cmpq $0x8, %rsi
jb 0x17d5
shrl $0x3, %esi
leaq 0x3953(%rip), %rcx      # 0x50d8
movq (%rcx), %r8
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
xorl %r9d, %r9d
movzbl (%r8,%r9), %r10d
xorl %ecx, %ecx
movl $0x1, %r11d
shll %cl, %r11d
btl %ecx, %r10d
jae 0x17bf
incl %ecx
cmpl $0x8, %ecx
jne 0x1797
incq %r9
addl $-0x8, %edi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rsi, %r9
jne 0x1790
jmp 0x17d5
orl %r11d, %r10d
movb %r10b, (%r8,%r9)
movq (%rax), %rax
decw 0xe(%rax)
movq (%rdx), %rax
decl 0x10(%rax)
subl %edi, %ecx
movl %ecx, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/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 %rbx
leaq 0x38e8(%rip), %rdx      # 0x50c8
movq (%rdx), %rcx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpw $0x0, 0xc(%rcx)
je 0x1857
leaq 0x38ca(%rip), %rsi      # 0x50c0
movq (%rsi), %rcx
movl 0x4(%rcx), %edi
cmpq $0x8, %rdi
jb 0x1857
shrl $0x3, %edi
leaq 0x38c4(%rip), %rcx      # 0x50d0
movq (%rcx), %r9
xorl %r8d, %r8d
xorl %r10d, %r10d
movzbl (%r9,%r10), %r11d
xorl %ecx, %ecx
movl $0x1, %ebx
shll %cl, %ebx
btl %ecx, %r11d
jae 0x183e
incl %ecx
cmpl $0x8, %ecx
jne 0x181c
incq %r10
addl $-0x8, %r8d
cmpq %rdi, %r10
jne 0x1815
jmp 0x1857
orl %ebx, %r11d
movb %r11b, (%r9,%r10)
movq (%rdx), %rax
decw 0xc(%rax)
movq (%rsi), %rax
decl 0xc(%rax)
subl %r8d, %ecx
movl %ecx, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/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
pushq %rax
movq %rsi, (%rsp)
callq 0x148d
movq %rax, %rbx
cmpl $-0x1, -0x4(%rax)
je 0x1aad
leaq 0x3677(%rip), %rax      # 0x50b0
movq (%rax), %r15
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl $0x400, %r12d           # imm = 0x400
cmpl $0x400, %r12d           # imm = 0x400
jne 0x1a69
movslq %ebp, %rax
incl %ebp
movslq 0x4(%rbx,%rax,4), %r13
shlq $0xa, %r13
addq %r15, %r13
xorl %r12d, %r12d
movq %r13, %r14
jmp 0x1a6f
movq %r14, %r13
movq %rax, %r14
leaq 0x8(%r14), %rsi
movzbl 0x6(%r14), %edx
movq (%rsp), %rdi
callq 0x1050
movzwl 0x4(%r14), %ecx
testl %eax, %eax
je 0x1ab4
movslq %r12d, %r12
addq %rcx, %r12
movslq %ebp, %rax
movslq (%rbx,%rax,4), %rcx
movq %rcx, %rdx
shlq $0xa, %rdx
movq %r12, %rax
addq %r15, %rax
addq %rdx, %rax
cmpq $-0x1, %rcx
jne 0x1a47
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x1adb
addw %cx, 0x4(%r13)
leaq 0x35f8(%rip), %rax      # 0x50b8
movq (%rax), %rax
movl (%r14), %edi
movq %rdi, %rcx
shlq $0x7, %rcx
xorl %ebp, %ebp
decw -0x66(%rax,%rcx)
jne 0x1adb
callq 0x1af4
movq %rbx, %rdi
callq 0x1030
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_O3/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 0x35b2(%rip), %rax      # 0x50b8
movq (%rax), %r12
movslq %edi, %r13
shlq $0x7, %r13
leaq (%r12,%r13), %r15
addq $-0x80, %r15
movq %r15, %rdi
callq 0x148d
movq %rax, %r14
xorl %edi, %edi
callq 0x10d0
movl %eax, 0x14(%r15)
movl (%r14), %edi
cmpl $-0x1, %edi
je 0x1b62
addq %r13, %r12
movq $-0x1, %r15
callq 0x1f8c
movl 0x8(%r14,%r15,4), %edi
incq %r15
cmpl $-0x1, %edi
jne 0x1b40
cmpq $0xb, %r15
jb 0x1b62
movl -0x28(%r12), %edi
callq 0x1f8c
movl %ebx, %edi
callq 0x1f2e
movq %r14, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x1030
// File: /workspace/github_c_makefile_star2_O3/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:
leal 0x7(%rdi), %eax
testl %edi, %edi
cmovnsl %edi, %eax
movl %eax, %edx
sarl $0x3, %edx
andl $-0x8, %eax
subl %eax, %edi
movl %edi, %ecx
subl $0x1, %ecx
sbbl $0x0, %edx
movl $0x1, %eax
shll %cl, %eax
cmpl $0x1, %edi
leaq 0x32ef(%rip), %rcx      # 0x50d8
movq (%rcx), %rcx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %edi
movl $0x80, %esi
cmovael %eax, %esi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %edi, %esi
je 0x1e05
retq
orb %dil, %sil
movb %sil, (%rcx,%rdx)
leaq 0x32b5(%rip), %rax      # 0x50c8
movq (%rax), %rax
decw 0xe(%rax)
leaq 0x329f(%rip), %rax      # 0x50c0
movq (%rax), %rax
decl 0x10(%rax)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/Carben-dev[P]ext2fs-simple-utilities/ext2_utils.c
// Function: restore_block_bitmap
int restore_block_bitmap(int block_num) {
    block_num++;
    
    unsigned char *ptr;
    int in_which_byte;
    int off;
    
    in_which_byte = block_num/8;
    if (block_num%8) {
        in_which_byte++;
        off = block_num%8;
    } else {
        off = 8;
    }
    
    
    ptr = block_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_blocks_count--;
    sb->s_free_blocks_count--;
    
    return 0;
    
}

// Assembly:
leal 0x1(%rdi), %eax
leal 0x8(%rdi), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
movl %ecx, %eax
sarl $0x3, %eax
andl $-0x8, %ecx
negl %ecx
leal (%rdi,%rcx), %edx
incl %edx
movl %edx, %ecx
subl $0x1, %ecx
sbbl $0x0, %eax
movl $0x1, %r8d
shll %cl, %r8d
cmpl $0x1, %edx
leaq 0x3271(%rip), %rcx      # 0x50d0
movq (%rcx), %rcx
movslq %eax, %rdx
movzbl (%rcx,%rdx), %edi
movl $0x80, %esi
cmovael %r8d, %esi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %edi, %esi
je 0x1e7c
retq
orb %dil, %sil
movb %sil, (%rcx,%rdx)
leaq 0x323e(%rip), %rax      # 0x50c8
movq (%rax), %rax
decw 0xc(%rax)
leaq 0x3228(%rip), %rax      # 0x50c0
movq (%rax), %rax
decl 0xc(%rax)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/Carben-dev[P]ext2fs-simple-utilities/ext2_utils.c
// Function: write_array_into_i_block
void write_array_into_i_block(struct ext2_inode *inode,
                              int *array,
                              int array_size)
{
    int num_block_written = 0;
    int i;
    
    for (i = 0; i < 12; i++) {
        inode->i_block[i] = array[i];
        num_block_written++;
        if (num_block_written == array_size) {
            return;
        }
    }
    
    // If reach here, write into indirect_block
    // allocate a space for indirect_block
    int indirect_block_num = dalloc();
    if (indirect_block_num < 0) {
        exit(ENOSPC);
    }
    inode->i_block[12] = indirect_block_num;
    inode->i_blocks += 2;
    
    // 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++) {
        indirect_block[i] = array[12 + i];
        num_block_written++;
        if (num_block_written == array_size) {
            return;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
leal -0x1(%rbx), %eax
cmpl $0xb, %eax
movl $0xb, %ebp
cmovbl %eax, %ebp
xorl %ecx, %ecx
movl (%r14,%rcx,4), %edx
movl %edx, 0x28(%r15,%rcx,4)
cmpq %rcx, %rax
je 0x1f19
incq %rcx
cmpq $0xc, %rcx
jne 0x1ec0
callq 0x17d8
testl %eax, %eax
js 0x1f24
movl %eax, 0x58(%r15)
addl $0x2, 0x1c(%r15)
leaq 0x31c0(%rip), %rcx      # 0x50b0
shll $0xa, %eax
addq (%rcx), %rax
subl %ebp, %ebx
addl $-0x2, %ebx
xorl %ecx, %ecx
movl 0x30(%r14,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
cmpl %ecx, %ebx
je 0x1f19
leaq 0x1(%rcx), %rdx
cmpq $0xff, %rcx
movq %rdx, %rcx
jne 0x1efd
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl $0x1c, %edi
callq 0x1110
// File: /workspace/github_c_makefile_star2_O3/Carben-dev[P]ext2fs-simple-utilities/ext2_utils.c
// Function: ifree
void ifree(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);
    *ptr = *ptr & ~(1<<(off - 1));
    
    //update superblock and gdt
    gdt->bg_free_inodes_count++;
    sb->s_free_inodes_count++;
}

// Assembly:
leal 0x7(%rdi), %eax
testl %edi, %edi
cmovnsl %edi, %eax
movl %eax, %edx
sarl $0x3, %edx
andl $-0x8, %eax
subl %eax, %edi
movl %edi, %ecx
subl $0x1, %ecx
sbbl $0x0, %edx
movl $0x1, %eax
shll %cl, %eax
cmpl $0x1, %edi
leaq 0x317f(%rip), %rcx      # 0x50d8
movq (%rcx), %rcx
notb %al
movzbl %al, %eax
movl $0x7f, %esi
cmovael %eax, %esi
movslq %edx, %rax
andb %sil, (%rcx,%rax)
leaq 0x3151(%rip), %rax      # 0x50c8
movq (%rax), %rax
incw 0xe(%rax)
leaq 0x313b(%rip), %rax      # 0x50c0
movq (%rax), %rax
incl 0x10(%rax)
retq
// File: /workspace/github_c_makefile_star2_O3/Carben-dev[P]ext2fs-simple-utilities/ext2_utils.c
// Function: dfree
void dfree(int block_num) {
    block_num++;
    
    unsigned char *ptr;
    int in_which_byte;
    int off;
    
    in_which_byte = block_num/8;
    if (block_num%8) {
        in_which_byte++;
        off = block_num%8;
    } else {
        off = 8;
    }
    
    
    ptr = block_bitmap + in_which_byte - 1;
    *ptr = *ptr & ~(1<<(off - 1));
    
    //update superblock and gdt
    gdt->bg_free_blocks_count++;
    sb->s_free_blocks_count++;
}

// Assembly:
leal 0x1(%rdi), %eax
leal 0x8(%rdi), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
movl %ecx, %eax
sarl $0x3, %eax
andl $-0x8, %ecx
negl %ecx
leal (%rdi,%rcx), %edx
incl %edx
movl %edx, %ecx
addl $-0x1, %ecx
adcl $0x0, %eax
movl $0x1, %esi
shll %cl, %esi
addl $-0x1, %edx
leaq 0x3111(%rip), %rcx      # 0x50d0
movq (%rcx), %rcx
notb %sil
movzbl %sil, %edx
movl $0x7f, %esi
cmovbl %edx, %esi
cltq
andb %sil, -0x1(%rcx,%rax)
leaq 0x30e9(%rip), %rax      # 0x50c8
movq (%rax), %rax
incw 0xc(%rax)
leaq 0x30d3(%rip), %rax      # 0x50c0
movq (%rax), %rax
incl 0xc(%rax)
retq
// File: /workspace/github_c_makefile_star2_O3/Carben-dev[P]ext2fs-simple-utilities/ext2_utils.c
// Function: count_inode_bitmap
int count_inode_bitmap() {
    unsigned char *inode_bitmap_ptr;
    int curr_byte = 0;
    int vaild_byte_count = sb->s_inodes_count/8;
    int result = 0;
    int i;
    
    while (curr_byte < vaild_byte_count) {
        inode_bitmap_ptr = inode_bitmap + curr_byte;
        for (i = 0; i < 8; i++) {
            if (!(*inode_bitmap_ptr>>i & 1)) {
                result++;
            }
            
        }
        curr_byte++;
    }
    
    return result;
}

// Assembly:
leaq 0x30c5(%rip), %rax      # 0x50c0
movq (%rax), %rax
movl (%rax), %ecx
xorl %eax, %eax
cmpq $0x8, %rcx
jb 0x20d0
shrl $0x3, %ecx
leaq 0x30c2(%rip), %rax      # 0x50d8
movq (%rax), %rdx
xorl %esi, %esi
movdqa 0x101d(%rip), %xmm0     # 0x3040
movaps 0x1026(%rip), %xmm1     # 0x3050
movdqa 0x102e(%rip), %xmm2     # 0x3060
xorl %eax, %eax
movzbl (%rdx,%rsi), %edi
notl %edi
movd %eax, %xmm3
movd %edi, %xmm4
pshufd $0x0, %xmm4, %xmm4      # xmm4 = xmm4[0,0,0,0]
movl $0x8, %eax
movdqa %xmm0, %xmm5
pshuflw $0xfe, %xmm5, %xmm6     # xmm6 = xmm5[2,3,3,3,4,5,6,7]
movdqa %xmm4, %xmm7
psrld %xmm6, %xmm7
pshuflw $0x54, %xmm5, %xmm6     # xmm6 = xmm5[0,1,1,1,4,5,6,7]
movdqa %xmm4, %xmm8
psrld %xmm6, %xmm8
punpcklqdq %xmm7, %xmm8    # xmm8 = xmm8[0],xmm7[0]
pshufd $0xee, %xmm5, %xmm6     # xmm6 = xmm5[2,3,2,3]
pshuflw $0xfe, %xmm6, %xmm7     # xmm7 = xmm6[2,3,3,3,4,5,6,7]
movdqa %xmm4, %xmm9
psrld %xmm7, %xmm9
pshuflw $0x54, %xmm6, %xmm6     # xmm6 = xmm6[0,1,1,1,4,5,6,7]
movdqa %xmm4, %xmm7
psrld %xmm6, %xmm7
punpckhqdq %xmm9, %xmm7    # xmm7 = xmm7[1],xmm9[1]
shufps $0xcc, %xmm7, %xmm8     # xmm8 = xmm8[0,3],xmm7[0,3]
andps %xmm1, %xmm8
paddd %xmm8, %xmm3
paddd %xmm2, %xmm5
addl $-0x4, %eax
jne 0x2050
pshufd $0xee, %xmm3, %xmm4     # xmm4 = xmm3[2,3,2,3]
paddd %xmm3, %xmm4
pshufd $0x55, %xmm4, %xmm3     # xmm3 = xmm4[1,1,1,1]
paddd %xmm4, %xmm3
movd %xmm3, %eax
incq %rsi
cmpq %rcx, %rsi
jne 0x2034
retq