// File: /workspace/github_c_makefile_star2_O1/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:
movl 0x40(%rdi), %edx
xorl %ecx, %ecx
movl $0x0, %eax
cmpl $0x2, %edx
jl 0xd0f5
addl $-0x2, %edx
movl 0xacb2(%rip), %eax      # 0x17da0
decl %eax
cmpl %eax, %edx
cmovll %edx, %eax
cltd
idivl 0xacb8(%rip)            # 0x17db4
movl %eax, %r8d
movl 0x44(%rdi), %eax
cmpl $0x2, %eax
jl 0xd117
addl $-0x2, %eax
movl 0xac94(%rip), %ecx      # 0x17da4
decl %ecx
cmpl %ecx, %eax
cmovll %eax, %ecx
subq $0x38, %rsp
movl %ecx, %eax
cltd
idivl 0xac8c(%rip)            # 0x17db0
movl 0x50(%rdi), %esi
movl (%rdi), %edx
cmpl $0x6, %edx
jne 0xd174
cmpl 0xad3b(%rip), %r8d      # 0x17e70
jne 0xd143
cmpl 0xad37(%rip), %eax      # 0x17e74
je 0xd26d
movl 0xac6f(%rip), %edi      # 0x17db8
testl $0x8010, %edi           # imm = 0x8010
je 0xd26d
shrb $0x4, %dil
movl 0x8571(%rip), %ecx      # 0x156d0
cmpl $0x3, %ecx
sete %r9b
testb %r9b, %dil
jne 0xd26d
addl $0x20, %ecx
jmp 0xd1b2
movl 0x54(%rdi), %ecx
movl 0xac3b(%rip), %edi      # 0x17db8
xorl %r9d, %r9d
cmpl $0x4, %ecx
setl %r9b
negl %r9d
orl $0x3c, %r9d
addl %ecx, %r9d
btl $0x9, %edi
movl $0x3, %ecx
cmovbl %r9d, %ecx
cmpl $0x5, %edx
cmovnel %r9d, %ecx
je 0xd1c1
cmpl $0x4, %edx
jne 0xd1e3
movl %ecx, 0x851e(%rip)      # 0x156d0
movl %r8d, 0xacb7(%rip)      # 0x17e70
movl %eax, 0xacb5(%rip)      # 0x17e74
jmp 0xd1e3
movl $0x3, 0x8505(%rip)      # 0x156d0
btl $0xe, %edi
jb 0xd26d
movl %ecx, %edi
andl $-0x2, %edi
cmpl $0x40, %edi
je 0xd26d
movl 0xabcf(%rip), %edi      # 0x17db8
btl $0xe, %edi
jb 0xd203
movl %esi, %r9d
shrl $0x3, %r9d
andl $0x8, %r9d
andl $0x5, %esi
leal (%r9,%rsi,4), %esi
addl %esi, %ecx
btl $0x9, %edi
jb 0xd22c
cmpl $0xde, %r8d
jg 0xd26d
cmpl $0xde, %eax
jg 0xd26d
addl $0x20, %ecx
addl $0x21, %r8d
addl $0x21, %eax
leaq 0x20b5(%rip), %rdx      # 0xf2df
jmp 0xd24a
incl %r8d
incl %eax
xorl %esi, %esi
cmpl $0x5, %edx
sete %sil
shll $0x5, %esi
orl $0x4d, %esi
movl %esi, (%rsp)
leaq 0x2087(%rip), %rdx      # 0xf2d1
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 0x6bbe
addq $0x38, %rsp
retq