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

  // Process keyboard button event 
  switch (key) {
  case GLUT_KEY_DOWN:
    grid_thresholds[selected_model_index] -= 0.025 * grid_ranges[selected_model_index].Diameter();
    if (grid_thresholds[selected_model_index] < grid_ranges[selected_model_index].Min() + 1E-20) 
      grid_thresholds[selected_model_index] = grid_ranges[selected_model_index].Min() + 1E-20;
    break;

  case GLUT_KEY_UP:
    grid_thresholds[selected_model_index] += 0.025 * grid_ranges[selected_model_index].Diameter();
    if (grid_thresholds[selected_model_index] > grid_ranges[selected_model_index].Max() - 1E-20)
      grid_thresholds[selected_model_index] = grid_ranges[selected_model_index].Max() - 1E-20;
    break;
      
  case GLUT_KEY_PAGE_UP:
    if (++selected_model_index > nmodels-1) selected_model_index = nmodels - 1;
    break;

  case GLUT_KEY_PAGE_DOWN:
    if (--selected_model_index < 0) selected_model_index = 0;
    break;
  }

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

  // Remember modifiers 
  GLUTmodifiers = glutGetModifiers();

  // Redraw
  glutPostRedisplay();
}

// Assembly:
subq $0x28, %rsp
movl %edi, 0x24(%rsp)
movl %esi, 0x20(%rsp)
movl %edx, 0x1c(%rsp)
movl 0x2bf3ee(%rip), %eax    # 0x2efaf4
movl 0x1c(%rsp), %ecx
subl %ecx, %eax
movl %eax, 0x1c(%rsp)
movl 0x24(%rsp), %eax
addl $-0x65, %eax
movl %eax, %ecx
movq %rcx, 0x10(%rsp)
subl $0x4, %eax
ja 0x3092b
movq 0x10(%rsp), %rax
leaq 0x235c6d(%rip), %rcx    # 0x2663a0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movslq 0x2ce581(%rip), %rax    # 0x2fecc4
leaq 0x2ce156(%rip), %rdi    # 0x2fe8a0
shlq $0x4, %rax
addq %rax, %rdi
callq 0x3a460
movslq 0x2ce567(%rip), %rcx    # 0x2fecc4
leaq 0x2ce57c(%rip), %rax    # 0x2fece0
movsd (%rax,%rcx,8), %xmm1
movsd 0x2358f7(%rip), %xmm2   # 0x266068
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
leaq 0x2ce560(%rip), %rax    # 0x2fece0
movsd %xmm0, (%rax,%rcx,8)
movslq 0x2ce538(%rip), %rcx    # 0x2fecc4
leaq 0x2ce54d(%rip), %rax    # 0x2fece0
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x8(%rsp)
movslq 0x2ce51f(%rip), %rax    # 0x2fecc4
leaq 0x2ce0f4(%rip), %rdi    # 0x2fe8a0
shlq $0x4, %rax
addq %rax, %rdi
callq 0x3a480
movsd 0x8(%rsp), %xmm1
movsd 0x235892(%rip), %xmm2   # 0x266058
addsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x30809
movslq 0x2ce4ed(%rip), %rax    # 0x2fecc4
leaq 0x2ce0c2(%rip), %rdi    # 0x2fe8a0
shlq $0x4, %rax
addq %rax, %rdi
callq 0x3a480
movsd 0x235866(%rip), %xmm1   # 0x266058
addsd %xmm1, %xmm0
movslq 0x2ce4c7(%rip), %rcx    # 0x2fecc4
leaq 0x2ce4dc(%rip), %rax    # 0x2fece0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x3092b
movslq 0x2ce4af(%rip), %rax    # 0x2fecc4
leaq 0x2ce084(%rip), %rdi    # 0x2fe8a0
shlq $0x4, %rax
addq %rax, %rdi
callq 0x3a460
movslq 0x2ce495(%rip), %rcx    # 0x2fecc4
leaq 0x2ce4aa(%rip), %rax    # 0x2fece0
movsd (%rax,%rcx,8), %xmm1
movsd 0x23581d(%rip), %xmm2   # 0x266060
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
leaq 0x2ce48e(%rip), %rax    # 0x2fece0
movsd %xmm0, (%rax,%rcx,8)
movslq 0x2ce466(%rip), %rcx    # 0x2fecc4
leaq 0x2ce47b(%rip), %rax    # 0x2fece0
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rsp)
movslq 0x2ce44e(%rip), %rax    # 0x2fecc4
leaq 0x2ce023(%rip), %rdi    # 0x2fe8a0
shlq $0x4, %rax
addq %rax, %rdi
callq 0x3a490
movaps %xmm0, %xmm1
movsd (%rsp), %xmm0
movsd 0x2357bf(%rip), %xmm2   # 0x266058
subsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x308dc
movslq 0x2ce41a(%rip), %rax    # 0x2fecc4
leaq 0x2cdfef(%rip), %rdi    # 0x2fe8a0
shlq $0x4, %rax
addq %rax, %rdi
callq 0x3a490
movsd 0x235793(%rip), %xmm1   # 0x266058
subsd %xmm1, %xmm0
movslq 0x2ce3f4(%rip), %rcx    # 0x2fecc4
leaq 0x2ce409(%rip), %rax    # 0x2fece0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x3092b
movl 0x2ce3e0(%rip), %eax    # 0x2fecc4
addl $0x1, %eax
movl %eax, 0x2ce3d7(%rip)    # 0x2fecc4
movl 0x2ce611(%rip), %ecx    # 0x2fef04
subl $0x1, %ecx
cmpl %ecx, %eax
jle 0x30909
movl 0x2ce604(%rip), %eax    # 0x2fef04
subl $0x1, %eax
movl %eax, 0x2ce3bb(%rip)    # 0x2fecc4
jmp 0x3092b
movl 0x2ce3b3(%rip), %eax    # 0x2fecc4
addl $-0x1, %eax
movl %eax, 0x2ce3aa(%rip)    # 0x2fecc4
cmpl $0x0, %eax
jge 0x30929
movl $0x0, 0x2ce39b(%rip)    # 0x2fecc4
jmp 0x3092b
movl 0x20(%rsp), %eax
movl %eax, 0x2ce5d3(%rip)    # 0x2fef08
movl 0x1c(%rsp), %eax
movl %eax, 0x2ce5cd(%rip)    # 0x2fef0c
callq 0x1fc3c0
movl %eax, 0x2ce5c6(%rip)    # 0x2fef10
callq 0x1f4190
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)