// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x10d10
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0x10d80
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rax
movl 0x54(%rax), %eax
movl %eax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movl 0x50(%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x6, (%rax)
jne 0x10a7e
movl -0x10(%rbp), %eax
cmpl 0xaa76(%rip), %eax      # 0x1b480
jne 0x10a1c
movl -0x14(%rbp), %eax
cmpl 0xaa6f(%rip), %eax      # 0x1b484
jne 0x10a1c
jmp 0x10c29
movl 0xa996(%rip), %eax      # 0x1b3b8
andl $0x10, %eax
cmpl $0x0, %eax
jne 0x10a3f
movl 0xa988(%rip), %eax      # 0x1b3b8
andl $0x8000, %eax           # imm = 0x8000
cmpl $0x0, %eax
jne 0x10a3f
jmp 0x10c29
movl 0xa973(%rip), %eax      # 0x1b3b8
andl $0x10, %eax
cmpl $0x0, %eax
je 0x10a5b
cmpl $0x3, 0x8278(%rip)      # 0x18ccc
jne 0x10a5b
jmp 0x10c29
movl 0x826b(%rip), %eax      # 0x18ccc
addl $0x20, %eax
movl %eax, -0x18(%rbp)
movl -0x10(%rbp), %eax
movl %eax, 0xaa10(%rip)      # 0x1b480
movl -0x14(%rbp), %eax
movl %eax, 0xaa0b(%rip)      # 0x1b484
jmp 0x10b1f
movl 0xa934(%rip), %eax      # 0x1b3b8
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
jne 0x10aa0
movq -0x8(%rbp), %rax
cmpl $0x5, (%rax)
jne 0x10aa0
movl $0x3, -0x18(%rbp)
jmp 0x10aba
movl -0x18(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x18(%rbp)
cmpl $0x3, -0x18(%rbp)
jl 0x10ab8
movl -0x18(%rbp), %eax
addl $0x3d, %eax
movl %eax, -0x18(%rbp)
jmp 0x10aba
movq -0x8(%rbp), %rax
cmpl $0x4, (%rax)
jne 0x10ae0
movl -0x18(%rbp), %eax
movl %eax, 0x8200(%rip)      # 0x18ccc
movl -0x10(%rbp), %eax
movl %eax, 0xa9ab(%rip)      # 0x1b480
movl -0x14(%rbp), %eax
movl %eax, 0xa9a6(%rip)      # 0x1b484
jmp 0x10b1d
movq -0x8(%rbp), %rax
cmpl $0x5, (%rax)
jne 0x10b1b
movl $0x3, 0x81d9(%rip)      # 0x18ccc
movl 0xa8bf(%rip), %eax      # 0x1b3b8
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
je 0x10b08
jmp 0x10c29
cmpl $0x40, -0x18(%rbp)
je 0x10b14
cmpl $0x41, -0x18(%rbp)
jne 0x10b19
jmp 0x10c29
jmp 0x10b1b
jmp 0x10b1d
jmp 0x10b1f
movl 0xa893(%rip), %eax      # 0x1b3b8
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
jne 0x10b72
movl -0x1c(%rbp), %edx
andl $0x1, %edx
xorl %eax, %eax
movl $0x4, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl -0x1c(%rbp), %esi
andl $0x40, %esi
xorl %ecx, %ecx
movl $0x8, %edx
cmpl $0x0, %esi
cmovnel %edx, %ecx
addl %ecx, %eax
movl -0x1c(%rbp), %esi
andl $0x4, %esi
xorl %ecx, %ecx
movl $0x10, %edx
cmpl $0x0, %esi
cmovnel %edx, %ecx
addl %ecx, %eax
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
movl 0xa840(%rip), %eax      # 0x1b3b8
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x10bca
leaq -0x50(%rbp), %rdi
movl -0x18(%rbp), %ecx
movl -0x10(%rbp), %r8d
addl $0x1, %r8d
movl -0x14(%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 0x19c6(%rip), %rdx      # 0x12581
movl %eax, (%rsp)
movb $0x0, %al
callq 0x50b0
movl %eax, -0xc(%rbp)
jmp 0x10c1a
cmpl $0xdf, -0x10(%rbp)
jge 0x10c16
cmpl $0xdf, -0x14(%rbp)
jge 0x10c16
leaq -0x50(%rbp), %rdi
movl -0x18(%rbp), %ecx
addl $0x20, %ecx
movl -0x10(%rbp), %r8d
addl $0x20, %r8d
addl $0x1, %r8d
movl -0x14(%rbp), %r9d
addl $0x20, %r9d
addl $0x1, %r9d
movl $0x28, %esi
leaq 0x1985(%rip), %rdx      # 0x1258f
movb $0x0, %al
callq 0x50b0
movl %eax, -0xc(%rbp)
jmp 0x10c18
jmp 0x10c29
jmp 0x10c1a
leaq -0x50(%rbp), %rdi
movslq -0xc(%rbp), %rsi
xorl %edx, %edx
callq 0x6f80
addq $0x60, %rsp
popq %rbp
retq
nop