LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/dict.c
// Function: dict_set
bool dict_set(struct list *list, const char *key, void *value)
{
	struct dict_item *item, needle;

	size_t index;
	bool found;

	needle.key = key;

	found = list_find_item_or_insertpoint(list, compare_key, &needle, &index);
	if(found) {
		item = list_get_item(list, index);
	} else {
		item = malloc(sizeof(*item));
		if(item == NULL)
			return false;

		item->key = strdup(key);
		if(item->key == NULL) {
			free(item);
			return false;
		}
		if(!list_insert(list, index, item)) {
			free((void*)item->key);
			free(item);
			return false;
		}
	}
	item->value = value;

	return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r15
leaq 0x8(%rsp), %rdx
movq %rsi, (%rdx)
leaq 0x74(%rip), %rsi        # 0x5e76
movq %rsp, %rcx
callq 0x774e
testb %al, %al
je 0x5e25
movq (%rsp), %rsi
movq %r15, %rdi
callq 0x76e4
movq %rax, %r14
movq %rbx, 0x8(%r14)
movb $0x1, %al
jmp 0x5e6a
pushq $0x10
popq %rdi
callq 0x3490
testq %rax, %rax
je 0x5e68
movq %rax, %r14
movq %r12, %rdi
callq 0x36a0
movq %rax, (%r14)
testq %rax, %rax
je 0x5e60
movq (%rsp), %rsi
movq %r15, %rdi
movq %r14, %rdx
callq 0x7581
testb %al, %al
jne 0x5e1d
movq (%r14), %rdi
callq 0x3740
movq %r14, %rdi
callq 0x3740
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/dict.c
// Function: dict_get
void *dict_get(struct list *list, const char *key)
{
	struct dict_item item;
	size_t index;
	bool found;

	item.key = key;

	found = list_find_item_or_insertpoint(list, compare_key, &item, &index);
	if(found) {
		struct dict_item *item = list_get_item(list, index);
		return item->value;
	}
	return NULL;
}

// Assembly:
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
leaq 0x10(%rsp), %rdx
movq %rsi, (%rdx)
leaq -0x28(%rip), %rsi       # 0x5e76
leaq 0x8(%rsp), %rcx
callq 0x774e
testb %al, %al
je 0x5ebf
movq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x76e4
movq 0x8(%rax), %rax
jmp 0x5ec1
xorl %eax, %eax
addq $0x20, %rsp
popq %rbx
retq
nop
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/dirmodel.c
// Function: dirmodel_getmarkedfilenames
int dirmodel_getmarkedfilenames(struct dirmodel *model, const struct list **markedlist_out)
{
	struct list *list = model->sortedlist;
	struct list *markedlist = list_new(0);

	if(markedlist == NULL)
		return ENOMEM;

	size_t length = list_length(list);

	for(size_t i = 0; i < length; i++)
	{
		struct filedata *filedata = list_get_item(list, i);
		if(filedata->is_marked) {
			char *filename = strdup(filedata->filename);
			if(filename == NULL) {
				list_delete(markedlist, free);
				return ENOMEM;
			}
			if(!list_append(markedlist, filename)) {
				free(filename);
				list_delete(markedlist, free);
				return ENOMEM;
			}
		}
	}
	if(list_length(markedlist) == 0) {
		list_delete(markedlist, NULL);
		return ENOENT;
	}

	*markedlist_out = markedlist;
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq 0x30(%rdi), %r12
xorl %edi, %edi
callq 0x7480
pushq $0xc
popq %rbx
testq %rax, %rax
je 0x5f8c
movq %rax, %r14
movq %r15, (%rsp)
movq %r12, %rdi
callq 0x7515
movq %rax, %r13
xorl %ebp, %ebp
cmpq %rbp, %r13
je 0x5f4e
movq %r12, %rdi
movq %rbp, %rsi
callq 0x76e4
cmpb $0x1, 0xa8(%rax)
jne 0x5f49
movq (%rax), %rdi
callq 0x36a0
testq %rax, %rax
je 0x5f6e
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
callq 0x7519
testb %al, %al
je 0x5f66
incq %rbp
jmp 0x5f11
movq %r14, %rdi
callq 0x7515
testq %rax, %rax
je 0x5f7f
movq (%rsp), %rax
movq %r14, (%rax)
xorl %ebx, %ebx
jmp 0x5f8c
movq %r15, %rdi
callq 0x3740
movq 0x703b(%rip), %rsi      # 0xcfb0
movq %r14, %rdi
callq 0x74d1
jmp 0x5f8c
movq %r14, %rdi
xorl %esi, %esi
callq 0x74d1
pushq $0x2
popq %rbx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/dirmodel.c
// Function: dirmodel_get_internal_index
bool dirmodel_get_internal_index(struct dirmodel *model, const char *filename, size_t *internal_index, size_t *index)
{
	struct filedata filedata;

	filedata.filename = filename;

	if(!list_find_item_or_insertpoint(model->list, filedata_listcompare_filename, &filedata, internal_index))
		return false;

	struct filedata *internal_filedata = list_get_item(model->list, *internal_index);
	if(!list_find_item_or_insertpoint(model->sortedlist, model->sort_compare, internal_filedata, index))
		return false;
	return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0xb0, %rsp
movq %rcx, %rbx
movq %rdx, %r15
movq %rdi, %r14
movq %rsp, %rdx
movq %rsi, (%rdx)
movq 0x28(%rdi), %rdi
leaq 0xd1e(%rip), %rsi       # 0x6cf0
movq %r15, %rcx
callq 0x774e
testb %al, %al
je 0x6002
movq 0x28(%r14), %rdi
movq (%r15), %rsi
callq 0x76e4
movq 0x30(%r14), %rdi
movq 0x90(%r14), %rsi
movq %rax, %rdx
movq %rbx, %rcx
callq 0x774e
jmp 0x6004
xorl %eax, %eax
addq $0xb0, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/dirmodel.c
// Function: dirmodel_regex_getnext
size_t dirmodel_regex_getnext(struct dirmodel *model, const char *regex, size_t start_index, int direction)
{
	struct list *list = model->sortedlist;
	regex_t cregex;
	size_t result = start_index;

	int ret = regcomp(&cregex, regex, REG_EXTENDED | REG_ICASE | REG_NOSUB);
	if(ret != 0)
		return start_index;

	if(direction > 0 && start_index < SIZE_MAX) {
		size_t length = list_length(list);
		for(size_t i = start_index + 1; i < length; i++) {
			struct filedata *filedata = list_get_item(list, i);
			if(regexec(&cregex, filedata->filename, 0, NULL, 0) == 0) {
				result = i;
				break;
			}
		}
	} else if(direction < 0 && start_index > 0) {
		for(size_t i = start_index - 1; i > 0; i--) {
			struct filedata *filedata = list_get_item(list, i);
			if(regexec(&cregex, filedata->filename, 0, NULL, 0) == 0) {
				result = i;
				break;
			}
		}
	}

	regfree(&cregex);
	return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %ecx, %ebp
movq %rdx, %rbx
movq 0x30(%rdi), %r14
leaq 0x8(%rsp), %rdi
pushq $0xb
popq %rdx
callq 0x3370
testl %eax, %eax
jne 0x60f0
testl %ebp, %ebp
setle %al
cmpq $-0x1, %rbx
sete %cl
orb %al, %cl
jne 0x6099
movq %r14, %rdi
callq 0x7515
movq %rax, %r12
leaq 0x8(%rsp), %r13
movq %rbx, %r15
incq %r15
cmpq %r12, %r15
jae 0x60e0
movq %r14, %rdi
movq %r15, %rsi
callq 0x76e4
movq (%rax), %rsi
movq %r13, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x34d0
testl %eax, %eax
jne 0x606e
jmp 0x60e3
testl %ebp, %ebp
setns %al
testq %rbx, %rbx
sete %cl
orb %al, %cl
jne 0x60e0
leaq -0x1(%rbx), %rsi
leaq 0x8(%rsp), %r12
movq %rsi, %r15
subq $0x1, %r15
jb 0x60e0
movq %r14, %rdi
callq 0x76e4
movq (%rax), %rsi
movq %r12, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x34d0
movq %r15, %rsi
testl %eax, %eax
jne 0x60b4
incq %r15
jmp 0x60e3
movq %rbx, %r15
leaq 0x8(%rsp), %rdi
callq 0x3220
movq %r15, %rbx
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/dirmodel.c
// Function: dirmodel_regex_setmark
void dirmodel_regex_setmark(struct dirmodel *model, const char *regex, bool mark)
{
	struct list *list = model->sortedlist;
	regex_t cregex;

	int ret = regcomp(&cregex, regex, REG_EXTENDED | REG_ICASE | REG_NOSUB);
	if(ret != 0)
		return;

	size_t length = list_length(list);

	for(size_t i = 0; i < length; i++) {
		struct filedata *filedata = list_get_item(list, i);
		if(regexec(&cregex, filedata->filename, 0, NULL, 0) == 0 &&
		   filedata->is_marked != mark) {
			if(mark) {
				dirmodel_update_marked_stats(model, NULL, filedata);
			} else {
				dirmodel_update_marked_stats(model, filedata, NULL);
			}
			filedata->is_marked = mark;
			listmodel_notify_change(&model->listmodel, MODEL_CHANGE, i, i);
		}
	}

	regfree(&cregex);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edx, %ebx
movq %rdi, %r14
movq 0x30(%rdi), %r15
leaq 0x8(%rsp), %rdi
pushq $0xb
popq %rdx
callq 0x3370
testl %eax, %eax
jne 0x61e1
movq %r15, %rdi
callq 0x7515
movq %rax, %r12
movzbl %bl, %eax
decq %rax
orq $0x1, %rax
movq %rax, (%rsp)
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x61d7
movq %r15, %rdi
movq %r13, %rsi
callq 0x76e4
movq %rax, %rbp
movq (%rax), %rsi
leaq 0x8(%rsp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x34d0
testl %eax, %eax
jne 0x61cf
cmpb %bl, 0xa8(%rbp)
je 0x61cf
leaq 0x40(%rbp), %rax
movq %rbp, %rcx
addq $0xa0, %rcx
cmpb $0x0, 0x8(%rbp)
cmoveq %rax, %rcx
movq (%rcx), %rax
movq %rax, %rcx
negq %rcx
testb %bl, %bl
cmovneq %rax, %rcx
addq %rcx, 0xa8(%r14)
movq (%rsp), %rax
addq %rax, 0xa0(%r14)
movb %bl, 0xa8(%rbp)
movq %r14, %rdi
pushq $0x2
popq %rsi
movq %r13, %rdx
movq %r13, %rcx
callq 0x7901
incq %r13
jmp 0x614a
leaq 0x8(%rsp), %rdi
callq 0x3220
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/dirmodel.c
// Function: dirmodel_update_marked_stats
static void dirmodel_update_marked_stats(struct dirmodel *model, struct filedata *oldfiledata, struct filedata *newfiledata)
{
	if(oldfiledata) {
		if(oldfiledata->is_link) {
			model->marked_stats.size -= oldfiledata->link_size;
		} else {
			model->marked_stats.size -= oldfiledata->stat.st_size;
		}
		model->marked_stats.count--;
	}
	if(newfiledata) {
		if(newfiledata->is_link) {
			model->marked_stats.size += newfiledata->link_size;
		} else {
			model->marked_stats.size += newfiledata->stat.st_size;
		}
		model->marked_stats.count++;
	}
}

// Assembly:
testq %rsi, %rsi
je 0x6219
leaq 0x40(%rsi), %rax
leaq 0xa0(%rsi), %rcx
cmpb $0x0, 0x8(%rsi)
cmovneq %rcx, %rax
movq (%rax), %rax
subq %rax, 0xa8(%rdi)
decq 0xa0(%rdi)
testq %rdx, %rdx
je 0x6255
leaq 0x40(%rdx), %rax
leaq 0xa0(%rdx), %rcx
cmpb $0x0, 0x8(%rdx)
cmovneq %rcx, %rax
movdqu 0xa0(%rdi), %xmm0
movq (%rax), %xmm1
movdqa 0x2feb(%rip), %xmm2     # 0x9230
punpcklqdq %xmm1, %xmm2    # xmm2 = xmm2[0],xmm1[0]
paddq %xmm0, %xmm2
movdqu %xmm2, 0xa0(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/dirmodel.c
// Function: dirmodel_setfilter
bool dirmodel_setfilter(struct dirmodel *model, const char *regex)
{
	if(model->filter_active)
		regfree(&model->filter);

	if(regex == NULL) {
		model->filter_active = false;
	} else {
		int ret = regcomp(&model->filter, regex, REG_EXTENDED | REG_ICASE | REG_NOSUB);
		model->filter_active = (ret == 0);
	}

	return model->filter_active;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
cmpb $0x1, 0x88(%rdi)
jne 0x6272
leaq 0x48(%rbx), %rdi
callq 0x3220
testq %r14, %r14
je 0x628d
leaq 0x48(%rbx), %rdi
pushq $0xb
popq %rdx
movq %r14, %rsi
callq 0x3370
testl %eax, %eax
sete %al
jmp 0x628f
xorl %eax, %eax
movb %al, 0x88(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/dirmodel.c
// Function: dirmodel_notify_file_deleted
void dirmodel_notify_file_deleted(struct dirmodel *model, const char *filename)
{
	struct list *list = model->list;
	size_t index, internal_index;

	bool found = dirmodel_get_internal_index(model, filename, &internal_index, &index);
	if(found) {
		struct filedata *filedata = list_get_item(list, internal_index);
		if(filedata->is_marked) {
			dirmodel_update_marked_stats(model, filedata, NULL);
		}
		dirmodel_update_dirsize(model, filedata, NULL);
		filedata_delete(filedata);
		list_remove(list, internal_index);
		list_remove(model->sortedlist, index);
		listmodel_notify_change(&model->listmodel, MODEL_REMOVE, 0, index);
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movq 0x28(%rdi), %r14
movq %rsp, %rdx
leaq 0x8(%rsp), %rcx
callq 0x5fac
testb %al, %al
je 0x634d
movq (%rsp), %rsi
movq %r14, %rdi
callq 0x76e4
movq %rax, %r15
cmpb $0x1, 0xa8(%rax)
jne 0x62f8
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x61f0
leaq 0x40(%r15), %rax
movq %r15, %rcx
addq $0xa0, %rcx
cmpb $0x0, 0x8(%r15)
cmoveq %rax, %rcx
movq (%rcx), %rax
subq %rax, 0xb0(%rbx)
movq %r15, %rdi
callq 0x7463
movq (%rsp), %rsi
movq %r14, %rdi
callq 0x7694
movq 0x30(%rbx), %rdi
movq 0x8(%rsp), %rsi
callq 0x7694
movq 0x8(%rsp), %rcx
pushq $0x1
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x7901
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/dirmodel.c
// Function: dirmodel_notify_file_added_or_changed
int dirmodel_notify_file_added_or_changed(struct dirmodel *model, const char *filename)
{
	size_t index;
	bool found = list_find_item_or_insertpoint(model->addchange_queue, listcompare_strcmp, filename, &index);
	if(!found) {
		char *filename_copy = strdup(filename);
		if(filename_copy == NULL)
			return ENOMEM;
		if(!list_insert(model->addchange_queue, index, filename_copy)) {
			free(filename_copy);
			return ENOMEM;
		}
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %r14
movq 0x38(%rdi), %rdi
leaq 0x4f(%rip), %rsi        # 0x6403
movq %rsp, %rcx
movq %r15, %rdx
callq 0x774e
xorl %ebx, %ebx
testb %al, %al
jne 0x63f6
movq %r15, %rdi
callq 0x36a0
pushq $0xc
popq %rbp
testq %rax, %rax
je 0x63f4
movq %rax, %r15
movq 0x38(%r14), %rdi
movq (%rsp), %rsi
movq %rax, %rdx
callq 0x7581
testb %al, %al
jne 0x63f6
movq %r15, %rdi
callq 0x3740
movl %ebp, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/dirmodel.c
// Function: dirmodel_change_directory
bool dirmodel_change_directory(struct dirmodel *model, const char *path)
{
	internal_destroy(model);
	if(!internal_init(model, path))
		return false;
	listmodel_notify_change(&model->listmodel, MODEL_RELOAD, 0, 0);
	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
callq 0x68c0
movq %r14, %rdi
callq 0x3200
testq %rax, %rax
je 0x68af
movq %rax, %r14
xorl %edi, %edi
callq 0x7480
movq %rax, 0x38(%rbx)
testq %rax, %rax
je 0x68a7
xorl %edi, %edi
callq 0x7480
testq %rax, %rax
je 0x689c
movq %rax, %r15
xorl %edi, %edi
callq 0x7480
testq %rax, %rax
je 0x688d
movq %rax, %r12
andq $0x0, 0xb0(%rbx)
movq %r14, %rdi
callq 0x3470
movq %rax, %rbp
leaq 0x48(%rbx), %r13
testq %rbp, %rbp
je 0x6833
cmpb $0x2e, 0x13(%rbp)
jne 0x6793
movzbl 0x14(%rbp), %eax
testl %eax, %eax
je 0x6823
cmpl $0x2e, %eax
jne 0x6793
cmpb $0x0, 0x15(%rbp)
je 0x6823
addq $0x13, %rbp
cmpb $0x1, 0x88(%rbx)
jne 0x67b6
movq %r13, %rdi
movq %rbp, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x34d0
testl %eax, %eax
jne 0x6823
movq %r14, %rdi
callq 0x33f0
movq %rsp, %rdi
movl %eax, %esi
movq %rbp, %rdx
callq 0x7312
testl %eax, %eax
je 0x67d9
cmpl $0xc, %eax
jne 0x6823
jmp 0x687a
movq (%rsp), %rsi
movq %r12, %rdi
callq 0x7519
testb %al, %al
je 0x687a
movq (%rsp), %rsi
movq %r15, %rdi
callq 0x7519
testb %al, %al
je 0x687a
movq (%rsp), %rax
testq %rax, %rax
je 0x6823
leaq 0x40(%rax), %rcx
leaq 0xa0(%rax), %rdx
cmpb $0x0, 0x8(%rax)
cmovneq %rdx, %rcx
movq (%rcx), %rax
addq %rax, 0xb0(%rbx)
movq %r14, %rdi
callq 0x3470
movq %rax, %rbp
jmp 0x6769
movq %r14, 0x40(%rbx)
movq %r15, 0x28(%rbx)
movq %r12, 0x30(%rbx)
leaq 0x4aa(%rip), %rsi       # 0x6cf0
movq %r15, %rdi
callq 0x773c
movq 0x90(%rbx), %rsi
movq %r12, %rdi
callq 0x773c
xorps %xmm0, %xmm0
movups %xmm0, 0xa0(%rbx)
pushq $0x3
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x7901
movb $0x1, %al
jmp 0x68b1
movq (%rsp), %rdi
callq 0x7463
movq %r12, %rdi
xorl %esi, %esi
callq 0x74d1
leaq 0xbcf(%rip), %rsi       # 0x7463
movq %r15, %rdi
callq 0x74d1
movq 0x38(%rbx), %rdi
xorl %esi, %esi
callq 0x74d1
movq %r14, %rdi
callq 0x3350
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/dirmodel.c
// Function: internal_destroy
static void internal_destroy(struct dirmodel *model)
{
	struct list *list = model->list;
	if(list == NULL)
		return;

	closedir(model->dir);

	list_delete(list, (list_item_deallocator)filedata_delete);
	list_delete(model->sortedlist, NULL);
	list_delete(model->addchange_queue, free);
	model->list = NULL;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq 0x28(%rdi), %r14
testq %r14, %r14
je 0x6908
movq %rdi, %rbx
movq 0x40(%rdi), %rdi
callq 0x3350
leaq 0xb83(%rip), %rsi       # 0x7463
movq %r14, %rdi
callq 0x74d1
movq 0x30(%rbx), %rdi
xorl %esi, %esi
callq 0x74d1
movq 0x38(%rbx), %rdi
movq 0x66b2(%rip), %rsi      # 0xcfb0
callq 0x74d1
andq $0x0, 0x28(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/dirmodel.c
// Function: dirmodel_init
void dirmodel_init(struct dirmodel *model)
{
	listmodel_init(&model->listmodel);

	model->list = NULL;
	model->sortedlist = NULL;
	model->listmodel.count = dirmodel_count;
	model->listmodel.render = dirmodel_render;
	model->listmodel.setmark = dirmodel_setmark;
	model->listmodel.ismarked = dirmodel_ismarked;
	model->filter_active = false;
	model->sort_compare = filedata_listcompare_directory_filename;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x795d
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rbx)
leaq -0xa5f(%rip), %rax      # 0x5ec8
movq %rax, (%rbx)
leaq 0x31(%rip), %rax        # 0x6962
movq %rax, 0x8(%rbx)
leaq 0x56(%rip), %rax        # 0x6992
movq %rax, 0x10(%rbx)
leaq 0xb5(%rip), %rax        # 0x69fc
movq %rax, 0x18(%rbx)
movb $0x0, 0x88(%rbx)
leaq 0x3a8(%rip), %rax       # 0x6d01
movq %rax, 0x90(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/dirmodel.c
// Function: dirmodel_setmark
static void dirmodel_setmark(struct listmodel *listmodel, size_t index, bool mark)
{
	struct dirmodel *model = container_of(listmodel, struct dirmodel, listmodel);;
	struct list *list = model->sortedlist;
	struct filedata *filedata = list_get_item(list, index);

	if(filedata->is_marked == mark)
		return;

	if(mark) {
		dirmodel_update_marked_stats(model, NULL, filedata);
	} else {
		dirmodel_update_marked_stats(model, filedata, NULL);
	}
	filedata->is_marked = mark;
	listmodel_notify_change(listmodel, MODEL_CHANGE, index, index);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x30(%rdi), %rdi
callq 0x76e4
cmpb %bpl, 0xa8(%rax)
jne 0x69be
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
movq %r14, %rdi
testb %bpl, %bpl
je 0x69d0
xorl %esi, %esi
movq %r15, %rdx
jmp 0x69d5
movq %r15, %rsi
xorl %edx, %edx
callq 0x61f0
movb %bpl, 0xa8(%r15)
pushq $0x2
popq %rsi
movq %r14, %rdi
movq %rbx, %rdx
movq %rbx, %rcx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x7901
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/dirmodel.c
// Function: dirmodel_destroy
void dirmodel_destroy(struct dirmodel *model)
{
	internal_destroy(model);
	listmodel_destroy(&model->listmodel);
	if(model->filter_active)
		regfree(&model->filter);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x68c0
movq %rbx, %rdi
callq 0x7963
cmpb $0x1, 0x88(%rbx)
jne 0x6a35
addq $0x48, %rbx
movq %rbx, %rdi
popq %rbx
jmp 0x3220
popq %rbx
retq
nop
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/keymap.c
// Function: keymap_handlekey
int keymap_handlekey(struct keymap *keymap, wint_t key, bool iskeycode)
{
	if(keymap->entries == NULL)
		return EINVAL;

	size_t length = list_length(keymap->entries);

	for(size_t i = 0; i < length; i++) {
		struct keymap_entry *curitem = list_get_item(keymap->entries, i);
		if(curitem->keyspec.key == key && curitem->keyspec.iskeycode == iskeycode) {
			char buffer[strlen(curitem->command) + 1];
			strcpy(buffer, curitem->command);

			return commandexecutor_execute(keymap->commandexecutor, buffer);
		}
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, -0x2c(%rbp)
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
testq %rdi, %rdi
je 0x6a8f
movl %esi, %r12d
callq 0x7515
movq %rax, %r15
xorl %r14d, %r14d
cmpq %r14, %r15
je 0x6a8b
movq 0x8(%rbx), %rdi
movq %r14, %rsi
callq 0x76e4
cmpl %r12d, 0x4(%rax)
jne 0x6a86
movq %rax, %r13
movl -0x2c(%rbp), %eax
cmpb %al, (%r13)
je 0x6a94
incq %r14
jmp 0x6a63
xorl %eax, %eax
jmp 0x6acb
pushq $0x16
popq %rax
jmp 0x6acb
movq 0x8(%r13), %rdi
callq 0x3230
movq %rsp, %r15
movq %rsp, %r14
addq $0x10, %rax
andq $-0x10, %rax
subq %rax, %r14
movq %r14, %rsp
movq 0x8(%r13), %rsi
movq %r14, %rdi
callq 0x3110
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x54f8
movq %r15, %rsp
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/filedata.c
// Function: filedata_listcompare_directory_filename_descending
int filedata_listcompare_directory_filename_descending(const void *a, const void *b)
{
	struct filedata *filedata1 = *(struct filedata **)a;
	struct filedata *filedata2 = *(struct filedata **)b;

	if(!(S_ISDIR(filedata1->stat.st_mode) ^ S_ISDIR(filedata2->stat.st_mode)))
		return -strcoll(filedata1->filename, filedata2->filename);
	if(S_ISDIR(filedata1->stat.st_mode))
		return -1;
	return 1;
}

// Assembly:
movq (%rdi), %rax
movq (%rsi), %rcx
movl $0xf000, %esi           # imm = 0xF000
movl 0x28(%rax), %edx
andl %esi, %edx
movl $0x4000, %edi           # imm = 0x4000
cmpl %edi, %edx
sete %r8b
andl 0x28(%rcx), %esi
cmpl %edi, %esi
sete %sil
xorb %r8b, %sil
je 0x6d84
xorl %eax, %eax
cmpl $0x4000, %edx           # imm = 0x4000
setne %al
leal -0x1(,%rax,2), %eax
retq
pushq %rax
movq (%rax), %rdi
movq (%rcx), %rsi
callq 0x34e0
negl %eax
addq $0x8, %rsp
retq
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/filedata.c
// Function: filedata_listcompare_directory_size_filename
int filedata_listcompare_directory_size_filename(const void *a, const void *b)
{
	struct filedata *filedata1 = *(struct filedata **)a;
	struct filedata *filedata2 = *(struct filedata **)b;

	if(!S_ISDIR(filedata1->stat.st_mode) && !S_ISDIR(filedata2->stat.st_mode)) {
		if(filedata1->stat.st_size < filedata2->stat.st_size)
			return -1;
		else if(filedata1->stat.st_size > filedata2->stat.st_size)
			return 1;
		return strcoll(filedata1->filename, filedata2->filename);
	}
	if(S_ISDIR(filedata1->stat.st_mode) && S_ISDIR(filedata2->stat.st_mode))
		return strcoll(filedata1->filename, filedata2->filename);
	if(S_ISDIR(filedata1->stat.st_mode))
		return -1;
	return 1;
}

// Assembly:
movq (%rdi), %rcx
movq (%rsi), %rdx
movl $0xf000, %esi           # imm = 0xF000
movl 0x28(%rcx), %eax
andl %esi, %eax
andl 0x28(%rdx), %esi
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x6dc4
cmpl $0x4000, %esi           # imm = 0x4000
jne 0x6dda
movq (%rcx), %rdi
movq (%rdx), %rsi
jmp 0x34e0
pushq $0x1
popq %rax
cmpl $0x4000, %esi           # imm = 0x4000
jne 0x6dd0
retq
movq 0x40(%rdx), %rsi
cmpq %rsi, 0x40(%rcx)
jge 0x6dde
pushq $-0x1
popq %rax
retq
jle 0x6db9
jmp 0x6dcf
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/filedata.c
// Function: filedata_listcompare_directory_mtime_filename
int filedata_listcompare_directory_mtime_filename(const void *a, const void *b)
{
	struct filedata *filedata1 = *(struct filedata **)a;
	struct filedata *filedata2 = *(struct filedata **)b;

	if(!(S_ISDIR(filedata1->stat.st_mode) ^ S_ISDIR(filedata2->stat.st_mode))) {
		if(filedata1->stat.st_mtime < filedata2->stat.st_mtime)
			return -1;
		else if(filedata1->stat.st_mtime > filedata2->stat.st_mtime)
			return 1;
		return strcoll(filedata1->filename, filedata2->filename);
	}
	if(S_ISDIR(filedata1->stat.st_mode))
		return -1;
	return 1;
}

// Assembly:
movq (%rdi), %rax
movq (%rsi), %rcx
movl $0xf000, %esi           # imm = 0xF000
movl 0x28(%rax), %edx
andl %esi, %edx
movl $0x4000, %edi           # imm = 0x4000
cmpl %edi, %edx
sete %r8b
andl 0x28(%rcx), %esi
cmpl %edi, %esi
sete %sil
xorb %r8b, %sil
je 0x6e66
xorl %eax, %eax
cmpl $0x4000, %edx           # imm = 0x4000
setne %al
leal -0x1(,%rax,2), %eax
retq
movq 0x68(%rcx), %rdx
cmpq %rdx, 0x68(%rax)
jge 0x6e74
pushq $-0x1
jmp 0x6e78
jle 0x6e7a
pushq $0x1
popq %rax
retq
movq (%rax), %rdi
movq (%rcx), %rsi
jmp 0x34e0
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/filedata.c
// Function: filedata_format_output
void filedata_format_output(const struct filedata *filedata, char *buffer)
{
	if(!filedata->is_stat_valid) {
		strcpy(buffer, "?????????? ? ? ????""-??""-?? ??:??:??");
		return;
	}


	buffer[0] = filetype_character(&filedata->stat);
	permission_characters(buffer + 1, (filedata->stat.st_mode >> 6) & 7);
	permission_characters(buffer + 4, (filedata->stat.st_mode >> 3) & 7);
	permission_characters(buffer + 7,  filedata->stat.st_mode       & 7);
	buffer[10] = ' ';

	size_t length = 11;

	struct passwd *passwd = getpwuid(filedata->stat.st_uid);
	struct group *group = getgrgid(filedata->stat.st_gid);
	struct tm modification_time;
	localtime_r(&filedata->stat.st_mtime, &modification_time);

	if(passwd)
		length += sprintf(buffer + length, "%.32s ", passwd->pw_name);
	else
		length += sprintf(buffer + length, "%.32d ", filedata->stat.st_uid);
	if(group)
		length += sprintf(buffer + length, "%.32s ", group->gr_name);
	else
		length += sprintf(buffer + length, "%.32d ", filedata->stat.st_gid);

	length += strftime(buffer + length, sizeof("1970-01-01 00:00:00"), "%F %T", &modification_time);

	buffer[length] = 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
cmpb $0x0, 0xa9(%rdi)
je 0x6f9f
movq %rdi, %r14
movl $0xf000, %eax           # imm = 0xF000
andl 0x28(%rdi), %eax
addl $0xfffff000, %eax       # imm = 0xFFFFF000
movb $0x2d, %cl
cmpl $0xbfff, %eax           # imm = 0xBFFF
ja 0x6f21
shrl $0xc, %eax
leaq 0x23ba(%rip), %rcx      # 0x92d8
movb (%rax,%rcx), %cl
movb %cl, (%rbx)
leaq 0x1(%rbx), %rdi
movl 0x28(%r14), %esi
shrl $0x6, %esi
andl $0x7, %esi
callq 0x7034
leaq 0x4(%rbx), %rdi
movzbl 0x28(%r14), %esi
shrl $0x3, %esi
andl $0x7, %esi
callq 0x7034
leaq 0x7(%rbx), %rdi
movl 0x28(%r14), %esi
andl $0x7, %esi
callq 0x7034
movb $0x20, 0xa(%rbx)
movl 0x2c(%r14), %edi
callq 0x3210
movq %rax, %r12
movl 0x30(%r14), %edi
callq 0x3290
movq %rax, %r15
leaq 0x68(%r14), %rdi
movq %rsp, %rsi
callq 0x3100
leaq 0xb(%rbx), %rdi
testq %r12, %r12
je 0x6fbd
movq (%r12), %rdx
leaq 0x22fb(%rip), %rsi      # 0x9291
xorl %eax, %eax
callq 0x3680
jmp 0x6fcf
movups 0x22d8(%rip), %xmm0     # 0x927e
movups %xmm0, 0x10(%rbx)
movups 0x22bd(%rip), %xmm0     # 0x926e
movups %xmm0, (%rbx)
movl $0x3f3f3a, 0x1f(%rbx)   # imm = 0x3F3F3A
jmp 0x7028
movl 0x2c(%r14), %edx
leaq 0x22d0(%rip), %rsi      # 0x9298
xorl %eax, %eax
callq 0x3680
cltq
leaq 0xb(%rax), %r12
leaq (%rbx,%rax), %rdi
addq $0xb, %rdi
testq %r15, %r15
je 0x6ff5
movq (%r15), %rdx
leaq 0x22a5(%rip), %rsi      # 0x9291
xorl %eax, %eax
callq 0x3680
jmp 0x7007
movl 0x30(%r14), %edx
leaq 0x2298(%rip), %rsi      # 0x9298
xorl %eax, %eax
callq 0x3680
cltq
addq %r12, %rbx
addq %rax, %rbx
leaq 0x2289(%rip), %rdx      # 0x929f
pushq $0x14
popq %rsi
movq %rsp, %rcx
movq %rbx, %rdi
callq 0x35a0
movb $0x0, (%rax,%rbx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/filedata.c
// Function: filesize_to_string
void filesize_to_string(wchar_t *buf, off_t filesize)
{
	char suffix[] = {' ', 'K', 'M', 'G', 'T', 'P', 'E'};
	size_t cs = 0;
	off_t cv = filesize;

	while(cv > 1024 && cs < sizeof(suffix) - 1) {
		filesize = cv;
		cv /= 1024;
		cs++;
	}

	if(cv >= 10000)
		wcscpy(buf, INFO_SIZE_OVERFLOW);
	else if(cv < 100 && cs > 0)
		swprintf(buf, 6, L"%lu.%1lu%c", cv, (filesize - cv * 1024) * 10 / 1024, suffix[cs]);
	else
		swprintf(buf, 6, L"%lu%c", cv, suffix[cs]);
}

// Assembly:
xorl %r8d, %r8d
movq %rsi, %rcx
cmpq $0x401, %rcx            # imm = 0x401
jl 0x707f
cmpq $0x5, %r8
ja 0x707f
movq %rcx, %rsi
shrq $0xa, %rcx
incq %r8
jmp 0x7064
cmpq $0x2710, %rcx           # imm = 0x2710
jl 0x7094
leaq 0x2255(%rip), %rsi      # 0x92e4
jmp 0x33e0
cmpq $0x64, %rcx
setl %al
testq %r8, %r8
setne %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0x70e0
movq %rcx, %rax
shlq $0xa, %rax
subq %rax, %rsi
imulq $0xa, %rsi, %rax
movl $0x400, %esi            # imm = 0x400
cqto
idivq %rsi
leaq 0x21e9(%rip), %rdx      # 0x92b0
movsbl (%r8,%rdx), %r9d
leaq 0x2229(%rip), %rdx      # 0x92fc
pushq $0x6
popq %rsi
movq %rax, %r8
xorl %eax, %eax
jmp 0x3410
leaq 0x21c9(%rip), %rax      # 0x92b0
movsbl (%r8,%rax), %r8d
leaq 0x2235(%rip), %rdx      # 0x9328
pushq $0x6
popq %rsi
xorl %eax, %eax
jmp 0x3410
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/filedata.c
// Function: filedata_new_from_file
int filedata_new_from_file(struct filedata **filedata, int dirfd, const char *filename)
{
	struct stat stat;
	bool valid = true;

	if(fstatat(dirfd, filename, &stat, AT_SYMLINK_NOFOLLOW) != 0) {
		if(errno == ENOENT)
			return ENOENT;
		valid = false;
		memset(&stat, 0, sizeof(stat));
	}

	*filedata = malloc(sizeof(**filedata));
	if(*filedata == NULL)
		return ENOMEM;

	(*filedata)->filename = strdup(filename);
	if((*filedata)->filename == NULL) {
		free(*filedata);
		*filedata = NULL;
		return ENOMEM;
	}

	(*filedata)->is_marked = false;
	(*filedata)->is_stat_valid = valid;

	if(S_ISLNK(stat.st_mode)) {
		(*filedata)->is_link = true;
		(*filedata)->link_size = stat.st_size;
		if(fstatat(dirfd, (*filedata)->filename, &(*filedata)->stat, 0) != 0) {
			(*filedata)->is_link_broken = true;
			memcpy(&(*filedata)->stat, &stat, sizeof(stat));
		} else
			(*filedata)->is_link_broken = false;
	} else {
		(*filedata)->is_link = false;
		memcpy(&(*filedata)->stat, &stat, sizeof(stat));
	}

	/* st_size field is not used for directories, so zero it out to get
	 * better file size count statistics in dirmodel */
	if(S_ISDIR((*filedata)->stat.st_mode))
		(*filedata)->stat.st_size = 0;
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdx, %r15
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x8(%rsp), %rdx
movl %esi, %edi
movq %r15, %rsi
movl $0x100, %ecx            # imm = 0x100
callq 0x3710
movl %eax, %r12d
testl %eax, %eax
je 0x736a
callq 0x30d0
cmpl $0x2, (%rax)
jne 0x7359
pushq $0x2
popq %r13
jmp 0x744e
leaq 0x8(%rsp), %rdi
movl $0x90, %edx
xorl %esi, %esi
callq 0x32e0
movl $0xb0, %edi
callq 0x3490
movq %rax, (%rbx)
pushq $0xc
popq %r13
testq %rax, %rax
je 0x744e
movq %rax, %r14
movq %r15, %rdi
callq 0x36a0
movq %rax, (%r14)
testq %rax, %rax
je 0x7406
testl %r12d, %r12d
movb $0x0, 0xa8(%r14)
sete 0xa9(%r14)
movl $0xf000, %ecx           # imm = 0xF000
andl 0x20(%rsp), %ecx
cmpl $0xa000, %ecx           # imm = 0xA000
jne 0x7414
movb $0x1, 0x8(%r14)
movq 0x38(%rsp), %rcx
movq %rcx, 0xa0(%r14)
addq $0x10, %r14
movl %ebp, %edi
movq %rax, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x3710
movq (%rbx), %r14
testl %eax, %eax
je 0x7431
movb $0x1, 0x9(%r14)
addq $0x10, %r14
leaq 0x8(%rsp), %rsi
movl $0x90, %edx
movq %r14, %rdi
callq 0x3450
movq (%rbx), %r14
jmp 0x7436
movq %r14, %rdi
callq 0x3740
andq $0x0, (%rbx)
jmp 0x744e
movb $0x0, 0x8(%r14)
movq %r14, %rdi
addq $0x10, %rdi
leaq 0x8(%rsp), %rsi
movl $0x90, %edx
callq 0x3450
jmp 0x7436
movb $0x0, 0x9(%r14)
movl $0xf000, %eax           # imm = 0xF000
andl 0x28(%r14), %eax
xorl %r13d, %r13d
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x744e
andq $0x0, 0x40(%r14)
movl %r13d, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/list.c
// Function: list_new
struct list *list_new(size_t initial_size)
{
	struct list *list;

	list = malloc(sizeof(*list));
	if(list == NULL)
		return NULL;

	list->length = 0;
	list->allocated_items = initial_size;
	if(list->allocated_items == 0)
		list->allocated_items = 1;

	list->items = malloc(list->allocated_items * sizeof(void *));
	if(list->items == NULL) {
		free(list);
		return NULL;
	}

	return list;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
pushq $0x18
popq %rdi
callq 0x3490
testq %rax, %rax
je 0x74c4
movq %rax, %rbx
andq $0x0, (%rax)
cmpq $0x1, %r14
adcq $0x0, %r14
movq %r14, 0x8(%rax)
shlq $0x3, %r14
movq %r14, %rdi
callq 0x3490
movq %rax, 0x10(%rbx)
testq %rax, %rax
jne 0x74c6
movq %rbx, %rdi
callq 0x3740
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/list.c
// Function: list_delete
void list_delete(const struct list *list, list_item_deallocator deallocator)
{
	if(list == NULL)
		return;
	if(deallocator)
		for(size_t i = 0; i < list->length; i++)
			deallocator(list->items[i]);
	free(list->items);
	free((void *)list);
}

// Assembly:
testq %rdi, %rdi
je 0x7514
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
testq %rsi, %rsi
je 0x74fe
xorl %r15d, %r15d
cmpq (%rbx), %r15
jae 0x74fe
movq 0x10(%rbx), %rax
movq (%rax,%r15,8), %rdi
callq *%r14
incq %r15
jmp 0x74e9
movq 0x10(%rbx), %rdi
callq 0x3740
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x3740
retq
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/list.c
// Function: list_append
bool list_append(struct list *list, void *item)
{
	if(list->length == list->allocated_items)
		if(!list_make_room(list))
			return false;

	list->items[list->length] = item;
	list->length++;

	return true;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %rax
cmpq 0x8(%rdi), %rax
jne 0x753b
movq %rbx, %rdi
callq 0x7557
testb %al, %al
je 0x754d
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
movq %r14, (%rcx,%rax,8)
incq %rax
movq %rax, (%rbx)
movb $0x1, %al
jmp 0x754f
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/list.c
// Function: list_make_room
static bool list_make_room(struct list *list)
{
	void *newitems = realloc(list->items, 2 * list->allocated_items * sizeof(void *));
	if(newitems == NULL)
		return false;

	list->allocated_items *= 2;
	list->items = newitems;

	return true;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rdi
shlq $0x4, %rsi
callq 0x3520
testq %rax, %rax
je 0x7579
shlq 0x8(%rbx)
movq %rax, 0x10(%rbx)
testq %rax, %rax
setne %al
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/list.c
// Function: list_insert
bool list_insert(struct list *list, size_t index, void *item)
{
	assert(index <= list->length);

	if(list->length == list->allocated_items)
		if(!list_make_room(list))
			return false;

	memmove(&list->items[index + 1], &list->items[index], (list->length - index) * sizeof(list->items[0]));
	list->items[index] = item;
	list->length++;

	return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %rbx
movq (%rdi), %rdx
cmpq %rsi, %rdx
jb 0x75df
movq %rsi, %r15
movq %rdi, %r14
cmpq 0x8(%rdi), %rdx
jne 0x75ac
movq %r14, %rdi
callq 0x7557
testb %al, %al
je 0x75d7
movq (%r14), %rdx
movq 0x10(%r14), %rax
leaq (%rax,%r15,8), %rsi
leaq (%rax,%r15,8), %rdi
addq $0x8, %rdi
subq %r15, %rdx
shlq $0x3, %rdx
callq 0x35b0
movq 0x10(%r14), %rax
movq %rbx, (%rax,%r15,8)
incq (%r14)
movb $0x1, %al
jmp 0x75d9
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
leaq 0x1da6(%rip), %rdi      # 0x938c
leaq 0x1db5(%rip), %rsi      # 0x93a2
leaq 0x1db9(%rip), %rcx      # 0x93ad
pushq $0x4e
popq %rdx
callq 0x32c0
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/list.c
// Function: list_move_item
void list_move_item(struct list *list, size_t oldindex, size_t newindex)
{
	assert(oldindex < list->length);
	assert(newindex < list->length);

	void *item = list->items[oldindex];

	if(oldindex < newindex)
		memmove(&list->items[oldindex], &list->items[oldindex + 1], (newindex - oldindex) * sizeof(list->items[0]));
	else
		memmove(&list->items[newindex + 1], &list->items[newindex], (oldindex - newindex) * sizeof(list->items[0]));

	list->items[newindex] = item;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq (%rdi), %rax
cmpq %rsi, %rax
jbe 0x765e
movq %rdx, %rbx
cmpq %rdx, %rax
jbe 0x7677
movq %rdi, %r14
movq 0x10(%rdi), %rax
movq (%rax,%rsi,8), %r15
movq %rsi, %rdx
subq %rbx, %rdx
jae 0x763b
leaq (%rax,%rsi,8), %rdi
leaq 0x8(%rdi), %rax
movq %rbx, %rdx
subq %rsi, %rdx
shlq $0x3, %rdx
movq %rax, %rsi
jmp 0x764b
leaq (%rax,%rbx,8), %rsi
leaq (%rax,%rbx,8), %rdi
addq $0x8, %rdi
shlq $0x3, %rdx
callq 0x35b0
movq 0x10(%r14), %rax
movq %r15, (%rax,%rbx,8)
popq %rbx
popq %r14
popq %r15
retq
leaq 0x1d79(%rip), %rdi      # 0x93de
leaq 0x1d36(%rip), %rsi      # 0x93a2
leaq 0x1d83(%rip), %rcx      # 0x93f6
pushq $0x5d
jmp 0x768e
leaq 0x1dab(%rip), %rdi      # 0x9429
leaq 0x1d1d(%rip), %rsi      # 0x93a2
leaq 0x1d6a(%rip), %rcx      # 0x93f6
pushq $0x5e
popq %rdx
callq 0x32c0
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/list.c
// Function: list_find_item_or_insertpoint
bool list_find_item_or_insertpoint(const struct list *list, int (*compare)(const void *, const void *), const void *item, size_t *index)
{
	void *currentitem;
	size_t min, middle, max;
	int ret;

	if(list_length(list) == 0) {
		*index = 0;
		return false;
	}

	min = 0;
	max = list_length(list) - 1;

	while(min < max) {
		middle = (min + max) / 2;
		currentitem = list_get_item(list, middle);
		ret = compare(&item, &currentitem);
		if(ret <= 0)
			max = middle;
		else
			min = middle + 1;
	}

	*index = min;
	currentitem = list_get_item(list, *index);
	ret = compare(&item, &currentitem);

	if(ret > 0 && *index == list_length(list) - 1)
		*index = list_length(list);
	return ret == 0;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, 0x8(%rsp)
movq (%rdi), %r13
testq %r13, %r13
je 0x77f5
movq %rsi, %r15
movq %rdi, %r14
movq %rcx, 0x10(%rsp)
decq %r13
xorl %ebx, %ebx
movq %rsp, %rbp
cmpq %r13, %rbx
jae 0x77b7
leaq (%rbx,%r13), %r12
shrq %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x76e4
movq %rax, (%rsp)
leaq 0x8(%rsp), %rdi
movq %rbp, %rsi
callq *%r15
testl %eax, %eax
jle 0x77b2
incq %r12
movq %r12, %rbx
jmp 0x7780
movq %r12, %r13
jmp 0x7780
movq 0x10(%rsp), %r12
movq %rbx, (%r12)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x76e4
movq %rsp, %rsi
movq %rax, (%rsi)
leaq 0x8(%rsp), %rdi
callq *%r15
testl %eax, %eax
jle 0x77ee
movq (%r14), %rcx
leaq -0x1(%rcx), %rdx
cmpq %rdx, (%r12)
jne 0x77ee
movq %rcx, (%r12)
testl %eax, %eax
sete %al
jmp 0x77fb
andq $0x0, (%rcx)
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/listmodel.c
// Function: listmodel_register_change_callback
bool listmodel_register_change_callback(struct listmodel *model, model_change_callback callback, void *data)
{
	if(model->change_callbacks == NULL)
		model->change_callbacks = list_new(0);

	if(model->change_callbacks == NULL)
		return false;

	struct callback *cb = malloc(sizeof(*cb));
	if(cb == NULL)
		return false;

	cb->cb = callback;
	cb->data = data;

	if(!list_append(model->change_callbacks, cb)) {
		free(cb);
		return false;
	}

	return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movq 0x20(%rdi), %r12
testq %r12, %r12
jne 0x7862
movq %rdi, %r13
xorl %r15d, %r15d
xorl %edi, %edi
callq 0x7480
movq %rax, %r12
movq %rax, 0x20(%r13)
testq %rax, %rax
je 0x7896
pushq $0x10
popq %rdi
callq 0x3490
testq %rax, %rax
je 0x7893
movq %rax, %r13
movq %r14, (%rax)
movq %rbx, 0x8(%rax)
movq %r12, %rdi
movq %rax, %rsi
callq 0x7519
movb $0x1, %r15b
testb %al, %al
jne 0x7896
movq %r13, %rdi
callq 0x3740
xorl %r15d, %r15d
movl %r15d, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/listmodel.c
// Function: listmodel_unregister_change_callback
void listmodel_unregister_change_callback(struct listmodel *model, model_change_callback callback, void *data)
{
	struct list *list = model->change_callbacks;
	struct callback *cb;
	size_t length = list_length(list);;

	for(size_t i = 0; i < length; i++) {
		cb = list_get_item(list, i);
		if(cb->cb == callback && cb->data == data) {
			free(cb);
			list_remove(list, i);
		}
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movq 0x20(%rdi), %r15
movq %r15, %rdi
callq 0x7515
movq %rax, %r12
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x78f7
movq %r15, %rdi
movq %r13, %rsi
callq 0x76e4
cmpq %r14, (%rax)
jne 0x78f2
cmpq %rbx, 0x8(%rax)
jne 0x78f2
movq %rax, %rdi
callq 0x3740
movq %r15, %rdi
movq %r13, %rsi
callq 0x7694
incq %r13
jmp 0x78c4
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/listmodel.c
// Function: listmodel_notify_change
void listmodel_notify_change(struct listmodel *model, enum model_change change, size_t newindex, size_t oldindex)
{
	struct list *list = model->change_callbacks;
	if(list == NULL)
		return;

	struct callback *cb;
	size_t length = list_length(list);;

	for(size_t i = 0; i < length; i++) {
		cb = list_get_item(list, i);
		cb->cb(change, newindex, oldindex, cb->data);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x20(%rdi), %r15
testq %r15, %r15
je 0x794e
movq %rcx, %rbx
movq %rdx, %r14
movl %esi, %ebp
movq %r15, %rdi
callq 0x7515
movq %rax, %r12
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x794e
movq %r15, %rdi
movq %r13, %rsi
callq 0x76e4
movq 0x8(%rax), %rcx
movl %ebp, %edi
movq %r14, %rsi
movq %rbx, %rdx
callq *(%rax)
incq %r13
jmp 0x792b
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/listview.c
// Function: listview_refresh
void listview_refresh(struct listview *view)
{
	if(!view->needs_refresh)
		return;

	unsigned int height, width;
	size_t i = 0;
	height = getmaxy(view->window);
	width = getmaxx(view->window);

	size_t buflen = width;

	werase(view->window);
	while(i < height) {
		if(i + view->first >= listmodel_count(view->model))
			break;

		wchar_t buffer[buflen + 1];
		size_t reallen = listmodel_render(view->model, buffer, buflen, width, i + view->first);

		if(reallen > buflen) {
			buflen = reallen;
			continue;
		}

		int attrs = attrs_for_index(view->model, view->first + i, view->index);

		wmove(view->window, i, 0);
		wattron(view->window, attrs);
		waddwstr(view->window, buffer);
		wattroff(view->window, attrs);

		i++;
	}
	wrefresh(view->window);
	view->needs_refresh = false;
}

// Assembly:
cmpb $0x1, 0x20(%rdi)
jne 0x7ac0
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x79ae
movswl 0x4(%rdi), %eax
incl %eax
movq %rax, -0x30(%rbp)
movswl 0x6(%rdi), %r14d
incl %r14d
jmp 0x79bd
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, -0x30(%rbp)
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
callq 0x30e0
xorl %r15d, %r15d
movq %r14, -0x38(%rbp)
movq %r14, -0x48(%rbp)
cmpq -0x30(%rbp), %r15
jae 0x7aa6
movq 0x10(%rbx), %r14
addq %r15, %r14
movq 0x8(%rbx), %rdi
callq 0x780c
cmpq %rax, %r14
movq -0x48(%rbp), %r14
jae 0x7aa6
movq %rsp, -0x50(%rbp)
movq %rsp, %r12
movq -0x38(%rbp), %r13
leaq 0x13(,%r13,4), %rax
andq $-0x10, %rax
subq %rax, %r12
movq %r12, %rsp
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %r8
addq %r15, %r8
movq %r12, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0x780e
cmpq %r13, %rax
jbe 0x7a35
movq %rax, -0x38(%rbp)
jmp 0x7a9d
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %r13
addq %r15, %r13
movq 0x18(%rbx), %rax
movq %rax, -0x40(%rbp)
movq %r13, %rsi
callq 0x7823
movzbl %al, %eax
shll $0x9, %eax
leal 0x200100(%rax), %r14d
cmpq -0x40(%rbp), %r13
cmovnel %eax, %r14d
movq (%rbx), %rdi
movl %r15d, %esi
xorl %edx, %edx
callq 0x3090
movq (%rbx), %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x3120
movq (%rbx), %rdi
movq %r12, %rsi
pushq $-0x1
popq %rdx
callq 0x32d0
movq (%rbx), %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x3620
incq %r15
movq -0x50(%rbp), %rsp
jmp 0x79cd
movq (%rbx), %rdi
callq 0x3390
movb $0x0, 0x20(%rbx)
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/listview.c
// Function: listview_setindex_internal
static void listview_setindex_internal(struct listview *view, size_t index, int direction, bool keep_distance)
{
	size_t listcount = listmodel_count(view->model);
	unsigned int rowcount = getmaxy(view->window);
	size_t distance = view->index - view->first;

	/* check index for over- and underflow */
	if(direction == 0 && index > listcount - 1)
		view->index = listcount - 1;
	else if(direction < 0 && index > view->index)
		view->index = 0;
	else if(direction > 0 && (index < view->index || index > listcount - 1))
		view->index = listcount - 1;
	else
		view->index = index;

	/* try to restore distance between first and index
	 * may underflow, but this is checked later */
	if(keep_distance)
		view->first = view->index - distance;

	/* make sure, first has a sane value relative to index */
	if(view->index < view->first)
		view->first = view->index;
	else if(view->index - view->first >= rowcount)
		view->first = view->index - rowcount + 1;

	/* make sure, view is always filled to the bottom with entries,
	 * or in case there aren't enough, scrolled to the first entry */
	if(listcount <= rowcount)
		view->first = 0;
	else if(listcount - view->first <= rowcount)
		view->first = listcount - rowcount;

	view->needs_refresh = true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %ecx, %ebp
movl %edx, %r15d
movq %rsi, %r14
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
callq 0x780c
movq (%rbx), %rcx
testq %rcx, %rcx
je 0x7afa
movswl 0x4(%rcx), %ecx
incl %ecx
jmp 0x7aff
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq 0x18(%rbx), %rsi
testl %r15d, %r15d
je 0x7b23
js 0x7b2e
cmpq %r14, %rsi
seta %dil
leaq -0x1(%rax), %rdx
cmpq %r14, %rdx
setb %r8b
orb %dil, %r8b
je 0x7b37
jmp 0x7b3a
leaq -0x1(%rax), %rdx
cmpq %r14, %rdx
jae 0x7b37
jmp 0x7b3a
cmpq %r14, %rsi
jae 0x7b37
xorl %edx, %edx
jmp 0x7b3a
movq %r14, %rdx
movq 0x10(%rbx), %rdi
movq %rdx, 0x18(%rbx)
testb %bpl, %bpl
je 0x7b51
subq %rsi, %rdi
addq %rdx, %rdi
movq %rdi, 0x10(%rbx)
movq %rdx, %rsi
subq %rdi, %rsi
jb 0x7b64
cmpq %rcx, %rsi
jb 0x7b6b
subq %rcx, %rdx
incq %rdx
movq %rdx, 0x10(%rbx)
movq %rdx, %rdi
movq %rax, %rdx
subq %rcx, %rdx
jbe 0x7b7d
subq %rdi, %rax
cmpq %rcx, %rax
jbe 0x7b7f
jmp 0x7b83
xorl %edx, %edx
movq %rdx, 0x10(%rbx)
movb $0x1, 0x20(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/listview.c
// Function: listview_init
bool listview_init(struct listview *view, struct listmodel *model, unsigned int x, unsigned int y, unsigned int width, unsigned int height)
{
	view->window = newwin(height, width, y, x);
	if(view->window == NULL)
		return false;

	view->index = 0;
	view->first = 0;
	view->model = model;
	view->needs_refresh = true;

	if(!listmodel_register_change_callback(view->model, change_cb, view)) {
		delwin(view->window);
		view->window = NULL;
		return false;
	}

	listview_refresh(view);

	return true;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %eax
movq %rsi, %r14
movq %rdi, %rbx
movl %r9d, %edi
movl %r8d, %esi
movl %ecx, %edx
movl %eax, %ecx
callq 0x3030
movq %rax, (%rbx)
testq %rax, %rax
je 0x7cad
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movq %r14, 0x8(%rbx)
movb $0x1, 0x20(%rbx)
leaq 0x31(%rip), %rsi        # 0x7cb7
movq %r14, %rdi
movq %rbx, %rdx
callq 0x7831
testb %al, %al
je 0x7ca1
movq %rbx, %rdi
callq 0x7974
movb $0x1, %al
jmp 0x7caf
movq (%rbx), %rdi
callq 0x31e0
andq $0x0, (%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq