// File: /workspace/github_c_makefile_star2_O2/jaimecgomezz[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 >= 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:
pushq %r14
pushq %rbx
subq $0x38, %rsp
movq %rdi, %r14
callq 0xca6a
movl %eax, %ebx
movq %r14, %rdi
callq 0xca8c
movl 0x50(%r14), %esi
movl (%r14), %edx
cmpl $0x6, %edx
jne 0xc8da
cmpl 0xa5c7(%rip), %ebx      # 0x16e60
jne 0xc8a7
cmpl 0xa5c3(%rip), %eax      # 0x16e64
je 0xc9d5
movl 0xa4fb(%rip), %edi      # 0x16da8
testw $0x8010, %di            # imm = 0x8010
je 0xc9d5
movl %edi, %r8d
shrb $0x4, %r8b
movl 0x7dfb(%rip), %ecx      # 0x146c0
cmpl $0x3, %ecx
sete %r9b
testb %r9b, %r8b
jne 0xc9d5
addl $0x20, %ecx
jmp 0xc917
movl 0x54(%r14), %ecx
movl 0xa4c4(%rip), %edi      # 0x16da8
xorl %r8d, %r8d
cmpl $0x4, %ecx
setl %r8b
negl %r8d
orl $0x3c, %r8d
addl %ecx, %r8d
btl $0x9, %edi
pushq $0x3
popq %rcx
cmovbl %r8d, %ecx
cmpl $0x5, %edx
cmovnel %r8d, %ecx
je 0xc925
cmpl $0x4, %edx
jne 0xc94a
movl %ecx, 0x7da9(%rip)      # 0x146c0
movl %ebx, 0xa543(%rip)      # 0x16e60
movl %eax, 0xa541(%rip)      # 0x16e64
jmp 0xc94a
movl $0x3, 0x7d91(%rip)      # 0x146c0
btl $0xe, %edi
jb 0xc9d5
movl %ecx, %r8d
andl $-0x2, %r8d
cmpl $0x40, %r8d
je 0xc9d5
btl $0xe, %edi
jb 0xc964
movl %esi, %r8d
shrl $0x3, %r8d
andl $0x8, %r8d
andl $0x5, %esi
leal (%r8,%rsi,4), %esi
addl %esi, %ecx
btl $0x9, %edi
jb 0xc994
movl $0xdf, %edx
cmpl %edx, %ebx
setl %sil
cmpl %edx, %eax
setl %dl
andb %sil, %dl
cmpb $0x1, %dl
jne 0xc9d5
addl $0x20, %ecx
addl $0x21, %ebx
addl $0x21, %eax
leaq 0x1939(%rip), %rdx      # 0xe2cb
jmp 0xc9b1
incl %ebx
incl %eax
xorl %esi, %esi
cmpl $0x5, %edx
sete %sil
shll $0x5, %esi
orl $0x4d, %esi
movl %esi, (%rsp)
leaq 0x190c(%rip), %rdx      # 0xe2bd
leaq 0x10(%rsp), %rdi
pushq $0x28
popq %rsi
movl %ebx, %r8d
movl %eax, %r9d
xorl %eax, %eax
callq 0x50b0
movslq %eax, %rsi
leaq 0x10(%rsp), %rdi
xorl %edx, %edx
callq 0x671c
addq $0x38, %rsp
popq %rbx
popq %r14
retq