// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movl $0x1, -0x30(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x1, -0x24(%rbp)
movq -0x8(%rbp), %rax
movl 0x1ac(%rax), %eax
movl %eax, -0x20(%rbp)
movl $0x1, -0x18(%rbp)
movq -0x8(%rbp), %rax
movl 0x1b0(%rax), %eax
movl %eax, -0x14(%rbp)
movl $0x80000, %edi          # imm = 0x80000
callq 0x36d0
movl %eax, -0xb4(%rbp)
cmpl $0x0, -0xb4(%rbp)
jge 0x4723
jmp 0x48c4
movl -0xb4(%rbp), %edi
leaq -0x30(%rbp), %rcx
movl $0x1, %esi
xorl %edx, %edx
callq 0x3380
cmpl $0x0, %eax
jge 0x4743
jmp 0x48b9
movl -0xb4(%rbp), %edi
movq -0x8(%rbp), %rax
movl 0x1ac(%rax), %edx
leaq -0x30(%rbp), %rcx
addq $0xc, %rcx
movl $0x1, %esi
callq 0x3380
cmpl $0x0, %eax
jge 0x476f
jmp 0x48b9
movq -0x8(%rbp), %rax
cmpl $-0x1, 0x1b0(%rax)
je 0x47aa
movl -0xb4(%rbp), %edi
movq -0x8(%rbp), %rax
movl 0x1b0(%rax), %edx
leaq -0x30(%rbp), %rcx
addq $0x18, %rcx
movl $0x1, %esi
callq 0x3380
cmpl $0x0, %eax
jge 0x47a8
jmp 0x48b9
jmp 0x47aa
movq -0x8(%rbp), %rax
movb $0x1, 0x1c0(%rax)
movq -0x8(%rbp), %rax
testb $0x1, 0x1c0(%rax)
je 0x48b7
movl -0xb4(%rbp), %edi
leaq -0xb0(%rbp), %rsi
movl $0xa, %edx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x3580
movl %eax, -0xb8(%rbp)
cmpl $0x0, -0xb8(%rbp)
jge 0x4802
callq 0x30d0
cmpl $0x4, (%rax)
jne 0x47fd
jmp 0x47b5
jmp 0x48b9
movl $0x0, -0xbc(%rbp)
movl -0xbc(%rbp), %eax
cmpl -0xb8(%rbp), %eax
jge 0x48b2
movslq -0xbc(%rbp), %rcx
leaq -0xb0(%rbp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x4(%rax)
jne 0x4842
movq -0x8(%rbp), %rdi
callq 0x48d0
movslq -0xbc(%rbp), %rcx
leaq -0xb0(%rbp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x1ac(%rcx), %eax
jne 0x486f
movq -0x8(%rbp), %rdi
callq 0x4ae0
movslq -0xbc(%rbp), %rcx
leaq -0xb0(%rbp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x1b0(%rcx), %eax
jne 0x489c
movq -0x8(%rbp), %rdi
callq 0x4cb0
jmp 0x489e
movl -0xbc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xbc(%rbp)
jmp 0x480c
jmp 0x47b5
jmp 0x48b9
movl -0xb4(%rbp), %edi
callq 0x3320
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax)