// File: /workspace/github_c_makefile_star2_O1/cglindkamp[P]dfm/src/application.c
// Function: application_run
void application_run(struct application *app)
{
	struct epoll_event pollfds[3] = {
		{ .events = EPOLLIN, .data.fd = 0, },
		{ .events = EPOLLIN, .data.fd = app->signal_fd, },
		{ .events = EPOLLIN, .data.fd = app->inotify_fd, },
	};
	struct epoll_event events[10];

	int epollfd = epoll_create1(EPOLL_CLOEXEC);
	if(epollfd < 0)
		return;

	if(epoll_ctl(epollfd, EPOLL_CTL_ADD, 0, &pollfds[0]) < 0)
		goto out;
	if(epoll_ctl(epollfd, EPOLL_CTL_ADD, app->signal_fd, &pollfds[1]) < 0)
		goto out;
	if(app->inotify_fd != -1) {
		if(epoll_ctl(epollfd, EPOLL_CTL_ADD, app->inotify_fd, &pollfds[2]) < 0)
			goto out;
	}

	app->running = true;
	while(app->running) {
		int ret = epoll_wait(epollfd, events, sizeof(events)/sizeof(events[0]), -1);
		if(ret < 0) {
			if(errno == EINTR)
				continue;
			else
				goto out;
		}
		for(int i = 0; i < ret; i++) {
			if(events[i].data.fd == 0)
				handle_stdin(app);
			if(events[i].data.fd == app->signal_fd)
				handle_signal(app);
			if(events[i].data.fd == app->inotify_fd)
				handle_inotify(app);
		}
	}
out:
	close(epollfd);
	return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10d8, %rsp           # imm = 0x10D8
movq %rdi, %rbx
movq $0x1, 0x30(%rsp)
movl $0x1, %eax
movl %eax, 0x3c(%rsp)
movl 0x1ac(%rdi), %ecx
movl %ecx, 0x40(%rsp)
movl %eax, 0x48(%rsp)
movl 0x1b0(%rdi), %eax
movl %eax, 0x4c(%rsp)
movl $0x80000, %edi          # imm = 0x80000
callq 0x36d0
testl %eax, %eax
js 0x4615
movl %eax, %ebp
leaq 0x30(%rsp), %rcx
movl %eax, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x3380
testl %eax, %eax
js 0x460e
leaq 0x3c(%rsp), %rcx
movl 0x1ac(%rbx), %edx
movl %ebp, %edi
movl $0x1, %esi
callq 0x3380
testl %eax, %eax
js 0x460e
movl 0x1b0(%rbx), %edx
cmpl $-0x1, %edx
je 0x425c
leaq 0x48(%rsp), %rcx
movl %ebp, %edi
movl $0x1, %esi
callq 0x3380
testl %eax, %eax
js 0x460e
movb $0x1, 0x1c0(%rbx)
leaq 0x28(%rbx), %r14
leaq 0xf8(%rbx), %rax
movq %rax, 0x8(%rsp)
leaq 0x180(%rbx), %rax
movq %rax, 0x18(%rsp)
leaq 0x188(%rbx), %rax
movq %rax, 0x20(%rsp)
leaq 0x60(%rsp), %r15
movl %ebp, 0x14(%rsp)
movl %ebp, %edi
movq %r15, %rsi
movl $0xa, %edx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x3580
testl %eax, %eax
js 0x45df
xorl %ecx, %ecx
testl %eax, %eax
je 0x45cd
movl %eax, %ebp
xorl %r15d, %r15d
leaq (%r15,%r15,2), %r12
cmpl $0x0, 0x64(%rsp,%r12,4)
jne 0x42d3
movq %rbx, %rdi
callq 0x4627
leaq (%rsp,%r12,4), %r13
addq $0x64, %r13
movl 0x1ac(%rbx), %edi
cmpl %edi, (%r13)
jne 0x4429
movl $0x80, %edx
leaq 0xd8(%rsp), %rsi
callq 0x33c0
cmpq $0x80, %rax
jne 0x4429
movl 0xd8(%rsp), %eax
cmpl $0xe, %eax
je 0x43f5
cmpl $0x11, %eax
je 0x43cf
cmpl $0x1c, %eax
jne 0x4429
callq 0x36c0
callq 0x3500
movq 0xf0(%rbx), %rdi
movq 0x8c9d(%rip), %r12      # 0xcfe0
movl (%r12), %esi
decl %esi
xorl %edx, %edx
callq 0x35c0
movq 0xf0(%rbx), %rdi
movq 0x8c7a(%rip), %r12      # 0xcfd8
movl (%r12), %edx
movl $0x1, %esi
callq 0x3650
movq 0xe8(%rbx), %rdi
movl (%r12), %edx
movl $0x1, %esi
callq 0x3650
movl (%r12), %esi
movq 0x8c54(%rip), %rax      # 0xcfe0
movl (%rax), %edx
addl $-0x2, %edx
movq %rbx, %rdi
callq 0x805d
movq %rbx, %rdi
callq 0x7d78
movq 0x8c38(%rip), %rax      # 0xcfe0
movl (%rax), %edx
decl %edx
movl (%r12), %ecx
movq 0x8(%rsp), %rdi
xorl %esi, %esi
callq 0x5cfb
movq %rbx, %rdi
callq 0x5256
cmpl $0x0, 0x1bc(%rbx)
jne 0x4429
jmp 0x4421
movl 0xe0(%rsp), %eax
decl %eax
cmpl $0x2, %eax
ja 0x4429
movl 0xe4(%rsp), %esi
movq 0x18(%rsp), %rdi
leaq 0x2c(%rsp), %rdx
callq 0x85e9
jmp 0x4429
movb $0x0, 0x1a8(%rbx)
movq %r14, %rdi
callq 0x65d7
movq %rbx, %rdi
callq 0x7d78
cmpl $0x0, 0x1bc(%rbx)
je 0x4421
movq 0x8(%rsp), %rdi
callq 0x5624
jmp 0x4429
movq %rbx, %rdi
callq 0x4d86
movl 0x1b0(%rbx), %edi
cmpl %edi, (%r13)
jne 0x45b6
movl $0x1000, %edx           # imm = 0x1000
leaq 0xd8(%rsp), %rsi
callq 0x33c0
testq %rax, %rax
jle 0x45b6
leaq (%rsp,%rax), %r13
addq $0xd8, %r13
leaq 0xd8(%rsp), %r12
movl (%r12), %eax
cmpl $-0x1, %eax
jne 0x447c
testb $0x40, 0x5(%r12)
jne 0x45a4
cmpl 0x1b4(%rbx), %eax
jne 0x4540
testb $0x40, 0x4(%r12)
je 0x44cc
movq %r14, %rdi
callq 0x7c0c
testq %rax, %rax
je 0x44cc
movq %rbx, %rdi
callq 0x8053
movq %r14, %rdi
movq %rax, %rsi
callq 0x6899
leaq 0x10(%r12), %rdi
movq %rax, %rsi
callq 0x33d0
testl %eax, %eax
jne 0x44cc
movl 0x8(%r12), %eax
movl %eax, 0x1b8(%rbx)
movl 0x4(%r12), %eax
testl $0x240, %eax            # imm = 0x240
je 0x44e7
leaq 0x10(%r12), %rsi
movq %r14, %rdi
callq 0x6454
jmp 0x44fb
testl $0x186, %eax            # imm = 0x186
je 0x44fb
leaq 0x10(%r12), %rsi
movq %r14, %rdi
callq 0x6561
testb $-0x80, 0x4(%r12)
je 0x4540
movl 0x8(%r12), %eax
cmpl 0x1b8(%rbx), %eax
jne 0x4540
movq %r14, %rdi
callq 0x65d7
leaq 0x10(%r12), %rsi
movq %rbx, %rdi
callq 0x5112
movl $0x0, 0x1b8(%rbx)
cmpl $0x0, 0x1bc(%rbx)
jne 0x4540
movq %rbx, %rdi
callq 0x4d86
movl 0xc(%r12), %eax
addq %rax, %r12
addq $0x10, %r12
cmpq %r13, %r12
jb 0x4467
cmpl $0x1, 0x1bc(%rbx)
jne 0x4568
movq 0x8(%rsp), %rdi
callq 0x5624
cmpb $0x0, 0x1a8(%rbx)
jne 0x45b6
movq $0x0, 0x198(%rbx)
movq $0xc350, 0x1a0(%rbx) # imm = 0xC350
movq 0x20(%rsp), %rsi
xorps %xmm0, %xmm0
movups %xmm0, (%rsi)
xorl %edi, %edi
xorl %edx, %edx
callq 0x3540
movb $0x1, 0x1a8(%rbx)
jmp 0x45b6
movq %rbx, %rdi
callq 0x4fdb
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4b4e
incq %r15
cmpq %rbp, %r15
jne 0x42bf
movl 0x14(%rsp), %ebp
leaq 0x60(%rsp), %r15
xorl %ecx, %ecx
movl %ecx, %eax
leaq 0x4a4a(%rip), %rcx      # 0x9020
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
callq 0x30d0
xorl %ecx, %ecx
cmpl $0x4, (%rax)
sete %cl
orl $0x2, %ecx
movl %ecx, %eax
leaq 0x4a28(%rip), %rcx      # 0x9020
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpb $0x0, 0x1c0(%rbx)
jne 0x4294
movl %ebp, %edi
callq 0x3320
addq $0x10d8, %rsp           # imm = 0x10D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq