// File: /workspace/github_c_makefile_star2_O3/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 0x45ef
leaq 0x30(%rsp), %rcx
movl %eax, 0x4(%rsp)
movl %eax, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x3380
testl %eax, %eax
js 0x45e6
leaq 0x3c(%rsp), %rcx
movl 0x1ac(%rbx), %edx
movl 0x4(%rsp), %edi
movl $0x1, %esi
callq 0x3380
testl %eax, %eax
js 0x45e6
movl 0x1b0(%rbx), %edx
cmpl $-0x1, %edx
je 0x4262
leaq 0x48(%rsp), %rcx
movl 0x4(%rsp), %edi
movl $0x1, %esi
callq 0x3380
testl %eax, %eax
js 0x45e6
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 0xd8(%rsp), %r12
movl 0x4(%rsp), %edi
leaq 0x60(%rsp), %rsi
movl $0xa, %edx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x3580
testl %eax, %eax
js 0x45cf
je 0x45d9
movl %eax, %ebp
xorl %r15d, %r15d
movq %rbp, 0x10(%rsp)
leaq (%r15,%r15,2), %rax
leaq (%rsp,%rax,4), %r13
addq $0x64, %r13
movl (%r13), %edi
testl %edi, %edi
jne 0x42e9
movq %rbx, %rdi
callq 0x4601
movl (%r13), %edi
cmpl 0x1ac(%rbx), %edi
jne 0x4432
movl $0x80, %edx
movq %r12, %rsi
callq 0x33c0
cmpq $0x80, %rax
jne 0x442e
movl 0xd8(%rsp), %eax
cmpl $0xe, %eax
je 0x43fa
cmpl $0x11, %eax
je 0x43d4
cmpl $0x1c, %eax
jne 0x442e
callq 0x36c0
callq 0x3500
movq 0xf0(%rbx), %rdi
movq 0x8c98(%rip), %rbp      # 0xcfe0
movl (%rbp), %esi
decl %esi
xorl %edx, %edx
callq 0x35c0
movq 0xf0(%rbx), %rdi
movq 0x8c76(%rip), %rbp      # 0xcfd8
movl (%rbp), %edx
movl $0x1, %esi
callq 0x3650
movq 0xe8(%rbx), %rdi
movl (%rbp), %edx
movl $0x1, %esi
callq 0x3650
movl (%rbp), %esi
movq 0x8c53(%rip), %rax      # 0xcfe0
movl (%rax), %edx
addl $-0x2, %edx
movq %rbx, %rdi
callq 0x7ebd
movq %rbx, %rdi
callq 0x7bf0
movq 0x8c37(%rip), %rax      # 0xcfe0
movl (%rax), %edx
decl %edx
movl (%rbp), %ecx
movq 0x10(%rsp), %rbp
movq 0x8(%rsp), %rdi
xorl %esi, %esi
callq 0x5d04
movq %rbx, %rdi
callq 0x51f1
cmpl $0x0, 0x1bc(%rbx)
jne 0x442e
jmp 0x4426
movl 0xe0(%rsp), %eax
decl %eax
cmpl $0x2, %eax
ja 0x442e
movl 0xe4(%rsp), %esi
movq 0x18(%rsp), %rdi
leaq 0x2c(%rsp), %rdx
callq 0x84a3
jmp 0x442e
movb $0x0, 0x1a8(%rbx)
movq %r14, %rdi
callq 0x64e3
movq %rbx, %rdi
callq 0x7bf0
cmpl $0x0, 0x1bc(%rbx)
je 0x4426
movq 0x8(%rsp), %rdi
callq 0x55bc
jmp 0x442e
movq %rbx, %rdi
callq 0x4d1e
movl (%r13), %edi
cmpl 0x1b0(%rbx), %edi
jne 0x45c1
movl $0x1000, %edx           # imm = 0x1000
movq %r12, %rsi
callq 0x33c0
testq %rax, %rax
jle 0x45c1
leaq (%rsp,%rax), %r13
addq $0xd8, %r13
movq %r12, %rbp
movl (%r12), %eax
cmpl $-0x1, %eax
jne 0x4477
testb $0x40, 0x5(%r12)
jne 0x45a7
cmpl 0x1b4(%rbx), %eax
jne 0x453b
testb $0x40, 0x4(%r12)
je 0x44c7
movq %r14, %rdi
callq 0x7a7c
testq %rax, %rax
je 0x44c7
movq %rbx, %rdi
callq 0x7eb3
movq %r14, %rdi
movq %rax, %rsi
callq 0x6811
leaq 0x10(%r12), %rdi
movq %rax, %rsi
callq 0x33d0
testl %eax, %eax
jne 0x44c7
movl 0x8(%r12), %eax
movl %eax, 0x1b8(%rbx)
movl 0x4(%r12), %eax
testl $0x240, %eax            # imm = 0x240
je 0x44e2
leaq 0x10(%r12), %rsi
movq %r14, %rdi
callq 0x63af
jmp 0x44f6
testl $0x186, %eax            # imm = 0x186
je 0x44f6
leaq 0x10(%r12), %rsi
movq %r14, %rdi
callq 0x646d
testb $-0x80, 0x4(%r12)
je 0x453b
movl 0x8(%r12), %eax
cmpl 0x1b8(%rbx), %eax
jne 0x453b
movq %r14, %rdi
callq 0x64e3
leaq 0x10(%r12), %rsi
movq %rbx, %rdi
callq 0x50aa
movl $0x0, 0x1b8(%rbx)
cmpl $0x0, 0x1bc(%rbx)
jne 0x453b
movq %rbx, %rdi
callq 0x4d1e
movl 0xc(%r12), %eax
addq %rax, %r12
addq $0x10, %r12
cmpq %r13, %r12
jb 0x4462
cmpl $0x1, 0x1bc(%rbx)
jne 0x4563
movq 0x8(%rsp), %rdi
callq 0x55bc
cmpb $0x0, 0x1a8(%rbx)
movq %rbp, %r12
movq 0x10(%rsp), %rbp
jne 0x45c1
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 0x45c1
movq %rbx, %rdi
callq 0x4f73
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4b03
movq %rbp, %r12
movq 0x10(%rsp), %rbp
incq %r15
cmpq %rbp, %r15
jne 0x42c9
jmp 0x45d9
callq 0x30d0
cmpl $0x4, (%rax)
jne 0x45e6
cmpb $0x0, 0x1c0(%rbx)
jne 0x4299
movl 0x4(%rsp), %edi
callq 0x3320
addq $0x10d8, %rsp           # imm = 0x10D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq