// File: /workspace/github_c_makefile_star2_O0/garbeam[P]st/x.c
// Function: run
void
run(void)
{
	XEvent ev;
	int w = win.w, h = win.h;
	fd_set rfd;
	int xfd = XConnectionNumber(xw.dpy), xev, blinkset = 0, dodraw = 0;
	int ttyfd;
	struct timespec drawtimeout, *tv = NULL, now, last, lastblink;
	long deltatime;

	/* Waiting for window mapping */
	do {
		XNextEvent(xw.dpy, &ev);
		/*
		 * This XFilterEvent call is required because of XOpenIM. It
		 * does filter out the key event and some client message for
		 * the input method too.
		 */
		if (XFilterEvent(&ev, None))
			continue;
		if (ev.type == ConfigureNotify) {
			w = ev.xconfigure.width;
			h = ev.xconfigure.height;
		}
	} while (ev.type != MapNotify);

	ttyfd = ttynew(opt_line, shell, opt_io, opt_cmd);
	cresize(w, h);

	clock_gettime(CLOCK_MONOTONIC, &last);
	lastblink = last;

	for (xev = actionfps;;) {
		FD_ZERO(&rfd);
		FD_SET(ttyfd, &rfd);
		FD_SET(xfd, &rfd);

		if (pselect(MAX(xfd, ttyfd)+1, &rfd, NULL, NULL, tv, NULL) < 0) {
			if (errno == EINTR)
				continue;
			die("select failed: %s\n", strerror(errno));
		}
		if (FD_ISSET(ttyfd, &rfd)) {
			ttyread();
			if (blinktimeout) {
				blinkset = tattrset(ATTR_BLINK);
				if (!blinkset)
					MODBIT(win.mode, 0, MODE_BLINK);
			}
		}

		if (FD_ISSET(xfd, &rfd))
			xev = actionfps;

		clock_gettime(CLOCK_MONOTONIC, &now);
		drawtimeout.tv_sec = 0;
		drawtimeout.tv_nsec =  (1000 * 1E6)/ xfps;
		tv = &drawtimeout;

		dodraw = 0;
		if (blinktimeout && TIMEDIFF(now, lastblink) > blinktimeout) {
			tsetdirtattr(ATTR_BLINK);
			win.mode ^= MODE_BLINK;
			lastblink = now;
			dodraw = 1;
		}
		deltatime = TIMEDIFF(now, last);
		if (deltatime > 1000 / (xev ? xfps : actionfps)) {
			dodraw = 1;
			last = now;
		}

		if (dodraw) {
			while (XPending(xw.dpy)) {
				XNextEvent(xw.dpy, &ev);
				if (XFilterEvent(&ev, None))
					continue;
				if (handler[ev.type])
					(handler[ev.type])(&ev);
			}

			draw();
			XFlush(xw.dpy);

			if (xev && !FD_ISSET(xfd, &rfd))
				xev--;
			if (!FD_ISSET(ttyfd, &rfd) && !FD_ISSET(xfd, &rfd)) {
				if (blinkset) {
					if (TIMEDIFF(now, lastblink) \
							> blinktimeout) {
						drawtimeout.tv_nsec = 1000;
					} else {
						drawtimeout.tv_nsec = (1E6 * \
							(blinktimeout - \
							TIMEDIFF(now,
								lastblink)));
					}
					drawtimeout.tv_sec = \
					    drawtimeout.tv_nsec / 1E9;
					drawtimeout.tv_nsec %= (long)1E9;
				} else {
					tv = NULL;
				}
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x200, %rsp            # imm = 0x200
movl 0xced7(%rip), %eax      # 0x1b4d8
movl %eax, -0xc4(%rbp)
movl 0xcecf(%rip), %eax      # 0x1b4dc
movl %eax, -0xc8(%rbp)
movq 0xcdc6(%rip), %rdi      # 0x1b3e0
callq 0x5260
movl %eax, -0x14c(%rbp)
movl $0x0, -0x154(%rbp)
movl $0x0, -0x158(%rbp)
movq $0x0, -0x178(%rbp)
movq 0xcd95(%rip), %rdi      # 0x1b3e0
leaq -0xc0(%rbp), %rsi
callq 0x53d0
leaq -0xc0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5300
cmpl $0x0, %eax
je 0xe66e
jmp 0xe691
cmpl $0x16, -0xc0(%rbp)
jne 0xe68f
movl -0x88(%rbp), %eax
movl %eax, -0xc4(%rbp)
movl -0x84(%rbp), %eax
movl %eax, -0xc8(%rbp)
jmp 0xe691
cmpl $0x13, -0xc0(%rbp)
jne 0xe644
movq 0xce7f(%rip), %rdi      # 0x1b520
movq 0x8918(%rip), %rsi      # 0x16fc0
movq 0xce69(%rip), %rdx      # 0x1b518
movq 0xce82(%rip), %rcx      # 0x1b538
callq 0x65d0
movl %eax, -0x15c(%rbp)
movl -0xc4(%rbp), %edi
movl -0xc8(%rbp), %esi
callq 0xf860
movl $0x1, %edi
leaq -0x198(%rbp), %rsi
callq 0x5130
movq -0x198(%rbp), %rax
movq %rax, -0x1a8(%rbp)
movq -0x190(%rbp), %rax
movq %rax, -0x1a0(%rbp)
movl 0x88c3(%rip), %eax      # 0x16fc8
movl %eax, -0x150(%rbp)
jmp 0xe70d
leaq -0x148(%rbp), %rax
movq %rax, -0x1c0(%rbp)
movl $0x0, -0x1b4(%rbp)
movl -0x1b4(%rbp), %eax
cmpq $0x10, %rax
jae 0xe757
movq -0x1c0(%rbp), %rax
movl -0x1b4(%rbp), %ecx
movq $0x0, (%rax,%rcx,8)
movl -0x1b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1b4(%rbp)
jmp 0xe725
jmp 0xe759
movl -0x15c(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, %rcx
movl -0x15c(%rbp), %eax
movl $0x40, %esi
cltd
idivl %esi
cltq
orq -0x148(%rbp,%rax,8), %rcx
movq %rcx, -0x148(%rbp,%rax,8)
movl -0x14c(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, %rcx
movl -0x14c(%rbp), %eax
movl $0x40, %esi
cltd
idivl %esi
cltq
orq -0x148(%rbp,%rax,8), %rcx
movq %rcx, -0x148(%rbp,%rax,8)
movl -0x14c(%rbp), %eax
cmpl -0x15c(%rbp), %eax
jge 0xe7ef
movl -0x15c(%rbp), %eax
movl %eax, -0x1c4(%rbp)
jmp 0xe7fb
movl -0x14c(%rbp), %eax
movl %eax, -0x1c4(%rbp)
movl -0x1c4(%rbp), %edi
addl $0x1, %edi
movq -0x178(%rbp), %r8
leaq -0x148(%rbp), %rsi
xorl %eax, %eax
movl %eax, %r9d
movq %r9, %rdx
movq %r9, %rcx
callq 0x52d0
cmpl $0x0, %eax
jge 0xe853
callq 0x5560
cmpl $0x4, (%rax)
jne 0xe836
jmp 0xe70b
callq 0x5560
movl (%rax), %edi
callq 0x5420
movq %rax, %rsi
leaq 0x31bd(%rip), %rdi      # 0x11a09
movb $0x0, %al
callq 0x5a60
movl -0x15c(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
cltq
movq -0x148(%rbp,%rax,8), %rax
movq %rax, -0x1d0(%rbp)
movl -0x15c(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x1d0(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0xe8d9
callq 0x6cf0
cmpl $0x0, 0x8723(%rip)      # 0x16fcc
je 0xe8d7
movl $0x10, %edi
callq 0x73c0
movl %eax, -0x154(%rbp)
cmpl $0x0, -0x154(%rbp)
jne 0xe8d5
movl 0xcc1e(%rip), %eax      # 0x1b4e8
andl $0xfffff7ff, %eax       # imm = 0xFFFFF7FF
movl %eax, 0xcc13(%rip)      # 0x1b4e8
jmp 0xe8d7
jmp 0xe8d9
movl -0x14c(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
cltq
movq -0x148(%rbp,%rax,8), %rax
movq %rax, -0x1d8(%rbp)
movl -0x14c(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x1d8(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0xe92f
movl 0x869f(%rip), %eax      # 0x16fc8
movl %eax, -0x150(%rbp)
movl $0x1, %edi
leaq -0x188(%rbp), %rsi
callq 0x5130
movq $0x0, -0x170(%rbp)
movl 0x867f(%rip), %eax      # 0x16fd0
cvtsi2sd %rax, %xmm1
movsd 0x342a(%rip), %xmm0     # 0x11d88
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0x168(%rbp)
leaq -0x170(%rbp), %rax
movq %rax, -0x178(%rbp)
movl $0x0, -0x158(%rbp)
cmpl $0x0, 0x863f(%rip)      # 0x16fcc
je 0xea28
movq -0x188(%rbp), %rdx
movq -0x180(%rbp), %rax
movq -0x1a8(%rbp), %rsi
movq -0x1a0(%rbp), %rcx
subq %rsi, %rdx
imulq $0x3e8, %rdx, %rdx      # imm = 0x3E8
cvtsi2sd %rdx, %xmm0
subq %rcx, %rax
cvtsi2sd %rax, %xmm1
movsd 0x33c2(%rip), %xmm2     # 0x11d90
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movl 0x85f0(%rip), %eax      # 0x16fcc
cvtsi2sd %rax, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xea28
movl $0x10, %edi
callq 0x7450
movl 0xcaf1(%rip), %eax      # 0x1b4e8
xorl $0x800, %eax            # imm = 0x800
movl %eax, 0xcae6(%rip)      # 0x1b4e8
movq -0x188(%rbp), %rax
movq %rax, -0x1a8(%rbp)
movq -0x180(%rbp), %rax
movq %rax, -0x1a0(%rbp)
movl $0x1, -0x158(%rbp)
movq -0x188(%rbp), %rax
subq -0x198(%rbp), %rax
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
cvtsi2sd %rax, %xmm0
movq -0x180(%rbp), %rax
subq -0x190(%rbp), %rax
cvtsi2sd %rax, %xmm1
movsd 0x3333(%rip), %xmm2     # 0x11d90
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0x1b0(%rbp)
movq -0x1b0(%rbp), %rax
movq %rax, -0x1e0(%rbp)
cmpl $0x0, -0x150(%rbp)
je 0xea96
movl 0x8542(%rip), %eax      # 0x16fd0
movl %eax, -0x1e4(%rbp)
jmp 0xeaa2
movl 0x852c(%rip), %eax      # 0x16fc8
movl %eax, -0x1e4(%rbp)
movl -0x1e4(%rbp), %ecx
movl $0x3e8, %eax            # imm = 0x3E8
xorl %edx, %edx
divl %ecx
movl %eax, %ecx
movq -0x1e0(%rbp), %rax
movl %ecx, %ecx
cmpq %rcx, %rax
jle 0xeae7
movl $0x1, -0x158(%rbp)
movq -0x188(%rbp), %rax
movq %rax, -0x198(%rbp)
movq -0x180(%rbp), %rax
movq %rax, -0x190(%rbp)
cmpl $0x0, -0x158(%rbp)
je 0xed8b
jmp 0xeaf6
movq 0xc8e3(%rip), %rdi      # 0x1b3e0
callq 0x58d0
cmpl $0x0, %eax
je 0xeb60
movq 0xc8d2(%rip), %rdi      # 0x1b3e0
leaq -0xc0(%rbp), %rsi
callq 0x53d0
leaq -0xc0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5300
cmpl $0x0, %eax
je 0xeb31
jmp 0xeaf6
movslq -0xc0(%rbp), %rcx
leaq 0x84a1(%rip), %rax      # 0x16fe0
cmpq $0x0, (%rax,%rcx,8)
je 0xeb5e
movslq -0xc0(%rbp), %rcx
leaq -0xc0(%rbp), %rdi
leaq 0x8485(%rip), %rax      # 0x16fe0
callq *(%rax,%rcx,8)
jmp 0xeaf6
callq 0x80f0
movq 0xc874(%rip), %rdi      # 0x1b3e0
callq 0x5570
cmpl $0x0, -0x150(%rbp)
je 0xebd3
movl -0x14c(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
cltq
movq -0x148(%rbp,%rax,8), %rax
movq %rax, -0x1f0(%rbp)
movl -0x14c(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x1f0(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
jne 0xebd3
movl -0x150(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x150(%rbp)
movl -0x15c(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
cltq
movq -0x148(%rbp,%rax,8), %rax
movq %rax, -0x1f8(%rbp)
movl -0x15c(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x1f8(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
jne 0xed89
movl -0x14c(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
cltq
movq -0x148(%rbp,%rax,8), %rax
movq %rax, -0x200(%rbp)
movl -0x14c(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x200(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
jne 0xed89
cmpl $0x0, -0x154(%rbp)
je 0xed7c
movq -0x188(%rbp), %rdx
movq -0x180(%rbp), %rax
movq -0x1a8(%rbp), %rsi
movq -0x1a0(%rbp), %rcx
subq %rsi, %rdx
imulq $0x3e8, %rdx, %rdx      # imm = 0x3E8
cvtsi2sd %rdx, %xmm0
subq %rcx, %rax
cvtsi2sd %rax, %xmm1
movsd 0x30d9(%rip), %xmm2     # 0x11d90
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movl 0x8307(%rip), %eax      # 0x16fcc
cvtsi2sd %rax, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xecdd
movq $0x3e8, -0x168(%rbp) # imm = 0x3E8
jmp 0xed41
movl 0x82e9(%rip), %eax      # 0x16fcc
cvtsi2sd %rax, %xmm1
movq -0x188(%rbp), %rax
subq -0x1a8(%rbp), %rax
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
cvtsi2sd %rax, %xmm0
movq -0x180(%rbp), %rax
subq -0x1a0(%rbp), %rax
cvtsi2sd %rax, %xmm2
movsd 0x3073(%rip), %xmm3     # 0x11d90
divsd %xmm3, %xmm2
addsd %xmm2, %xmm0
subsd %xmm0, %xmm1
movsd 0x305f(%rip), %xmm0     # 0x11d90
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0x168(%rbp)
cvtsi2sdq -0x168(%rbp), %xmm0
movsd 0x3036(%rip), %xmm1     # 0x11d88
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0x170(%rbp)
movq -0x168(%rbp), %rax
movl $0x3b9aca00, %ecx       # imm = 0x3B9ACA00
cqto
idivq %rcx
movq %rdx, -0x168(%rbp)
jmp 0xed87
movq $0x0, -0x178(%rbp)
jmp 0xed89
jmp 0xed8b
jmp 0xe70b