// File: /workspace/github_c_makefile_star2_O1/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 0xaa3f(%rip), %edx      # 0x17dc8
movl $0x0, %eax
js 0xd39d
movl 0xaa22(%rip), %eax      # 0x17db8
decl %eax
cmpl %eax, %edx
cmovll %edx, %eax
cltd
idivl 0xaa30(%rip)            # 0x17dd4
movl %eax, %r8d
movl 0x44(%rdi), %eax
subl 0xaa1c(%rip), %eax      # 0x17dcc
js 0xd3bf
movl 0xaa04(%rip), %ecx      # 0x17dbc
decl %ecx
cmpl %ecx, %eax
cmovll %eax, %ecx
subq $0x38, %rsp
movl %ecx, %eax
cltd
idivl 0xaa04(%rip)            # 0x17dd0
movl 0x50(%rdi), %esi
movl (%rdi), %edx
cmpl $0x6, %edx
jne 0xd41c
cmpl 0xaab3(%rip), %r8d      # 0x17e90
jne 0xd3eb
cmpl 0xaaaf(%rip), %eax      # 0x17e94
je 0xd527
movl 0xa9e7(%rip), %edi      # 0x17dd8
testl $0x8010, %edi           # imm = 0x8010
je 0xd527
shrb $0x4, %dil
movl 0x82d9(%rip), %ecx      # 0x156e0
cmpl $0x3, %ecx
sete %r9b
testb %r9b, %dil
jne 0xd527
addl $0x20, %ecx
jmp 0xd46b
movl 0xa9b5(%rip), %r9d      # 0x17dd8
movl %r9d, %r10d
andl $0x200, %r10d           # imm = 0x200
movl %edx, %r11d
xorl $0x5, %r11d
movl $0x3, %ecx
orl %r10d, %r11d
je 0xd45b
movl 0x54(%rdi), %ecx
cmpl $0x8, %ecx
jl 0xd44b
addl $0x78, %ecx
jmp 0xd45b
xorl %edi, %edi
cmpl $0x4, %ecx
setl %dil
negl %edi
orl $0x3c, %edi
addl %edi, %ecx
cmpl $0x5, %edx
je 0xd47a
cmpl $0x4, %edx
jne 0xd49d
movl %ecx, 0x8275(%rip)      # 0x156e0
movl %r8d, 0xaa1e(%rip)      # 0x17e90
movl %eax, 0xaa1c(%rip)      # 0x17e94
jmp 0xd49d
movl $0x3, 0x825c(%rip)      # 0x156e0
btl $0xe, %r9d
jb 0xd527
movl %ecx, %edi
andl $-0x2, %edi
cmpl $0x40, %edi
je 0xd527
movl 0xa935(%rip), %edi      # 0x17dd8
btl $0xe, %edi
jb 0xd4bd
movl %esi, %r9d
shrl $0x3, %r9d
andl $0x8, %r9d
andl $0x5, %esi
leal (%r9,%rsi,4), %esi
addl %esi, %ecx
btl $0x9, %edi
jb 0xd4e6
cmpl $0xde, %r8d
jg 0xd527
cmpl $0xde, %eax
jg 0xd527
addl $0x20, %ecx
addl $0x21, %r8d
addl $0x21, %eax
leaq 0x1e34(%rip), %rdx      # 0xf318
jmp 0xd504
incl %r8d
incl %eax
xorl %esi, %esi
cmpl $0x5, %edx
sete %sil
shll $0x5, %esi
orl $0x4d, %esi
movl %esi, (%rsp)
leaq 0x1e06(%rip), %rdx      # 0xf30a
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 0x6bde
addq $0x38, %rsp
retq