// File: /workspace/github_c_makefile_star2_O2/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 $0xd8, %rsp
movq %rsi, 0x10(%rsp)
movq %rdi, %r14
leaq 0x18(%rsp), %r12
leaq 0x6353(%rip), %rbx      # 0xd100
xorl %r15d, %r15d
leaq 0xf(%rsp), %r13
pushq $0x1
popq %rbp
movq 0xc879(%rip), %rdi      # 0x13638
callq 0x45d0
orl 0xc8f6(%rip), %eax      # 0x136c0
je 0x6f60
movq 0xc861(%rip), %rdi      # 0x13638
movq %r12, %rsi
callq 0x4340
movl 0x18(%rsp), %eax
leal -0x2(%rax), %ecx
cmpl $0xa, %ecx
ja 0x6e45
movslq (%rbx,%rcx,4), %rax
addq %rbx, %rax
jmpq *%rax
movq %r12, %rdi
movq %r13, %rsi
movl %ebp, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x40e0
cmpl $0x1, %eax
jne 0x6db8
movzbl 0xf(%rsp), %eax
leal -0x49(%rax), %ecx
cmpl $0x9, %ecx
jbe 0x6e80
leal -0x69(%rax), %ecx
cmpl $0x9, %ecx
jbe 0x6e90
cmpl $0x20, %eax
je 0x6ea0
cmpl $0x43, %eax
je 0x6ed2
cmpl $0x63, %eax
je 0x6ed2
cmpl $0x3, %eax
jne 0x6db8
jmp 0x6f47
cmpl $0x12, %eax
je 0x6ec3
cmpl $0x13, %eax
jne 0x6db8
andl $0x0, 0xc866(%rip)      # 0x136c0
jmp 0x6db8
cmpl $0x0, 0x50(%rsp)
jne 0x6db8
jmp 0x6f27
movq 0x58(%rsp), %rax
movq %rax, 0xc83d(%rip)      # 0x136b8
jmp 0x6db8
leaq 0x62a5(%rip), %rdx      # 0xd12c
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
leaq 0x62bd(%rip), %rdx      # 0xd154
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movq 0xc791(%rip), %rdi      # 0x13638
movq 0xc792(%rip), %rsi      # 0x13640
movl 0xc7c4(%rip), %edx      # 0x13678
callq 0x41f0
jmp 0x6db8
callq 0x5bdc
movl $0x1, 0xc7f3(%rip)      # 0x136c0
jmp 0x6db8
callq 0x5b9c
jmp 0x6e53
movq 0x58(%rsp), %rax
movq %rax, 0xc7d0(%rip)      # 0x136b8
movl 0x6c(%rsp), %eax
leal 0x60(%rax), %ecx
movb %cl, (%r14)
leaq 0xc7d7(%rip), %rcx      # 0x136d0
movq $0x1, (%rcx,%rax,8)
jmp 0x6f5c
movq 0x58(%rsp), %rax
movq %rax, 0xc7a9(%rip)      # 0x136b8
movl 0x6c(%rsp), %eax
leal 0x40(%rax), %ecx
movb %cl, (%r14)
leaq 0xc7b0(%rip), %rcx      # 0x136d0
andq $0x0, (%rcx,%rax,8)
jmp 0x6f5c
cmpl $0x0, 0xc792(%rip)      # 0x136c0
jne 0x6f35
callq 0x5b9c
movq 0x40(%rsp), %rax
movq %rax, 0xc777(%rip)      # 0x136b8
movb $0x52, (%r14)
jmp 0x6f5c
movb $0x51, %al
jmp 0x6f4d
movb $0x52, %al
movb %al, (%r14)
movq 0x58(%rsp), %rax
movq %rax, 0xc75c(%rip)      # 0x136b8
pushq $0x1
popq %r15
cmpq $0x0, 0xc770(%rip)      # 0x136d8
je 0x6f7b
cmpq $0x0, 0xc776(%rip)      # 0x136e8
je 0x6f7b
movb $0x51, (%r14)
movl %ebp, %r15d
cmpl $0x0, 0xc73e(%rip)      # 0x136c0
jne 0x6fab
imull $0xa, 0xc72d(%rip), %eax # 0x136b8
pushq $0x7
popq %rcx
cltd
idivl %ecx
addl $0x32, %eax
movq 0x10(%rsp), %rsi
movl %eax, (%rsi)
imull $0xa, 0xc71a(%rip), %eax # 0x136bc
cltd
idivl %ecx
addl $0x32, %eax
movl %eax, 0x4(%rsi)
movl %r15d, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq