// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/application.c
// Function: application_init
bool application_init(struct application *app)
{
	bool ret = true;

	app->mode = MODE_NORMAL;
	app->lastsearch_regex = NULL;
	app->timer_running = false;
	curs_set(0);

	processmanager_init(&app->pm);

	const char *shared_clipboard_path = getenv("DFM_CLIPBOARD_DIR");
	if(shared_clipboard_path) {
		if(access(shared_clipboard_path, R_OK | W_OK | X_OK) != 0)
			shared_clipboard_path = NULL;
	}
	clipboard_init(&app->clipboard, shared_clipboard_path);

	app->inotify_fd = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
	app->inotify_watch = -1;

	dirmodel_init(&app->model);
	commandexecutor_init(&app->commandexecutor, application_command_map);
	keymap_init(&app->keymap, &app->commandexecutor);

	app->stored_positions = dict_new();
	if(app->stored_positions == NULL)
		ret = false;

	app->pathbar = newwin(1, COLS, 0, 0);
	if(app->pathbar == NULL)
		ret = false;

	app->status = newwin(1, COLS, LINES - 1, 0);
	if(app->status != NULL) {
		keypad(app->status, TRUE);
		nodelay(app->status, TRUE);
	} else
		ret = false;

	if(!commandline_init(&app->commandline, 0, LINES - 1, COLS))
		ret = false;

	if(!path_init(&app->cwd, PATH_MAX))
		ret = false;

	if(!listview_init(&app->view, &app->model.listmodel, 0, 1, COLS, LINES - 2))
		ret = false;

	if(ret == false)
		return false;

	if(!path_set_to_current_working_directory(&app->cwd))
		return false;

	if(!enter_directory(app, NULL))
		return false;

	app->signal_fd = create_signalfd();
	if(app->signal_fd == -1)
		return false;

	if(!application_run_rcfile(app))
		return false;

	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdi, %r14
andl $0x0, 0x1bc(%rdi)
andq $0x0, 0x1c8(%rdi)
movb $0x0, 0x1a8(%rdi)
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x3140
leaq 0x180(%r14), %rdi
callq 0x8213
leaq 0x4988(%rip), %rdi      # 0x911f
callq 0x3070
testq %rax, %rax
je 0x47b7
movq %rax, %r15
pushq $0x7
popq %rsi
movq %rax, %rdi
callq 0x3610
xorl %ebx, %ebx
testl %eax, %eax
cmoveq %r15, %rbx
leaq 0x150(%r14), %rdi
movq %rbx, %rsi
callq 0x53ca
movl $0x80800, %edi          # imm = 0x80800
callq 0x36f0
movl %eax, 0x1b0(%r14)
orl $-0x1, 0x1b4(%r14)
leaq 0x28(%r14), %rdi
movq %rdi, 0x10(%rsp)
callq 0x6910
leaq 0x178(%r14), %rbx
leaq 0x8bb5(%rip), %rsi      # 0xd3b0
movq %rbx, %rdi
callq 0x5534
leaq 0x168(%r14), %rdi
movq %rbx, 0x8(%rsp)
movq %rbx, %rsi
callq 0x6ccf
xorl %r12d, %r12d
xorl %eax, %eax
callq 0x5d70
movq %rax, %r15
movq %rax, 0xe0(%r14)
movq 0x87a6(%rip), %rbp      # 0xcfd8
movl (%rbp), %esi
pushq $0x1
popq %rbx
movl %ebx, %edi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x3030
movq %rax, %r13
movq %rax, 0xe8(%r14)
movl (%rbp), %esi
movq 0x8789(%rip), %rax      # 0xcfe0
movl (%rax), %edx
decl %edx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x3030
movq %rax, 0xf0(%r14)
testq %rax, %rax
je 0x489b
testq %r13, %r13
setne %cl
testq %r15, %r15
setne %r12b
andb %cl, %r12b
pushq $0x1
popq %rbx
movq %rax, %rdi
movl %ebx, %esi
callq 0x3360
movq 0xf0(%r14), %rdi
movl %ebx, %esi
callq 0x3060
movl %r12d, 0x4(%rsp)
leaq 0xf8(%r14), %rdi
movq 0x8732(%rip), %r12      # 0xcfe0
movl (%r12), %edx
decl %edx
movl (%rbp), %ecx
xorl %esi, %esi
callq 0x5ce7
movq %rbp, %r15
movl %eax, %ebp
leaq 0x140(%r14), %r13
movl $0x1000, %esi           # imm = 0x1000
movq %r13, %rdi
callq 0x805f
movl %eax, %ebx
movl (%r15), %r8d
movl (%r12), %r9d
addl $-0x2, %r9d
pushq $0x1
popq %rcx
movq %r14, %rdi
movq 0x10(%rsp), %rsi
xorl %edx, %edx
callq 0x7c4d
testb %al, %al
je 0x49e1
testb %bl, %bl
je 0x49e1
testb %bpl, %bpl
movl $0x0, %ebx
je 0x49e3
cmpb $0x0, 0x4(%rsp)
je 0x49e3
movq %r13, %rdi
callq 0x7ebe
testb %al, %al
je 0x49e1
xorl %ebx, %ebx
movq %r14, %rdi
xorl %esi, %esi
callq 0x4aab
testb %al, %al
je 0x49e3
leaq 0x18(%rsp), %r12
movq %r12, %rdi
callq 0x3400
pushq $0x1c
popq %rsi
movq %r12, %rdi
callq 0x36e0
pushq $0x11
popq %rsi
movq %r12, %rdi
callq 0x36e0
pushq $0xe
popq %rsi
movq %r12, %rdi
callq 0x36e0
xorl %ebx, %ebx
xorl %edi, %edi
movq %r12, %rsi
xorl %edx, %edx
callq 0x30a0
pushq $-0x1
popq %rdi
movq %r12, %rsi
movl $0x80000, %edx          # imm = 0x80000
callq 0x3300
movl %eax, 0x1ac(%r14)
cmpl $-0x1, %eax
je 0x49e3
leaq 0x47ae(%rip), %rdi      # 0x9150
leaq 0x4829(%rip), %rdx      # 0x91d2
xorl %ebx, %ebx
pushq $0x4
popq %rcx
xorl %esi, %esi
callq 0x844c
testq %rax, %rax
je 0x49e3
movq %rax, %r14
movq %rax, %rdi
callq 0x7dc8
movq %rax, %r13
leaq 0x18(%rsp), %rsi
movq %rax, %rdi
callq 0x3430
testl %eax, %eax
je 0x49f7
movq %r14, %rdi
callq 0x8047
xorl %ebx, %ebx
movl %ebx, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x48(%rsp), %r12
testq %r12, %r12
je 0x49d9
leaq 0x1(%r12), %rdi
callq 0x3490
testq %rax, %rax
je 0x49d9
movq %rax, %r15
movq %r13, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x3600
testl %eax, %eax
js 0x4a9e
movl %eax, %ebp
movl %eax, %edi
movq %r15, %rsi
movq %r12, %rdx
callq 0x33c0
movq %rax, %rbx
movl %ebp, %edi
callq 0x3320
testl %ebx, %ebx
js 0x4a9e
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
movb $0x0, (%r15,%rbx)
leaq 0x4783(%rip), %r12      # 0x91d5
leaq 0x18(%rsp), %r13
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x33b0
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x54f8
xorl %edi, %edi
movq %r12, %rsi
movq %r13, %rdx
callq 0x33b0
testq %rax, %rax
jne 0x4a6a
movq %r14, %rdi
callq 0x8047
movq %r15, %rdi
callq 0x3740
movb $0x1, %bl
jmp 0x49e3
movq %r15, %rdi
callq 0x3740
jmp 0x49d9