// File: /workspace/github_c_makefile_star2_O0/cglindkamp[P]dfm/src/application.c
// Function: handle_inotify
static void handle_inotify(struct application *app)
{
	char buf[4096]
		__attribute__((aligned(__alignof(struct inotify_event))));
	char *ptr;
	const struct inotify_event *event;
	ssize_t len;

	len = read(app->inotify_fd, &buf, sizeof(buf));
	if(len <= 0)
		return;

	for(ptr = buf; ptr < buf + len; ptr += sizeof(struct inotify_event) + event->len) {
		event = (const struct inotify_event *)ptr;

		if(event->wd == -1 && event->mask & IN_Q_OVERFLOW) {
			reload_directory(app);
			return;
		}
		if(event->wd != app->inotify_watch)
			continue;

		if(event->mask & IN_MOVED_FROM && listmodel_count(&app->model.listmodel) != 0) {
			size_t index = listview_getindex(&app->view);
			const char *filename = dirmodel_getfilename(&app->model, index);
			if(strcmp(event->name, filename) == 0)
				app->inotify_cookie = event->cookie;
		}

		if(event->mask & (IN_DELETE | IN_MOVED_FROM)) {
			dirmodel_notify_file_deleted(&app->model, event->name);
		} else if(event->mask & (IN_CREATE | IN_MOVED_TO | IN_MODIFY | IN_ATTRIB)) {
			(void)dirmodel_notify_file_added_or_changed(&app->model, event->name);
		}

		if(event->mask & IN_MOVED_TO && event->cookie == app->inotify_cookie) {
			dirmodel_notify_flush(&app->model);
			select_filename(app, event->name);
			app->inotify_cookie = 0;
			if(app->mode == MODE_NORMAL)
				refresh_statusbar(app);
		}
	}
	if(app->mode == MODE_COMMAND)
		commandline_updatecursor(&app->commandline);

	if(!app->timer_running) {
		app->refresh_timer.it_value.tv_sec = 0;
		app->refresh_timer.it_value.tv_usec = 50000;
		app->refresh_timer.it_interval.tv_sec = 0;
		app->refresh_timer.it_interval.tv_usec = 0;
		setitimer(ITIMER_REAL, &app->refresh_timer, NULL);
		app->timer_running = true;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1030, %rsp           # imm = 0x1030
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl 0x1b0(%rax), %edi
leaq -0x1008(%rbp), %rsi
movl $0x1000, %edx           # imm = 0x1000
callq 0x33c0
movq %rax, -0x1020(%rbp)
cmpq $0x0, -0x1020(%rbp)
jg 0x4cf0
jmp 0x4f6b
leaq -0x1008(%rbp), %rax
movq %rax, -0x1010(%rbp)
movq -0x1010(%rbp), %rax
leaq -0x1008(%rbp), %rcx
addq -0x1020(%rbp), %rcx
cmpq %rcx, %rax
jae 0x4ee4
movq -0x1010(%rbp), %rax
movq %rax, -0x1018(%rbp)
movq -0x1018(%rbp), %rax
cmpl $-0x1, (%rax)
jne 0x4d58
movq -0x1018(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
je 0x4d58
movq -0x8(%rbp), %rdi
callq 0x5b70
jmp 0x4f6b
movq -0x1018(%rbp), %rax
movl (%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x1b4(%rcx), %eax
je 0x4d72
jmp 0x4ec3
movq -0x1018(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x4df4
movq -0x8(%rbp), %rdi
addq $0x28, %rdi
callq 0xa660
cmpq $0x0, %rax
je 0x4df4
movq -0x8(%rbp), %rdi
callq 0xafa0
movq %rax, -0x1028(%rbp)
movq -0x8(%rbp), %rdi
addq $0x28, %rdi
movq -0x1028(%rbp), %rsi
callq 0x8250
movq %rax, -0x1030(%rbp)
movq -0x1018(%rbp), %rdi
addq $0x10, %rdi
movq -0x1030(%rbp), %rsi
callq 0x33d0
cmpl $0x0, %eax
jne 0x4df2
movq -0x1018(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1b8(%rax)
jmp 0x4df4
movq -0x1018(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x240, %eax            # imm = 0x240
cmpl $0x0, %eax
je 0x4e22
movq -0x8(%rbp), %rdi
addq $0x28, %rdi
movq -0x1018(%rbp), %rsi
addq $0x10, %rsi
callq 0x7e50
jmp 0x4e50
movq -0x1018(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x186, %eax            # imm = 0x186
cmpl $0x0, %eax
je 0x4e4e
movq -0x8(%rbp), %rdi
addq $0x28, %rdi
movq -0x1018(%rbp), %rsi
addq $0x10, %rsi
callq 0x7fc0
jmp 0x4e50
movq -0x1018(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x4ec1
movq -0x1018(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x1b8(%rcx), %eax
jne 0x4ec1
movq -0x8(%rbp), %rdi
addq $0x28, %rdi
callq 0x80a0
movq -0x8(%rbp), %rdi
movq -0x1018(%rbp), %rsi
addq $0x10, %rsi
callq 0x5a80
movq -0x8(%rbp), %rax
movl $0x0, 0x1b8(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x1bc(%rax)
jne 0x4ebf
movq -0x8(%rbp), %rdi
callq 0x5560
jmp 0x4ec1
jmp 0x4ec3
movq -0x1018(%rbp), %rax
movl 0xc(%rax), %eax
addq $0x10, %rax
addq -0x1010(%rbp), %rax
movq %rax, -0x1010(%rbp)
jmp 0x4cfe
movq -0x8(%rbp), %rax
cmpl $0x1, 0x1bc(%rax)
jne 0x4f01
movq -0x8(%rbp), %rdi
addq $0xf8, %rdi
callq 0x6540
movq -0x8(%rbp), %rax
testb $0x1, 0x1a8(%rax)
jne 0x4f6b
movq -0x8(%rbp), %rax
movq $0x0, 0x198(%rax)
movq -0x8(%rbp), %rax
movq $0xc350, 0x1a0(%rax) # imm = 0xC350
movq -0x8(%rbp), %rax
movq $0x0, 0x188(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x190(%rax)
movq -0x8(%rbp), %rsi
addq $0x188, %rsi            # imm = 0x188
xorl %edi, %edi
xorl %eax, %eax
movl %eax, %edx
callq 0x3540
movq -0x8(%rbp), %rax
movb $0x1, 0x1a8(%rax)
addq $0x1030, %rsp           # imm = 0x1030
popq %rbp
retq
nopw %cs:(%rax,%rax)