// File: tomfunkhouser[P]gaps/apps/confview/confview.cpp
// Function: GLUTMotion(int, int)
void GLUTMotion(int x, int y)
{
  // Invert y coordinate
  y = GLUTwindow_height - y;

  // Compute mouse movement
  int dx = x - GLUTmouse[0];
  int dy = y - GLUTmouse[1];
  
  // Update mouse drag
  GLUTmouse_drag += dx*dx + dy*dy;

  // Check if control key is down
  if (GLUTmodifiers & GLUT_ACTIVE_CTRL) {
    // Update rubber box
    if (rubber_box_active) {
      DrawRubberBox();
      rubber_box_corners[1] = R2Point(x, y);
      DrawRubberBox();
    }
    else {
      rubber_box_active = TRUE;
      rubber_box_corners[0] = R2Point(x, y);
      rubber_box_corners[1] = R2Point(x, y);
      DrawRubberBox();
    }
  }
  else {
    // World in hand navigation 
    if (GLUTbutton[0]) viewer.RotateWorld(1.0, center, x, y, dx, dy);
    else if (GLUTbutton[1]) viewer.ScaleWorld(1.0, center, x, y, dx, dy);
    else if (GLUTbutton[2]) viewer.TranslateWorld(1.0, center, x, y, dx, dy);
    if (GLUTbutton[0] || GLUTbutton[1] || GLUTbutton[2]) glutPostRedisplay();
  }

  // Remember mouse position 
  GLUTmouse[0] = x;
  GLUTmouse[1] = y;
}

// Assembly:
subq $0x48, %rsp
movl %edi, 0x44(%rsp)
movl %esi, 0x40(%rsp)
movl 0x20b6de(%rip), %eax    # 0x235ae0
subl 0x40(%rsp), %eax
movl %eax, 0x40(%rsp)
movl 0x44(%rsp), %eax
subl 0x2119c0(%rip), %eax    # 0x23bdd4
movl %eax, 0x3c(%rsp)
movl 0x40(%rsp), %eax
subl 0x2119b6(%rip), %eax    # 0x23bdd8
movl %eax, 0x38(%rsp)
movl 0x3c(%rsp), %eax
imull 0x3c(%rsp), %eax
movl 0x38(%rsp), %ecx
imull 0x38(%rsp), %ecx
addl %ecx, %eax
addl 0x21199c(%rip), %eax    # 0x23bddc
movl %eax, 0x211996(%rip)    # 0x23bddc
movl 0x211994(%rip), %eax    # 0x23bde0
andl $0x2, %eax
cmpl $0x0, %eax
je 0x2a4fe
cmpl $0x0, 0x211985(%rip)    # 0x23bde4
je 0x2a498
callq 0x2a5f0
cvtsi2sdl 0x44(%rsp), %xmm0
cvtsi2sdl 0x40(%rsp), %xmm1
leaq 0x28(%rsp), %rdi
callq 0x11d5f0
leaq 0x21180d(%rip), %rdi    # 0x23bc90
addq $0x10, %rdi
leaq 0x28(%rsp), %rsi
callq 0x11d890
callq 0x2a5f0
jmp 0x2a4f9
movl $0x1, 0x211942(%rip)    # 0x23bde4
cvtsi2sdl 0x44(%rsp), %xmm0
cvtsi2sdl 0x40(%rsp), %xmm1
leaq 0x18(%rsp), %rdi
callq 0x11d5f0
leaq 0x2117d1(%rip), %rdi    # 0x23bc90
leaq 0x18(%rsp), %rsi
callq 0x11d890
cvtsi2sdl 0x44(%rsp), %xmm0
cvtsi2sdl 0x40(%rsp), %xmm1
leaq 0x8(%rsp), %rdi
callq 0x11d5f0
leaq 0x2117aa(%rip), %rdi    # 0x23bc90
addq $0x10, %rdi
leaq 0x8(%rsp), %rsi
callq 0x11d890
callq 0x2a5f0
jmp 0x2a5ca
cmpl $0x0, 0x2118e3(%rip)    # 0x23bde8
je 0x2a536
movl 0x44(%rsp), %edx
movl 0x40(%rsp), %ecx
movl 0x3c(%rsp), %r8d
movl 0x38(%rsp), %r9d
leaq 0x2117c0(%rip), %rdi    # 0x23bce0
movsd 0x19cae8(%rip), %xmm0   # 0x1c7010
leaq 0x211799(%rip), %rsi    # 0x23bcc8
callq 0x4b450
jmp 0x2a5a8
cmpl $0x0, 0x2118af(%rip)    # 0x23bdec
je 0x2a56e
movl 0x44(%rsp), %edx
movl 0x40(%rsp), %ecx
movl 0x3c(%rsp), %r8d
movl 0x38(%rsp), %r9d
leaq 0x211788(%rip), %rdi    # 0x23bce0
movsd 0x19cab0(%rip), %xmm0   # 0x1c7010
leaq 0x211761(%rip), %rsi    # 0x23bcc8
callq 0x4b360
jmp 0x2a5a6
cmpl $0x0, 0x21187b(%rip)    # 0x23bdf0
je 0x2a5a4
movl 0x44(%rsp), %edx
movl 0x40(%rsp), %ecx
movl 0x3c(%rsp), %r8d
movl 0x38(%rsp), %r9d
leaq 0x211750(%rip), %rdi    # 0x23bce0
movsd 0x19ca78(%rip), %xmm0   # 0x1c7010
leaq 0x211729(%rip), %rsi    # 0x23bcc8
callq 0x4b190
jmp 0x2a5a6
jmp 0x2a5a8
cmpl $0x0, 0x211839(%rip)    # 0x23bde8
jne 0x2a5c3
cmpl $0x0, 0x211834(%rip)    # 0x23bdec
jne 0x2a5c3
cmpl $0x0, 0x21182f(%rip)    # 0x23bdf0
je 0x2a5c8
callq 0x1b2ae0
jmp 0x2a5ca
movl 0x44(%rsp), %eax
movl %eax, 0x211800(%rip)    # 0x23bdd4
movl 0x40(%rsp), %eax
movl %eax, 0x2117fa(%rip)    # 0x23bdd8
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)