// File: /workspace/github_c_makefile_star2_O2/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)
pushq $0x1
popq %rax
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 0x45b2
pushq $0x1
popq %rsi
leaq 0x30(%rsp), %rcx
movl %eax, 0x4(%rsp)
movl %eax, %edi
xorl %edx, %edx
callq 0x3380
testl %eax, %eax
js 0x45a9
leaq 0x3c(%rsp), %rcx
movl 0x1ac(%rbx), %edx
pushq $0x1
popq %rsi
movl 0x4(%rsp), %edi
callq 0x3380
testl %eax, %eax
js 0x45a9
movl 0x1b0(%rbx), %edx
cmpl $-0x1, %edx
je 0x4222
leaq 0x48(%rsp), %rcx
pushq $0x1
popq %rsi
movl 0x4(%rsp), %edi
callq 0x3380
testl %eax, %eax
js 0x45a9
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)
movb $0x1, %al
leaq 0xd8(%rsp), %r12
testb $0x1, %al
je 0x45a9
movl 0x4(%rsp), %edi
leaq 0x60(%rsp), %rsi
pushq $0xa
popq %rdx
pushq $-0x1
popq %rcx
callq 0x3580
testl %eax, %eax
js 0x4594
movl %eax, %ebp
xorl %r15d, %r15d
movq %rbp, 0x10(%rsp)
cmpq %rbp, %r15
je 0x459e
imulq $0xc, %r15, %rax
leaq (%rsp,%rax), %r13
addq $0x64, %r13
movl (%r13), %edi
testl %edi, %edi
jne 0x42b2
movq %rbx, %rdi
callq 0x45c4
movl (%r13), %edi
cmpl 0x1ac(%rbx), %edi
jne 0x440a
movl $0x80, %edx
movq %r12, %rsi
callq 0x33c0
cmpq $0x80, %rax
jne 0x4406
movl 0xd8(%rsp), %eax
cmpl $0xe, %eax
je 0x43d2
cmpl $0x11, %eax
je 0x43ac
cmpl $0x1c, %eax
jne 0x4406
callq 0x36c0
callq 0x3500
movq 0xf0(%rbx), %rdi
movq 0x8ccf(%rip), %rbp      # 0xcfe0
movl (%rbp), %esi
decl %esi
xorl %edx, %edx
callq 0x35c0
movq 0xf0(%rbx), %rdi
movq 0x8cad(%rip), %rbp      # 0xcfd8
movl (%rbp), %edx
pushq $0x1
popq %rbp
movl %ebp, %esi
callq 0x3650
movq 0xe8(%rbx), %rdi
movq 0x8c92(%rip), %rax      # 0xcfd8
movl (%rax), %edx
movl %ebp, %esi
movq 0x10(%rsp), %rbp
callq 0x3650
movq 0x8c7d(%rip), %rax      # 0xcfd8
movl (%rax), %esi
movq 0x8c7c(%rip), %rax      # 0xcfe0
movl (%rax), %edx
addl $-0x2, %edx
movq %rbx, %rdi
callq 0x7c2a
movq %rbx, %rdi
callq 0x7974
movq 0x8c60(%rip), %rax      # 0xcfe0
movl (%rax), %edx
decl %edx
movq 0x8c4d(%rip), %rax      # 0xcfd8
movl (%rax), %ecx
movq 0x8(%rsp), %rdi
xorl %esi, %esi
callq 0x5bdd
movq %rbx, %rdi
callq 0x5196
cmpl $0x0, 0x1bc(%rbx)
jne 0x4406
jmp 0x43fe
movl 0xe0(%rsp), %eax
decl %eax
cmpl $0x2, %eax
ja 0x4406
movl 0xe4(%rsp), %esi
movq 0x18(%rsp), %rdi
leaq 0x2c(%rsp), %rdx
callq 0x819e
jmp 0x4406
movb $0x0, 0x1a8(%rbx)
movq %r14, %rdi
callq 0x640e
movq %rbx, %rdi
callq 0x7974
cmpl $0x0, 0x1bc(%rbx)
je 0x43fe
movq 0x8(%rsp), %rdi
callq 0x5538
jmp 0x4406
movq %rbx, %rdi
callq 0x4cc1
movl (%r13), %edi
cmpl 0x1b0(%rbx), %edi
jne 0x458c
movl $0x1000, %edx           # imm = 0x1000
movq %r12, %rsi
callq 0x33c0
testq %rax, %rax
jle 0x458c
leaq (%rsp,%rax), %r13
addq $0xd8, %r13
movq %r12, %rbp
cmpq %r13, %r12
jae 0x4528
movl (%r12), %eax
cmpl $-0x1, %eax
jne 0x4458
testb $0x40, 0x5(%r12)
jne 0x457c
cmpl 0x1b4(%rbx), %eax
jne 0x4517
testb $0x40, 0x4(%r12)
je 0x44a8
movq %r14, %rdi
callq 0x780c
testq %rax, %rax
je 0x44a8
movq %rbx, %rdi
callq 0x7c20
movq %r14, %rdi
movq %rax, %rsi
callq 0x66b1
leaq 0x10(%r12), %rdi
movq %rax, %rsi
callq 0x33d0
testl %eax, %eax
jne 0x44a8
movl 0x8(%r12), %eax
movl %eax, 0x1b8(%rbx)
movl 0x4(%r12), %eax
testw $0x240, %ax             # imm = 0x240
je 0x44c2
leaq 0x10(%r12), %rsi
movq %r14, %rdi
callq 0x62b2
jmp 0x44d5
testw $0x186, %ax             # imm = 0x186
je 0x44d5
leaq 0x10(%r12), %rsi
movq %r14, %rdi
callq 0x639c
testb $-0x80, 0x4(%r12)
je 0x4517
movl 0x8(%r12), %eax
cmpl 0x1b8(%rbx), %eax
jne 0x4517
movq %r14, %rdi
callq 0x640e
leaq 0x10(%r12), %rsi
movq %rbx, %rdi
callq 0x503e
andl $0x0, 0x1b8(%rbx)
cmpl $0x0, 0x1bc(%rbx)
jne 0x4517
movq %rbx, %rdi
callq 0x4cc1
movl 0xc(%r12), %eax
addq %rax, %r12
addq $0x10, %r12
jmp 0x443a
cmpl $0x1, 0x1bc(%rbx)
movq %rbp, %r12
jne 0x453e
movq 0x8(%rsp), %rdi
callq 0x5538
cmpb $0x0, 0x1a8(%rbx)
movq 0x10(%rsp), %rbp
jne 0x458c
andq $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 0x458c
movq %rbx, %rdi
callq 0x50db
movq %rbp, %r12
movq 0x10(%rsp), %rbp
incq %r15
jmp 0x4289
callq 0x30d0
cmpl $0x4, (%rax)
jne 0x45a9
movb 0x1c0(%rbx), %al
jmp 0x425b
movl 0x4(%rsp), %edi
callq 0x3320
addq $0x10d8, %rsp           # imm = 0x10D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq