// File: /workspace/github_c_makefile_star2_O3/impact-eintr[P]st/x.c
// Function: mousereport
void
mousereport(XEvent *e)
{
	int len, x = evcol(e), y = evrow(e),
	    button = e->xbutton.button, state = e->xbutton.state;
	char buf[40];
	static int ox, oy;

	/* from urxvt */
	if (e->xbutton.type == MotionNotify) {
		if (x == ox && y == oy)
			return;
		if (!IS_SET(MODE_MOUSEMOTION) && !IS_SET(MODE_MOUSEMANY))
			return;
		/* MOUSE_MOTION: no reporting if no button is pressed */
		if (IS_SET(MODE_MOUSEMOTION) && oldbutton == 3)
			return;

		button = oldbutton + 32;
		ox = x;
		oy = y;
	} else {
		if (!IS_SET(MODE_MOUSESGR) && e->xbutton.type == ButtonRelease) {
			button = 3;
		} else {
			button -= Button1;
			if (button >= 7)
				button += 128 - 7;
			else if (button >= 3)
				button += 64 - 3;
		}
		if (e->xbutton.type == ButtonPress) {
			oldbutton = button;
			ox = x;
			oy = y;
		} else if (e->xbutton.type == ButtonRelease) {
			oldbutton = 3;
			/* MODE_MOUSEX10: no button release reporting */
			if (IS_SET(MODE_MOUSEX10))
				return;
			if (button == 64 || button == 65)
				return;
		}
	}

	if (!IS_SET(MODE_MOUSEX10)) {
		button += ((state & ShiftMask  ) ? 4  : 0)
			+ ((state & Mod4Mask   ) ? 8  : 0)
			+ ((state & ControlMask) ? 16 : 0);
	}

	if (IS_SET(MODE_MOUSESGR)) {
		len = snprintf(buf, sizeof(buf), "\033[<%d;%d;%d%c",
				button, x+1, y+1,
				e->xbutton.type == ButtonRelease ? 'm' : 'M');
	} else if (x < 223 && y < 223) {
		len = snprintf(buf, sizeof(buf), "\033[M%c%c%c",
				32+button, 32+x+1, 32+y+1);
	} else {
		return;
	}

	ttywrite(buf, len, 0);
}

// Assembly:
movl 0x40(%rdi), %edx
xorl %ecx, %ecx
subl 0xa71d(%rip), %edx      # 0x17db8
movl $0x0, %eax
js 0xd6af
movl 0xa700(%rip), %eax      # 0x17da8
decl %eax
cmpl %eax, %edx
cmovll %edx, %eax
cltd
idivl 0xa70e(%rip)            # 0x17dc4
movl %eax, %r8d
movl 0x44(%rdi), %eax
subl 0xa6fa(%rip), %eax      # 0x17dbc
js 0xd6d1
movl 0xa6e2(%rip), %ecx      # 0x17dac
decl %ecx
cmpl %ecx, %eax
cmovll %eax, %ecx
subq $0x38, %rsp
movl %ecx, %eax
cltd
idivl 0xa6e2(%rip)            # 0x17dc0
movl 0x50(%rdi), %esi
movl (%rdi), %edx
cmpl $0x6, %edx
jne 0xd733
cmpl 0xa791(%rip), %r8d      # 0x17e80
jne 0xd6fd
cmpl 0xa78d(%rip), %eax      # 0x17e84
je 0xd83b
movl 0xa6c4(%rip), %r9d      # 0x17dc8
testl $0x8010, %r9d           # imm = 0x8010
je 0xd83b
movl %r9d, %edi
shrb $0x4, %dil
movl 0x7fb2(%rip), %ecx      # 0x156d0
cmpl $0x3, %ecx
sete %r10b
testb %r10b, %dil
jne 0xd83b
addl $0x20, %ecx
jmp 0xd787
movl 0xa68e(%rip), %r9d      # 0x17dc8
movl %r9d, %r10d
andl $0x200, %r10d           # imm = 0x200
movl %edx, %r11d
xorl $0x5, %r11d
movl $0x3, %ecx
orl %r10d, %r11d
je 0xd796
movl 0x54(%rdi), %edi
xorl %r10d, %r10d
cmpl $0x4, %edi
setl %r10b
negl %r10d
orl $0x3c, %r10d
cmpl $0x8, %edi
movl $0x78, %ecx
cmovll %r10d, %ecx
addl %edi, %ecx
cmpl $0x5, %edx
je 0xd796
cmpl $0x4, %edx
jne 0xd7b9
movl %ecx, 0x7f49(%rip)      # 0x156d0
movl %r8d, 0xa6f2(%rip)      # 0x17e80
movl %eax, 0xa6f0(%rip)      # 0x17e84
jmp 0xd7b9
movl $0x3, 0x7f30(%rip)      # 0x156d0
btl $0xe, %r9d
jb 0xd83b
movl %ecx, %edi
andl $-0x2, %edi
cmpl $0x40, %edi
je 0xd83b
btl $0xe, %r9d
jb 0xd7d0
movl %esi, %edi
shrl $0x3, %edi
andl $0x8, %edi
andl $0x5, %esi
leal (%rdi,%rsi,4), %esi
addl %esi, %ecx
btl $0x9, %r9d
jb 0xd7fa
cmpl $0xde, %r8d
jg 0xd83b
cmpl $0xde, %eax
jg 0xd83b
addl $0x20, %ecx
addl $0x21, %r8d
addl $0x21, %eax
leaq 0x1b40(%rip), %rdx      # 0xf338
jmp 0xd818
incl %r8d
incl %eax
xorl %esi, %esi
cmpl $0x5, %edx
sete %sil
shll $0x5, %esi
orl $0x4d, %esi
movl %esi, (%rsp)
leaq 0x1b12(%rip), %rdx      # 0xf32a
leaq 0x10(%rsp), %rdi
movl $0x28, %esi
movl %eax, %r9d
xorl %eax, %eax
callq 0x50b0
movslq %eax, %rsi
leaq 0x10(%rsp), %rdi
xorl %edx, %edx
callq 0x6ccb
addq $0x38, %rsp
retq