// File: /workspace/github_c_makefile_star2_O0/mcaimi[P]st/x.c
// Function: mousereport
void
mousereport(XEvent *e)
{
  int len, btn, code;
  int x = evcol(e), y = evrow(e);
  int state = e->xbutton.state;

  char buf[40];
  static int ox, oy;

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

  /* Set btn to lowest-numbered pressed button, or 12 if no
   * buttons are pressed. */
  for (btn = 1; btn <= 11 && !(buttons & (1<<(btn-1))); btn++);
  code = 32;
  } else {
    btn = e->xbutton.button;
    /* Only buttons 1 through 11 can be encoded */
    if (btn < 1 || btn > 11)
      return;
    if (e->type == ButtonRelease) {
     /* MODE_MOUSEX10: no button release reporting */
      if (IS_SET(MODE_MOUSEX10))
        return;
      /* Don't send release events for the scroll wheel */
      if (btn == 4 || btn == 5)
        return;
    }

    code = 0;
  }

  ox = x;
  oy = y;

  /* Encode btn into code. If no button is pressed for a motion event in
   * MODE_MOUSEMANY, then encode it as a release. */
  if ((!IS_SET(MODE_MOUSESGR) && e->type == ButtonRelease) || btn == 12)
    code += 3;
  else if (btn >= 8)
    code += 128 + btn - 8;
  else if (btn >= 4)
    code += 64 + btn - 4;
  else
    code += btn - 1;

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

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

  ttywrite(buf, len, 0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x14c30
movl %eax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0x14ca0
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movl 0x50(%rax), %eax
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x6, (%rax)
jne 0x14968
movl -0x18(%rbp), %eax
cmpl 0x10374(%rip), %eax     # 0x24c38
jne 0x148d6
movl -0x1c(%rbp), %eax
cmpl 0x1036d(%rip), %eax     # 0x24c3c
jne 0x148d6
jmp 0x14b41
movl 0x10214(%rip), %eax     # 0x24af0
andl $0x10, %eax
cmpl $0x0, %eax
jne 0x148f9
movl 0x10206(%rip), %eax     # 0x24af0
andl $0x8000, %eax           # imm = 0x8000
cmpl $0x0, %eax
jne 0x148f9
jmp 0x14b41
movl 0x101f1(%rip), %eax     # 0x24af0
andl $0x10, %eax
cmpl $0x0, %eax
je 0x14915
cmpl $0x0, 0x10326(%rip)     # 0x24c34
jne 0x14915
jmp 0x14b41
movl $0x1, -0x10(%rbp)
xorl %eax, %eax
cmpl $0xb, -0x10(%rbp)
movb %al, -0x51(%rbp)
jg 0x14949
movl 0x10307(%rip), %eax     # 0x24c34
movl -0x10(%rbp), %ecx
subl $0x1, %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
movb %al, -0x51(%rbp)
movb -0x51(%rbp), %al
testb $0x1, %al
jne 0x14952
jmp 0x1495f
jmp 0x14954
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x1491c
movl $0x20, -0x14(%rbp)
jmp 0x149bb
movq -0x8(%rbp), %rax
movl 0x54(%rax), %eax
movl %eax, -0x10(%rbp)
cmpl $0x1, -0x10(%rbp)
jl 0x1497e
cmpl $0xb, -0x10(%rbp)
jle 0x14983
jmp 0x14b41
movq -0x8(%rbp), %rax
cmpl $0x5, (%rax)
jne 0x149b4
movl 0x1015e(%rip), %eax     # 0x24af0
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
je 0x149a1
jmp 0x14b41
cmpl $0x4, -0x10(%rbp)
je 0x149ad
cmpl $0x5, -0x10(%rbp)
jne 0x149b2
jmp 0x14b41
jmp 0x149b4
movl $0x0, -0x14(%rbp)
movl -0x18(%rbp), %eax
movl %eax, 0x10274(%rip)     # 0x24c38
movl -0x1c(%rbp), %eax
movl %eax, 0x1026f(%rip)     # 0x24c3c
movl 0x1011d(%rip), %eax     # 0x24af0
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
jne 0x149e6
movq -0x8(%rbp), %rax
cmpl $0x5, (%rax)
je 0x149ec
cmpl $0xc, -0x10(%rbp)
jne 0x149f7
movl -0x14(%rbp), %eax
addl $0x3, %eax
movl %eax, -0x14(%rbp)
jmp 0x14a37
cmpl $0x8, -0x10(%rbp)
jl 0x14a10
movl -0x10(%rbp), %eax
addl $0x80, %eax
subl $0x8, %eax
addl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
jmp 0x14a35
cmpl $0x4, -0x10(%rbp)
jl 0x14a27
movl -0x10(%rbp), %eax
addl $0x40, %eax
subl $0x4, %eax
addl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
jmp 0x14a33
movl -0x10(%rbp), %eax
subl $0x1, %eax
addl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
jmp 0x14a35
jmp 0x14a37
movl 0x100b3(%rip), %eax     # 0x24af0
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
jne 0x14a8a
movl -0x20(%rbp), %edx
andl $0x1, %edx
xorl %eax, %eax
movl $0x4, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl -0x20(%rbp), %esi
andl $0x8, %esi
xorl %ecx, %ecx
movl $0x8, %edx
cmpl $0x0, %esi
cmovnel %edx, %ecx
addl %ecx, %eax
movl -0x20(%rbp), %esi
andl $0x4, %esi
xorl %ecx, %ecx
movl $0x10, %edx
cmpl $0x0, %esi
cmovnel %edx, %ecx
addl %ecx, %eax
addl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
movl 0x10060(%rip), %eax     # 0x24af0
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x14ae2
leaq -0x50(%rbp), %rdi
movl -0x14(%rbp), %ecx
movl -0x18(%rbp), %r8d
addl $0x1, %r8d
movl -0x1c(%rbp), %r9d
addl $0x1, %r9d
movq -0x8(%rbp), %rax
movl (%rax), %esi
movl $0x4d, %eax
movl $0x6d, %edx
cmpl $0x5, %esi
cmovel %edx, %eax
movl $0x28, %esi
leaq 0x6fe0(%rip), %rdx      # 0x1bab3
movl %eax, (%rsp)
movb $0x0, %al
callq 0x60d0
movl %eax, -0xc(%rbp)
jmp 0x14b32
cmpl $0xdf, -0x18(%rbp)
jge 0x14b2e
cmpl $0xdf, -0x1c(%rbp)
jge 0x14b2e
leaq -0x50(%rbp), %rdi
movl -0x14(%rbp), %ecx
addl $0x20, %ecx
movl -0x18(%rbp), %r8d
addl $0x20, %r8d
addl $0x1, %r8d
movl -0x1c(%rbp), %r9d
addl $0x20, %r9d
addl $0x1, %r9d
movl $0x28, %esi
leaq 0x6f9f(%rip), %rdx      # 0x1bac1
movb $0x0, %al
callq 0x60d0
movl %eax, -0xc(%rbp)
jmp 0x14b30
jmp 0x14b41
jmp 0x14b32
leaq -0x50(%rbp), %rdi
movslq -0xc(%rbp), %rsi
xorl %edx, %edx
callq 0x8400
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)