// File: /workspace/github_c_makefile_star2_O3/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
movl $0x0, 0x1bc(%rdi)
movq $0x0, 0x1c8(%rdi)
movb $0x0, 0x1a8(%rdi)
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x3140
leaq 0x180(%r14), %rdi
callq 0x8526
leaq 0x493f(%rip), %rdi      # 0x911f
callq 0x3070
testq %rax, %rax
je 0x4802
movq %rax, %r15
movq %rax, %rdi
movl $0x7, %esi
callq 0x3610
xorl %ebx, %ebx
testl %eax, %eax
cmoveq %r15, %rbx
leaq 0x150(%r14), %rdi
movq %rbx, %rsi
callq 0x5436
movl $0x80800, %edi          # imm = 0x80800
callq 0x36f0
movl %eax, 0x1b0(%r14)
movl $0xffffffff, 0x1b4(%r14) # imm = 0xFFFFFFFF
leaq 0x28(%r14), %rdi
movq %rdi, 0x10(%rsp)
callq 0x6a80
leaq 0x178(%r14), %rbx
leaq 0x8b67(%rip), %rsi      # 0xd3b0
movq %rbx, %rdi
callq 0x55b5
leaq 0x168(%r14), %rdi
movq %rbx, 0x8(%rsp)
movq %rbx, %rsi
callq 0x6e7e
xorl %r12d, %r12d
xorl %eax, %eax
callq 0x5ebc
movq %rax, %r15
movq %rax, 0xe0(%r14)
movq 0x8758(%rip), %rbx      # 0xcfd8
movl (%rbx), %esi
movl $0x1, %edi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x3030
movq %rax, %r13
movq %rax, 0xe8(%r14)
movl (%rbx), %esi
movq 0x873d(%rip), %rbp      # 0xcfe0
movl (%rbp), %edx
decl %edx
movl $0x1, %edi
xorl %ecx, %ecx
callq 0x3030
movq %rax, 0xf0(%r14)
testq %rax, %rax
je 0x48ee
testq %r13, %r13
setne %cl
testq %r15, %r15
setne %r12b
andb %cl, %r12b
movq %rax, %rdi
movl $0x1, %esi
callq 0x3360
movq 0xf0(%r14), %rdi
movl $0x1, %esi
callq 0x3060
leaq 0xf8(%r14), %rdi
movl (%rbp), %edx
decl %edx
movl (%rbx), %ecx
xorl %esi, %esi
callq 0x5e2b
movq %rbp, %r15
movl %eax, %ebp
leaq 0x140(%r14), %r13
movl $0x1000, %esi           # imm = 0x1000
movq %r13, %rdi
callq 0x8352
movq %rbx, %rcx
movl %eax, %ebx
movl (%rcx), %r8d
movl (%r15), %r9d
addl $-0x2, %r9d
movq %r14, %rdi
movq 0x10(%rsp), %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x7ee0
testb %al, %al
je 0x4a36
testb %bl, %bl
je 0x4a36
testb %bpl, %bpl
movl $0x0, %r15d
je 0x4a39
testb %r12b, %r12b
je 0x4a39
movq %r13, %rdi
callq 0x8135
testb %al, %al
je 0x4a36
xorl %r15d, %r15d
movq %r14, %rdi
xorl %esi, %esi
callq 0x4b03
testb %al, %al
je 0x4a39
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
callq 0x3400
movq %rbx, %rdi
movl $0x1c, %esi
callq 0x36e0
movq %rbx, %rdi
movl $0x11, %esi
callq 0x36e0
movq %rbx, %rdi
movl $0xe, %esi
callq 0x36e0
xorl %r15d, %r15d
xorl %edi, %edi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x30a0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rbx, %rsi
movl $0x80000, %edx          # imm = 0x80000
callq 0x3300
movl %eax, 0x1ac(%r14)
cmpl $-0x1, %eax
je 0x4a39
leaq 0x475c(%rip), %rdi      # 0x9150
leaq 0x47d7(%rip), %rdx      # 0x91d2
xorl %r15d, %r15d
xorl %esi, %esi
movl $0x4, %ecx
callq 0x8770
testq %rax, %rax
je 0x4a39
movq %rax, %r14
movq %rax, %rdi
callq 0x8050
movq %rax, %r13
leaq 0x18(%rsp), %rsi
movq %rax, %rdi
callq 0x3430
testl %eax, %eax
je 0x4a4e
movq %r14, %rdi
callq 0x8337
xorl %r15d, %r15d
movl %r15d, %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 0x4a2e
leaq 0x1(%r12), %rdi
callq 0x3490
testq %rax, %rax
je 0x4a2e
movq %rax, %r15
movq %r13, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x3600
testl %eax, %eax
js 0x4af6
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 0x4af6
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
movb $0x0, (%r15,%rbx)
leaq 0x472c(%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 0x5579
xorl %edi, %edi
movq %r12, %rsi
movq %r13, %rdx
callq 0x33b0
testq %rax, %rax
jne 0x4ac1
movq %r14, %rdi
callq 0x8337
movq %r15, %rdi
callq 0x3740
movb $0x1, %r15b
jmp 0x4a39
movq %r15, %rdi
callq 0x3740
jmp 0x4a2e