// File: /workspace/github_c_makefile_star2_O3/jrrk[P]cbzone/c_gpr.c
// Function: gprcondeventwait
Bool gprcondeventwait(key, posn)
     char* key;
     Position_t *posn;
{
  static unsigned long flag[16]={0};
  XEvent ev;
  char keystr;
  Bool return_val = False;
  Bool motion = False;

  while (XPending(d) || paused) {
    XNextEvent(d, &ev);
    switch(ev.type) {
    case Expose:
      if (((XExposeEvent*) &ev)->count) break;
      if (!paused)
        grabpointer();
      mouse_posn.x = ev.xexpose.x;
      mouse_posn.y = ev.xexpose.y;
      *key = 'R';
      return_val = True;
      break;
    case UnmapNotify:
      paused = True;
      break;
    case MapNotify:
      paused = False;
      break;
    case KeyPress:
      if (XLookupString(&ev.xkey,&keystr,1,(KeySym *) 0,
                        (XComposeStatus *) 0) == 1)
        switch (keystr) {
        case 'p': case 'P':
          ungrabpointer();
          paused = True;
          break;
        case 'c': case 'C':
          grabpointer();
          paused = False;
          break;
        case 'i': case 'I': case ' ':
          XIconifyWindow(d, w, screen_num);
          break;
        case 'r': case 'R':
          *key = 'R';
          return_val = True;
          break;
        case '\003': case 'q': case 'Q':
          *key = 'Q';
          return_val = True;
          break;
        }
      if (return_val) {
        mouse_posn.x = ev.xkey.x;
        mouse_posn.y = ev.xkey.y;
      }
      break;
    case MotionNotify:
      motion = True;
      mouse_posn.x = ev.xmotion.x;
      mouse_posn.y = ev.xmotion.y;
      break;
    case ButtonPress:
      mouse_posn.x = ev.xbutton.x;
      mouse_posn.y = ev.xbutton.y;
      *key = ev.xbutton.button + 'a' - 1;
      flag[ev.xbutton.button]=1;
      return_val = True;
      break;
    case ButtonRelease:
      mouse_posn.x = ev.xbutton.x;
      mouse_posn.y = ev.xbutton.y;
      *key = ev.xbutton.button + 'A' - 1;
      flag[ev.xbutton.button]=0;
      return_val = True;
      break;
    }
    if (return_val)
      break;
  }
  if(flag[1]&&flag[3]) {
    *key = 'Q';
    return_val = True;
  }
  if (!paused) {
    posn->x = mouse_posn.x*XD/XM + XOFF;
    posn->y = mouse_posn.y*YD/YM + YOFF;
  }
  return return_val;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0xd32d(%rip), %rdi      # 0x14628
callq 0x45c0
orl 0xd3aa(%rip), %eax      # 0x146b0
je 0x744b
leaq 0x8(%rsp), %r15
leaq 0x6e18(%rip), %r13      # 0xe130
leaq 0x7(%rsp), %r12
leaq 0x6e38(%rip), %rbp      # 0xe15c
movq 0xd2fd(%rip), %rdi      # 0x14628
movq %r15, %rsi
callq 0x4340
movl 0x8(%rsp), %eax
leal -0x2(%rax), %ecx
cmpl $0xa, %ecx
ja 0x738d
movslq (%r13,%rcx,4), %rax
addq %r13, %rax
jmpq *%rax
movq %r15, %rdi
movq %r12, %rsi
movl $0x1, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x40e0
cmpl $0x1, %eax
jne 0x7422
movzbl 0x7(%rsp), %eax
cmpl $0x48, %eax
jg 0x73c5
cmpl $0x20, %eax
je 0x73ef
cmpl $0x43, %eax
je 0x7441
cmpl $0x3, %eax
jne 0x7422
jmp 0x7548
cmpl $0x12, %eax
je 0x7418
cmpl $0x13, %eax
jne 0x7422
movl $0x0, 0xd307(%rip)      # 0x146b0
jmp 0x7422
cmpl $0x0, 0x40(%rsp)
jne 0x7422
jmp 0x7528
movq 0x48(%rsp), %rax
movq %rax, 0xd2e5(%rip)      # 0x146a8
jmp 0x7422
leal -0x49(%rax), %ecx
cmpl $0x9, %ecx
jbe 0x73e5
leal -0x69(%rax), %ecx
cmpl $0x9, %ecx
ja 0x743c
leaq 0x6da8(%rip), %rdx      # 0xe184
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movslq (%rbp,%rcx,4), %rax
addq %rbp, %rax
jmpq *%rax
movq 0xd232(%rip), %rdi      # 0x14628
movq 0xd233(%rip), %rsi      # 0x14630
movl 0xd265(%rip), %edx      # 0x14668
callq 0x41f0
jmp 0x7422
movq 0xd217(%rip), %rdi      # 0x14628
xorl %esi, %esi
callq 0x4140
movl $0x1, 0xd28e(%rip)      # 0x146b0
movq 0xd1ff(%rip), %rdi      # 0x14628
callq 0x45c0
orl 0xd27c(%rip), %eax      # 0x146b0
jne 0x7324
jmp 0x744b
cmpl $0x63, %eax
jne 0x7422
callq 0x5d04
jmp 0x739f
xorl %eax, %eax
cmpq $0x0, 0xd273(%rip)      # 0x146c8
je 0x746a
cmpq $0x0, 0xd279(%rip)      # 0x146d8
je 0x746a
movb $0x51, (%r14)
movl $0x1, %eax
cmpl $0x0, 0xd23f(%rip)      # 0x146b0
jne 0x74c8
movl 0xd22f(%rip), %ecx      # 0x146a8
addl %ecx, %ecx
leal (%rcx,%rcx,4), %ecx
movslq %ecx, %rcx
imulq $-0x6db6db6d, %rcx, %rdx # imm = 0x92492493
shrq $0x20, %rdx
addl %edx, %ecx
movl %ecx, %edx
sarl $0x2, %edx
shrl $0x1f, %ecx
addl %edx, %ecx
addl $0x32, %ecx
movl %ecx, (%rbx)
movl 0xd209(%rip), %ecx      # 0x146ac
addl %ecx, %ecx
leal (%rcx,%rcx,4), %ecx
movslq %ecx, %rcx
imulq $-0x6db6db6d, %rcx, %rdx # imm = 0x92492493
shrq $0x20, %rdx
addl %edx, %ecx
movl %ecx, %edx
sarl $0x2, %edx
shrl $0x1f, %ecx
addl %edx, %ecx
addl $0x32, %ecx
movl %ecx, 0x4(%rbx)
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x48(%rsp), %rax
movq %rax, 0xd1c2(%rip)      # 0x146a8
movl 0x5c(%rsp), %eax
leal 0x40(%rax), %ecx
movb %cl, (%r14)
leaq 0xd1c9(%rip), %rcx      # 0x146c0
movq $0x0, (%rcx,%rax,8)
jmp 0x755d
movq 0x48(%rsp), %rax
movq %rax, 0xd19b(%rip)      # 0x146a8
movl 0x5c(%rsp), %eax
leal 0x60(%rax), %ecx
movb %cl, (%r14)
leaq 0xd1a2(%rip), %rcx      # 0x146c0
movq $0x1, (%rcx,%rax,8)
jmp 0x755d
cmpl $0x0, 0xd181(%rip)      # 0x146b0
jne 0x7536
callq 0x5d04
movq 0x30(%rsp), %rax
movq %rax, 0xd166(%rip)      # 0x146a8
movb $0x52, (%r14)
jmp 0x755d
movb $0x51, %al
jmp 0x754e
movb $0x52, %al
movb %al, (%r14)
movq 0x48(%rsp), %rax
movq %rax, 0xd14b(%rip)      # 0x146a8
movl $0x1, %eax
jmp 0x744d