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

  // Set useful variables
  static RNBoolean first = TRUE;
  static RNScalar threshold_step = 1;
  static RNInterval threshold_range(0,0);
  if (first) {
    RNInterval grid_range = grid->Range();
    threshold_step = grid->StandardDeviation() / 10;
    threshold_range.Reset(grid_range.Min() + 1.0E-20, grid_range.Max() - 1.0E-20);
    first = FALSE;
  }

  // Process keyboard button event 
  switch (key) {
  case GLUT_KEY_DOWN:
    grid_threshold -= threshold_step;
    if (grid_threshold < threshold_range.Min()) grid_threshold = threshold_range.Min();
    break;

  case GLUT_KEY_UP:
    grid_threshold += threshold_step;
    if (grid_threshold > threshold_range.Max()) grid_threshold = threshold_range.Max();
    break;

  case GLUT_KEY_LEFT:
    threshold_step /= 2;
    break;

  case GLUT_KEY_RIGHT:
    threshold_step *= 2;
    break;
  }

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

  // Remember modifiers 
  GLUTmodifiers = glutGetModifiers();

  // Redraw
  glutPostRedisplay();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebp
movl %esi, %ebx
movl %edi, %r14d
movl 0xff568(%rip), %r15d    # 0x122880
movb 0x104542(%rip), %al     # 0x127860
testb %al, %al
je 0x23468
cmpb $0x0, 0x10451f(%rip)    # 0x12784c
jne 0x2338b
movq 0x10446a(%rip), %rsi    # 0x1277a0
movq %rsp, %rdi
callq 0x33e90
movq 0x10445b(%rip), %rdi    # 0x1277a0
callq 0x33d6e
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x2335a
sqrtsd %xmm0, %xmm0
jmp 0x2335f
callq 0x1f590
divsd 0xa1d01(%rip), %xmm0    # 0xc5068
movsd %xmm0, 0xff519(%rip)    # 0x122888
movapd (%rsp), %xmm0
addpd 0xa1cb4(%rip), %xmm0    # 0xc5030
movapd %xmm0, 0x1044cc(%rip)   # 0x127850
movb $0x1, 0x1044c1(%rip)    # 0x12784c
addl $-0x64, %r14d
cmpl $0x3, %r14d
ja 0x2340d
leaq 0xa1d1c(%rip), %rax     # 0xc50b8
movslq (%rax,%r14,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movsd 0xff4db(%rip), %xmm0    # 0x122888
mulsd 0xa1ca3(%rip), %xmm0    # 0xc5058
jmp 0x233c3
movsd 0xff4c9(%rip), %xmm0    # 0x122888
addsd %xmm0, %xmm0
movsd %xmm0, 0xff4bd(%rip)    # 0x122888
jmp 0x2340d
xorps %xmm0, %xmm0
cvtss2sd 0xff498(%rip), %xmm0    # 0x122870
subsd 0xff4a8(%rip), %xmm0    # 0x122888
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xff484(%rip)    # 0x122870
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
movsd 0x104455(%rip), %xmm0   # 0x127850
ucomisd %xmm1, %xmm0
jbe 0x2340d
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xff463(%rip)    # 0x122870
subl %ebp, %r15d
movl %ebx, 0x104422(%rip)    # 0x127838
movl %r15d, 0x10441f(%rip)   # 0x12783c
callq 0x8d914
callq 0x889cc
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
xorps %xmm0, %xmm0
cvtss2sd 0xff433(%rip), %xmm0    # 0x122870
addsd 0xff443(%rip), %xmm0    # 0x122888
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xff41f(%rip)    # 0x122870
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
movsd 0x1043f8(%rip), %xmm0   # 0x127858
ucomisd %xmm0, %xmm1
ja 0x23401
jmp 0x2340d
leaq 0x1043f1(%rip), %rdi    # 0x127860
callq 0x1fe80
testl %eax, %eax
je 0x23326
leaq 0x1043cd(%rip), %rdi    # 0x127850
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0x87a86
leaq 0x1043c9(%rip), %rdi    # 0x127860
callq 0x1f4d0
jmp 0x23326
movq %rax, %rbx
leaq 0x1043b5(%rip), %rdi    # 0x127860
callq 0x1f4b0
movq %rbx, %rdi
callq 0x1fe30