// File: /workspace/github_cpp_makefile_star2_O3/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 0xfe5a0(%rip), %r15d    # 0x121880
movb 0x10357a(%rip), %al     # 0x126860
testb %al, %al
je 0x23430
cmpb $0x0, 0x103557(%rip)    # 0x12684c
jne 0x23353
movq 0x1034a2(%rip), %rsi    # 0x1267a0
movq %rsp, %rdi
callq 0x33dae
movq 0x103493(%rip), %rdi    # 0x1267a0
callq 0x33c94
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x23322
sqrtsd %xmm0, %xmm0
jmp 0x23327
callq 0x1f590
divsd 0xa0d39(%rip), %xmm0    # 0xc4068
movsd %xmm0, 0xfe551(%rip)    # 0x121888
movapd (%rsp), %xmm0
addpd 0xa0cec(%rip), %xmm0    # 0xc4030
movapd %xmm0, 0x103504(%rip)   # 0x126850
movb $0x1, 0x1034f9(%rip)    # 0x12684c
addl $-0x64, %r14d
cmpl $0x3, %r14d
ja 0x233d5
leaq 0xa0d54(%rip), %rax     # 0xc40b8
movslq (%rax,%r14,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movsd 0xfe513(%rip), %xmm0    # 0x121888
mulsd 0xa0cdb(%rip), %xmm0    # 0xc4058
jmp 0x2338b
movsd 0xfe501(%rip), %xmm0    # 0x121888
addsd %xmm0, %xmm0
movsd %xmm0, 0xfe4f5(%rip)    # 0x121888
jmp 0x233d5
xorps %xmm0, %xmm0
cvtss2sd 0xfe4d0(%rip), %xmm0    # 0x121870
subsd 0xfe4e0(%rip), %xmm0    # 0x121888
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xfe4bc(%rip)    # 0x121870
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
movsd 0x10348d(%rip), %xmm0   # 0x126850
ucomisd %xmm1, %xmm0
jbe 0x233d5
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xfe49b(%rip)    # 0x121870
subl %ebp, %r15d
movl %ebx, 0x10345a(%rip)    # 0x126838
movl %r15d, 0x103457(%rip)   # 0x12683c
callq 0x8c885
callq 0x879cc
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
xorps %xmm0, %xmm0
cvtss2sd 0xfe46b(%rip), %xmm0    # 0x121870
addsd 0xfe47b(%rip), %xmm0    # 0x121888
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xfe457(%rip)    # 0x121870
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
movsd 0x103430(%rip), %xmm0   # 0x126858
ucomisd %xmm0, %xmm1
ja 0x233c9
jmp 0x233d5
leaq 0x103429(%rip), %rdi    # 0x126860
callq 0x1fe80
testl %eax, %eax
je 0x232ee
leaq 0x103405(%rip), %rdi    # 0x126850
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0x86a8a
leaq 0x103401(%rip), %rdi    # 0x126860
callq 0x1f4d0
jmp 0x232ee
movq %rax, %rbx
leaq 0x1033ed(%rip), %rdi    # 0x126860
callq 0x1f4b0
movq %rbx, %rdi
callq 0x1fe30