// File: /workspace/github_c_makefile_star2_O3/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 0xd401
addl $-0x2, %edx
movl 0xa996(%rip), %eax      # 0x17d90
decl %eax
cmpl %eax, %edx
cmovll %edx, %eax
cltd
idivl 0xa99c(%rip)            # 0x17da4
movl %eax, %r8d
movl 0x44(%rdi), %eax
cmpl $0x2, %eax
jl 0xd423
addl $-0x2, %eax
movl 0xa978(%rip), %ecx      # 0x17d94
decl %ecx
cmpl %ecx, %eax
cmovll %eax, %ecx
subq $0x38, %rsp
movl %ecx, %eax
cltd
idivl 0xa970(%rip)            # 0x17da0
movl 0x50(%rdi), %esi
movl (%rdi), %edx
cmpl $0x6, %edx
jne 0xd483
cmpl 0xaa1f(%rip), %r8d      # 0x17e60
jne 0xd44f
cmpl 0xaa1b(%rip), %eax      # 0x17e64
je 0xd579
movl 0xa953(%rip), %edi      # 0x17da8
testl $0x8010, %edi           # imm = 0x8010
je 0xd579
movl %edi, %r9d
shrb $0x4, %r9b
movl 0x8252(%rip), %ecx      # 0x156c0
cmpl $0x3, %ecx
sete %r10b
testb %r10b, %r9b
jne 0xd579
addl $0x20, %ecx
jmp 0xd4c1
movl 0x54(%rdi), %ecx
movl 0xa91c(%rip), %edi      # 0x17da8
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 0xd4d0
cmpl $0x4, %edx
jne 0xd4f5
movl %ecx, 0x81ff(%rip)      # 0x156c0
movl %r8d, 0xa998(%rip)      # 0x17e60
movl %eax, 0xa996(%rip)      # 0x17e64
jmp 0xd4f5
movl $0x3, 0x81e6(%rip)      # 0x156c0
btl $0xe, %edi
jb 0xd579
movl %ecx, %r9d
andl $-0x2, %r9d
cmpl $0x40, %r9d
je 0xd579
btl $0xe, %edi
jb 0xd50f
movl %esi, %r9d
shrl $0x3, %r9d
andl $0x8, %r9d
andl $0x5, %esi
leal (%r9,%rsi,4), %esi
addl %esi, %ecx
btl $0x9, %edi
jb 0xd538
cmpl $0xde, %r8d
jg 0xd579
cmpl $0xde, %eax
jg 0xd579
addl $0x20, %ecx
addl $0x21, %r8d
addl $0x21, %eax
leaq 0x1dc5(%rip), %rdx      # 0xf2fb
jmp 0xd556
incl %r8d
incl %eax
xorl %esi, %esi
cmpl $0x5, %edx
sete %sil
shll $0x5, %esi
orl $0x4d, %esi
movl %esi, (%rsp)
leaq 0x1d97(%rip), %rdx      # 0xf2ed
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 0x6cab
addq $0x38, %rsp
retq