// File: /workspace/github_c_makefile_star2_O0/cglindkamp[P]dfm/src/dirmodel.c
// Function: internal_init
static bool internal_init(struct dirmodel *model, const char *path)
{
	DIR *dir;
	struct filedata *filedata;

	dir = opendir(path);
	if(dir == NULL)
		goto err_opendir;

	model->addchange_queue = list_new(0);
	if(model->addchange_queue == NULL)
		goto err_new_addchange_queue;

	struct list *list = list_new(0);
	if(list == NULL)
		goto err_newlist;

	struct list *sortedlist = list_new(0);
	if(sortedlist == NULL)
		goto err_newsortedlist;


	model->dirsize = 0;
	for(struct dirent *entry = readdir(dir); entry; entry = readdir(dir)) {
		if(strcmp(entry->d_name, ".") != 0 &&
		   strcmp(entry->d_name, "..") != 0 &&
		   (model->filter_active ? regexec(&model->filter, entry->d_name, 0, NULL, 0) == 0 : true)) {
			int ret = filedata_new_from_file(&filedata, dirfd(dir), entry->d_name);

			if(ret == ENOMEM)
				goto err_readdir;

			if(ret != 0)
				continue;

			if(!list_append(sortedlist, filedata))
				goto err_readdir;
			if(!list_append(list, filedata))
				goto err_readdir;
			dirmodel_update_dirsize(model, NULL, filedata);
		}
	}
	model->dir = dir;
	model->list = list;
	model->sortedlist = sortedlist;

	list_sort(list, filedata_listcompare_filename);
	list_sort(sortedlist, model->sort_compare);

	model->marked_stats.count = 0;
	model->marked_stats.size = 0;

	return true;

err_readdir:
	filedata_delete(filedata);
	list_delete(sortedlist, NULL);
err_newsortedlist:
	list_delete(list, (list_item_deallocator)filedata_delete);
err_newlist:
	list_delete(model->addchange_queue, NULL);
err_new_addchange_queue:
	closedir(dir);
err_opendir:
	return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3200
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x8439
jmp 0x865a
xorl %eax, %eax
movl %eax, %edi
callq 0x9f60
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x38(%rax)
jne 0x845d
jmp 0x8651
xorl %eax, %eax
movl %eax, %edi
callq 0x9f60
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x8476
jmp 0x8640
xorl %eax, %eax
movl %eax, %edi
callq 0x9f60
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x848f
jmp 0x8630
movq -0x10(%rbp), %rax
movq $0x0, 0xb0(%rax)
movq -0x20(%rbp), %rdi
callq 0x3470
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x85ae
movq -0x40(%rbp), %rdi
addq $0x13, %rdi
leaq 0x4d2d(%rip), %rsi      # 0xd1f2
callq 0x33d0
cmpl $0x0, %eax
je 0x859a
movq -0x40(%rbp), %rdi
addq $0x13, %rdi
leaq 0x4d0f(%rip), %rsi      # 0xd1f1
callq 0x33d0
cmpl $0x0, %eax
je 0x859a
movq -0x10(%rbp), %rax
testb $0x1, 0x88(%rax)
je 0x8523
movq -0x10(%rbp), %rdi
addq $0x48, %rdi
movq -0x40(%rbp), %rsi
addq $0x13, %rsi
xorl %eax, %eax
movl %eax, %ecx
xorl %r8d, %r8d
movq %rcx, %rdx
callq 0x34d0
cmpl $0x0, %eax
je 0x852b
jmp 0x859a
movb $0x1, %al
testb $0x1, %al
jne 0x852b
jmp 0x859a
movq -0x20(%rbp), %rdi
callq 0x33f0
movl %eax, %esi
movq -0x40(%rbp), %rdx
addq $0x13, %rdx
leaq -0x28(%rbp), %rdi
callq 0x9d40
movl %eax, -0x44(%rbp)
cmpl $0xc, -0x44(%rbp)
jne 0x8555
jmp 0x861a
cmpl $0x0, -0x44(%rbp)
je 0x855d
jmp 0x859c
movq -0x38(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0xa0b0
testb $0x1, %al
jne 0x8573
jmp 0x861a
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0xa0b0
testb $0x1, %al
jne 0x8589
jmp 0x861a
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rdx
xorl %eax, %eax
movl %eax, %esi
callq 0x7f10
jmp 0x859c
movq -0x20(%rbp), %rdi
callq 0x3470
movq %rax, -0x40(%rbp)
jmp 0x84ab
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x30(%rbp), %rdi
leaq 0xa43(%rip), %rsi       # 0x9020
callq 0xa4f0
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rsi
callq 0xa4f0
movq -0x10(%rbp), %rax
movq $0x0, 0xa0(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0xa8(%rax)
movb $0x1, -0x1(%rbp)
jmp 0x865e
movq -0x28(%rbp), %rdi
callq 0x9f30
movq -0x38(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xa010
movq -0x30(%rbp), %rdi
leaq 0x18f5(%rip), %rsi      # 0x9f30
callq 0xa010
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xa010
movq -0x20(%rbp), %rdi
callq 0x3350
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)