// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Utils/R3SurfelViewer.cpp
// Function: gaps::R3SurfelViewer::Keyboard(int, int, int, int, int, int)
int R3SurfelViewer::
Keyboard(int x, int y, int key, int shift, int ctrl, int alt)
{
  // Initialize redraw status
  int redraw = 1;

  // Process debugging commands
  if (alt) {
    // Process debugging commands
    switch (key) {
    case 'A':
    case 'a':
      SetAxesVisibility(-1);
      break;
      
    case 'B':
      SetNodeBBoxVisibility(-1);
      break;

    case 'b':
      SetObjectOrientedBBoxVisibility(-1);
      break;

    case 'C':
      SetSurfelColorScheme((surfel_color_scheme + 1) % R3_SURFEL_VIEWER_NUM_COLOR_SCHEMES);
      break;

    case 'c':
      if (SurfelColorScheme() == R3_SURFEL_VIEWER_COLOR_BY_RGB)
        SetSurfelColorScheme(R3_SURFEL_VIEWER_COLOR_BY_ELEVATION);
      else if (SurfelColorScheme() == R3_SURFEL_VIEWER_COLOR_BY_ELEVATION)
        SetSurfelColorScheme(R3_SURFEL_VIEWER_COLOR_BY_OBJECT);
      else if (SurfelColorScheme() == R3_SURFEL_VIEWER_COLOR_BY_OBJECT)
        SetSurfelColorScheme(R3_SURFEL_VIEWER_COLOR_BY_CURRENT_LABEL);
      else SetSurfelColorScheme(R3_SURFEL_VIEWER_COLOR_BY_RGB);
      break;
      
    case 'D':
    case 'd':
      SetImagePointsVisibility(-1);
      SelectImage(selected_image, FALSE, FALSE);
      break;
      
    case 'E':
    case 'e':
      if (shape_draw_flags != 0) shape_draw_flags = 0;
      else shape_draw_flags = R3_SURFEL_DISC_DRAW_FLAG | R3_SURFEL_NORMAL_DRAW_FLAG;
      break;
      
    case 'F':
    case 'f':
      SetBackfacingVisibility(-1);
      break;

    case 'G':
    case 'g':
      if (ElevationRange().IsEmpty()) SetElevationRange(RNInterval(-FLT_MAX, 0.25));
      else SetElevationRange(RNnull_interval);
      break;
      
    case 'I':
      SetImagePlaneVisibility(-1);
      SelectImage(selected_image, FALSE, FALSE);
      break;

    case 'i':
      SetImageInsetVisibility(-1);
      SelectImage(selected_image, FALSE, FALSE);
      break;

    case 'L': 
    case 'l':
      SetHumanLabeledObjectVisibility(-1);
      break;
      
    case 'M':
    case 'm':
      subsampling_multiplier_when_mouse_down = (subsampling_multiplier_when_mouse_down <= 1) ? 8 : 1;
      break;
      
    case 'N':
    case 'n':
      SetNormalVisibility(-1);
      break;
      
    case 'O':
    case 'o':
      SetCenterPointVisibility(-1);
      break;
      
    case 'P':
    case 'p':
      SetSurfelVisibility(-1);
      break;

    case 'R':
    case 'r':
      SetObjectRelationshipVisibility(-1);
      break;

    // case 'S': // Save for toggling "selection" in sfllabel
    // case 's':
    //   break;

    // case 'T': // Reserve for toggling object label text in sfllabel
    // case 't':
    //  break;
      
    case 'V':
    case 'v':
      SetImageViewpointVisibility(-1);
      break;
      
    case 'W':
      UpdateWorkingSet(viewer);
      break;

    case 'w': {
      R3Point pick_position;
      R3SurfelNode *node = PickNode(x, y, &pick_position);
      if (node) SetCenterPoint(pick_position);
      break; }

    case 'X':
    case 'x':
      SetObjectPrincipalAxesVisibility(-1);
      break;
      
    case 'Y':
    case 'y':
      SetScanViewpointVisibility(-1);
      break;
      
    case 'Z':
    case 'z':
      SetViewingExtentVisibility(-1);
      break;
      
    case 'Q':
      // Print info about the currently selected image
      if (selected_image) {
        printf("%s\n", selected_image->Name());
        fflush(stdout);
      }
      break;
        
    case 'q': {
      // Print info about the node clicked
      R3Point pick_position(0,0,0);
      R3SurfelNode *node = PickNode(x, y, &pick_position);
      if (node) {
        SetCenterPoint(pick_position);
        printf("%g %g %g\n", pick_position[0], pick_position[1], pick_position[2]);
        while (node) {
          const char *node_name = (node->Name()) ? node->Name() : "-";
          R3SurfelObject *object = node->Object();
          const char *object_name = (object && (object->Name())) ? object->Name() : "-";
          char object_index[128];
          if (object) sprintf(object_index, "%d", object->SceneIndex());
          else sprintf(object_index, "%s", "-");
          R3SurfelLabel *ground_truth_label = (object) ? object->GroundTruthLabel() : NULL;
          const char *ground_truth_label_name = (ground_truth_label && (ground_truth_label->Name())) ? ground_truth_label->Name() : "-";
          R3SurfelLabel *current_label = (object) ? object->CurrentLabel() : NULL;
          const char *current_label_name = (current_label && (current_label->Name())) ? current_label->Name() : "-";
          printf("  %4d %4d %-30s  :  %-6s %-30s  :  %-30s %-30s\n",  
                 node->TreeLevel(), node->NParts(), node_name, 
                 object_index, object_name, 
                 current_label_name, ground_truth_label_name);
          node = node->Parent();        
        }
      }
      break; }

    case ';':
      SetFocusRadius(0.9 * FocusRadius());
      break;
      
    case '\'':
      SetFocusRadius(1.1 * FocusRadius());
      break;

    case ':':
      SetTargetResolution(0.9 * TargetResolution());
      break;

    case '"':
      SetTargetResolution(1.1 * TargetResolution());
      break;

    case ',': 
    case '.':
      if (!ElevationRange().IsEmpty()) {
        RNInterval range = ElevationRange();
        if (key == ',') range.SetMax(0.9 * range.Max());
        else if (key == '.') range.SetMax(1.1 * range.Max());
        SetElevationRange(range);
      }
      break;
      
    case '{':
    case '}': {
      // Set billboard depth
      RNScalar factor = (key == '{') ? 0.8 : 1.2;
      SetImagePlaneDepth(factor * ImagePlaneDepth());
      break; }

    case '<':
    case '>': {
      // Select next/prev image
      int image_index = (selected_image) ? selected_image->SceneIndex() : 0;
      if (key == '>') image_index++;
      else if (key == '<') image_index--;
      if (image_index < 0) image_index = 0;
      if (image_index > scene->NImages()-1) image_index = scene->NImages()-1;
      SelectImage(scene->Image(image_index), FALSE, FALSE);
      break; }

    case '_': 
      SetSubsamplingFactor(SubsamplingFactor() / 2);
      break;

    case '+': 
      SetSubsamplingFactor(SubsamplingFactor() * 2);
      break;

    case '-': 
      SetSurfelSize(0.8 * SurfelSize());
      break;

    case '=': 
      SetSurfelSize(1.25 * SurfelSize());
      break;

    default:
      redraw = 0;
      break;
    }
  }
  else if (ctrl) {
    switch(key) {
    case 'M':
    case 'm': // Enter
      if (image_inset_size < 0.5) SetImageInsetSize(0.8);
      else SetImageInsetSize(0.2);
      break;

    case 'R':
    case 'r':
      // Reset camera
      ResetCamera();
      break;

    default:
      redraw = 0;
      break;
    }
  }
  else {
    // Process other commands
    switch (key) {
    case R3_SURFEL_VIEWER_F1_KEY:
    case R3_SURFEL_VIEWER_F2_KEY:
    case R3_SURFEL_VIEWER_F3_KEY:
    case R3_SURFEL_VIEWER_F4_KEY: {
      int scale = key - R3_SURFEL_VIEWER_F1_KEY + 1;
      ZoomCamera(0.05 + 0.25*scale*scale);
      break; }

    case R3_SURFEL_VIEWER_F7_KEY:
      if (selected_image) SelectImage(selected_image, TRUE, TRUE);
      break;

    case R3_SURFEL_VIEWER_F8_KEY:
      ResetCamera();
      break;
      
    case R3_SURFEL_VIEWER_DOWN_KEY:
      SetImageInsetSize(0.8 * ImageInsetSize());
      break;

    case R3_SURFEL_VIEWER_UP_KEY:
      SetImageInsetSize(1.25 * ImageInsetSize());
      break;

    case R3_SURFEL_VIEWER_PAGE_UP_KEY: 
      if (viewing_extent.IsEmpty()) viewing_extent = scene->BBox();
      if (shift) viewing_extent[RN_LO][RN_Z] += 0.01 * scene->BBox().ZLength();
      else viewing_extent[RN_HI][RN_Z] += 0.01 * scene->BBox().ZLength();
      if (R3Contains(viewing_extent, scene->BBox())) viewing_extent = R3null_box;
      break;

    case R3_SURFEL_VIEWER_PAGE_DOWN_KEY: 
      if (viewing_extent.IsEmpty()) viewing_extent = scene->BBox();
      if (shift) viewing_extent[RN_LO][RN_Z] -= 0.01 * scene->BBox().ZLength();
      else viewing_extent[RN_HI][RN_Z] -= 0.01 * scene->BBox().ZLength();
      if (R3Contains(viewing_extent, scene->BBox())) viewing_extent = R3null_box;
      break;

    default:
      redraw = 0;
      break;
    }
  }

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

  // Remember modifiers 
  shift_down = shift;
  ctrl_down = ctrl;
  alt_down = alt;

  // Return whether need redraw
  return redraw;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movl %r9d, %ebx
movl %ecx, %ebp
movl %edx, %r15d
movq %rdi, %r14
movl 0x100(%rsp), %edx
xorl %r13d, %r13d
testl %edx, %edx
je 0x30960
leal -0x22(%rbp), %eax
cmpl $0x5b, %eax
ja 0x312aa
leaq 0x107cbb(%rip), %rcx    # 0x1385bc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsd 0x158(%r14), %xmm0
movl $0x1, %r13d
ucomisd 0x160(%r14), %xmm0
ja 0x312aa
movl %r8d, 0x10(%rsp)
movl %esi, %r12d
leaq 0x158(%r14), %rsi
leaq 0x40(%rsp), %rdi
callq 0xe76d4
cmpl $0x2c, %ebp
je 0x31524
cmpl $0x2e, %ebp
jne 0x31538
movsd 0x107a6d(%rip), %xmm0   # 0x1383c8
jmp 0x3152c
testl %ebx, %ebx
je 0x30980
cmpl $0x6c, %ebp
jg 0x309e8
cmpl $0x4d, %ebp
je 0x309f6
cmpl $0x52, %ebp
je 0x30a23
jmp 0x312aa
cmpl $0x427, %ebp            # imm = 0x427
jle 0x30a39
movl %r8d, 0x10(%rsp)
movl %esi, %r12d
leal -0x428(%rbp), %eax
cmpl $0x4, %eax
jae 0x30a93
addl $0xfffffbd9, %ebp       # imm = 0xFFFFFBD9
cvtsi2sd %ebp, %xmm1
movsd 0x107a3b(%rip), %xmm0   # 0x1383f0
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
addsd 0x1079fb(%rip), %xmm0   # 0x1383c0
movq (%r14), %rax
movq %r14, %rdi
callq *0x60(%rax)
movl $0x1, %r13d
movl 0x100(%rsp), %edx
movl %r12d, %esi
movl 0x10(%rsp), %r8d
jmp 0x312aa
cmpl $0x72, %ebp
je 0x30a23
cmpl $0x6d, %ebp
jne 0x312aa
movl %r8d, %ebp
movl %esi, %r12d
movsd 0x10760c(%rip), %xmm0   # 0x138010
ucomisd 0x2d8(%r14), %xmm0
movq (%r14), %rax
movq 0x88(%rax), %rax
jbe 0x30a6e
movsd 0x1079b7(%rip), %xmm0   # 0x1383d8
jmp 0x30a76
movq (%r14), %rax
movq %r14, %rdi
movl %edx, %ebp
movl %esi, %r12d
movl %r8d, %r13d
callq *0x50(%rax)
jmp 0x3129c
addl $0xfffffbfe, %ebp       # imm = 0xFFFFFBFE
cmpl $0x6, %ebp
ja 0x312aa
leaq 0x107cdd(%rip), %rax    # 0x13872c
movslq (%rax,%rbp,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movsd 0x2d8(%r14), %xmm0
mulsd 0x10796f(%rip), %xmm0   # 0x1383d8
jmp 0x30d87
movsd 0x1079aa(%rip), %xmm0   # 0x138420
movq %r14, %rdi
callq *%rax
movl $0x1, %r13d
movl 0x100(%rsp), %edx
movl %r12d, %esi
movl %ebp, %r8d
jmp 0x312aa
cmpl $0x42e, %ebp            # imm = 0x42E
je 0x30e1f
cmpl $0x42f, %ebp            # imm = 0x42F
movl %r12d, %esi
movl 0x10(%rsp), %r8d
jne 0x312aa
movq (%r14), %rax
movq %r14, %rdi
callq *0x50(%rax)
movl 0x10(%rsp), %r8d
movl %r12d, %esi
movl 0x100(%rsp), %edx
jmp 0x312a4
movq (%r14), %rax
movq %r14, %rdi
movl %esi, %r12d
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %edx, %ebp
movl %r8d, %r13d
callq *0x100(%rax)
jmp 0x3129c
movq (%r14), %rax
movq %r14, %rdi
movl %esi, %r12d
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %edx, %ebp
movl %r8d, %r13d
callq *0xd0(%rax)
jmp 0x3129c
movq (%r14), %rax
movq %r14, %rdi
movl %esi, %r12d
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %edx, %ebp
movl %r8d, %r13d
callq *0x130(%rax)
jmp 0x3129c
movq (%r14), %rax
movq %r14, %rdi
movl %esi, %r12d
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %edx, %ebp
movl %r8d, %r13d
callq *0xe0(%rax)
jmp 0x3129c
movq (%r14), %rax
movq %r14, %rdi
movl %esi, %r12d
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %edx, %ebp
movl %r8d, %r13d
callq *0xc8(%rax)
jmp 0x3129c
movq (%r14), %rax
movq %r14, %rdi
movl %esi, %r12d
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %edx, %ebp
movl %r8d, %r13d
callq *0xb0(%rax)
jmp 0x3129c
movq (%r14), %rax
movq %r14, %rdi
movl %esi, %r12d
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %edx, %ebp
movl %r8d, %r13d
callq *0x108(%rax)
jmp 0x3129c
movq (%r14), %rax
movq %r14, %rdi
movl %esi, %r12d
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %edx, %ebp
movl %r8d, %r13d
callq *0x138(%rax)
jmp 0x3129c
movl %r8d, %ebp
movl %esi, %r12d
movsd 0x158(%r14), %xmm0
ucomisd 0x160(%r14), %xmm0
ja 0x312e2
movq (%r14), %rax
leaq 0x595028(%rip), %rsi    # 0x5c5c10
movq %r14, %rdi
jmp 0x3130e
cmpq $0x0, 0x458(%r14)
je 0x31316
movq $0x0, 0x458(%r14)
jmp 0x312a4
movq 0x2d0(%r14), %rax
testq %rax, %rax
je 0x31323
movl 0x10(%rax), %eax
jmp 0x31325
xorl %eax, %eax
cmpl $0x7b, %ebp
sete %al
leaq 0x10787b(%rip), %rcx    # 0x1384b0
movsd (%rcx,%rax,8), %xmm0
mulsd 0x2e0(%r14), %xmm0
movq (%r14), %rax
movq %r14, %rdi
movl %edx, %ebp
movl %esi, %r12d
movl %r8d, %r13d
callq *0x90(%rax)
jmp 0x3129c
movq (%r14), %rax
movq %r14, %rdi
movl %esi, %r12d
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %edx, %ebp
movl %r8d, %r13d
callq *0x120(%rax)
jmp 0x31207
cmpl $0x2, 0x490(%r14)
movl $0x1, %r13d
movl $0x8, %eax
cmovgel %r13d, %eax
movl %eax, 0x490(%r14)
jmp 0x312aa
movq (%r14), %rax
movq %r14, %rdi
movl %esi, %r12d
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %edx, %ebp
movl %r8d, %r13d
callq *0xa8(%rax)
jmp 0x3129c
movq (%r14), %rax
movq %r14, %rdi
movl %esi, %r12d
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %edx, %ebp
movl %r8d, %r13d
callq *0xa0(%rax)
jmp 0x3129c
movq (%r14), %rax
movq %r14, %rdi
movl %esi, %r12d
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %edx, %ebp
movl %r8d, %r13d
callq *0x128(%rax)
jmp 0x3129c
movl %esi, 0x14(%rsp)
movl %r15d, 0x18(%rsp)
leaq 0x128(%r14), %r13
movsd 0x128(%r14), %xmm0
leaq 0x140(%r14), %r12
ucomisd 0x140(%r14), %xmm0
ja 0x30d4e
movsd 0x130(%r14), %xmm0
ucomisd 0x148(%r14), %xmm0
ja 0x30d4e
movsd 0x138(%r14), %xmm0
ucomisd 0x150(%r14), %xmm0
jbe 0x313bf
movl %r8d, %ebp
movq 0x8(%r14), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x3139a
callq 0x4003c
movq %rax, %r15
jmp 0x313a1
movsd 0x2d8(%r14), %xmm0
mulsd 0x107691(%rip), %xmm0   # 0x138418
movq (%r14), %rax
movq %r14, %rdi
movl %edx, %ebp
movl %esi, %r12d
movl %r8d, %r13d
callq *0x88(%rax)
jmp 0x3129c
movl %esi, 0x14(%rsp)
movl %r15d, 0x18(%rsp)
leaq 0x128(%r14), %r13
movsd 0x128(%r14), %xmm0
leaq 0x140(%r14), %r12
ucomisd 0x140(%r14), %xmm0
ja 0x30df7
movsd 0x130(%r14), %xmm0
ucomisd 0x148(%r14), %xmm0
ja 0x30df7
movsd 0x138(%r14), %xmm0
ucomisd 0x150(%r14), %xmm0
jbe 0x31447
movl %r8d, %ebp
movq 0x8(%r14), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x31422
callq 0x4003c
movq %rax, %r15
jmp 0x31429
movq 0x2d0(%r14), %rsi
testq %rsi, %rsi
je 0x3138f
movq (%r14), %rax
movl $0x1, %r13d
movq %r14, %rdi
movl $0x1, %edx
movl $0x1, %ecx
callq *0x1c0(%rax)
jmp 0x309d4
movq (%r14), %rax
movq %r14, %rdi
movl %esi, %r12d
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %edx, %ebp
movl %r8d, %r13d
callq *0x110(%rax)
jmp 0x31207
movq (%r14), %rax
movq %r14, %rdi
movl %esi, %r12d
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %edx, %ebp
movl %r8d, %r13d
callq *0xd8(%rax)
jmp 0x3129c
movl %r8d, 0x10(%rsp)
movl %r15d, %ebp
leaq 0x40(%rsp), %r13
movq %r13, %rdi
movl %esi, %r15d
callq 0xc3d30
movq (%r14), %rax
movl $0x0, (%rsp)
movq %r14, %rdi
movl %r15d, %r12d
movl %r15d, %esi
movl %ebp, %r15d
movl %ebp, %edx
movq %r13, %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq *0x1f8(%rax)
testq %rax, %rax
je 0x309ce
movq (%r14), %rax
leaq 0x40(%rsp), %rsi
movq %r14, %rdi
callq *0x80(%rax)
jmp 0x309ce
movq 0x2d0(%r14), %rax
movl $0x1, %r13d
testq %rax, %rax
je 0x312aa
movq 0x1c0(%rax), %rdi
movl %esi, %r12d
movl %r8d, %ebp
callq 0x27f10
movq 0x18af87(%rip), %rax    # 0x1bbea0
movq (%rax), %rdi
callq 0x27af0
movl %ebp, %r8d
movl %r12d, %esi
movl 0x100(%rsp), %edx
jmp 0x312aa
movq (%r14), %rax
movq %r14, %rdi
movl %esi, %r12d
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %edx, %ebp
movl %r8d, %r13d
callq *0xf0(%rax)
jmp 0x3129c
movsd 0x478(%r14), %xmm0
mulsd 0x1073f6(%rip), %xmm0   # 0x138358
jmp 0x31123
movsd 0x2e8(%r14), %xmm0
mulsd 0x1074a0(%rip), %xmm0   # 0x138418
jmp 0x311d5
movl %r8d, 0x10(%rsp)
movl %ebx, 0x1c(%rsp)
movl %r15d, %ebx
leaq 0x28(%rsp), %r15
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %r15, %rdi
movl %esi, %ebp
callq 0xc3d32
movq (%r14), %rax
movl $0x0, (%rsp)
movq %r14, %rdi
movl %ebp, 0x14(%rsp)
movl %ebp, %esi
movl %ebx, 0x18(%rsp)
movl %ebx, %edx
movq %r15, %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq *0x1f8(%rax)
testq %rax, %rax
je 0x310ed
movq %rax, %r13
movq (%r14), %rax
leaq 0x28(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq *0x80(%rax)
movsd (%r15), %xmm0
movsd 0x8(%r15), %xmm1
movsd 0x10(%r15), %xmm2
leaq 0x10a62f(%rip), %rdi    # 0x13b632
movb $0x3, %al
callq 0x27080
leaq 0x107909(%rip), %rbx    # 0x13891a
movq 0xb8(%r13), %rbp
testq %rbp, %rbp
cmoveq %rbx, %rbp
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x401d4
testq %rax, %rax
je 0x31093
movq %rax, %r12
movq 0x88(%rax), %r15
testq %r15, %r15
cmoveq %rbx, %r15
movl 0x10(%rax), %edx
leaq 0x40(%rsp), %rdi
leaq 0x11559a(%rip), %rsi    # 0x1465ea
xorl %eax, %eax
callq 0x27140
movq %r12, %rdi
callq 0x47054
testq %rax, %rax
je 0x31072
movq %rbx, %rcx
movq 0x60(%rax), %rbx
testq %rbx, %rbx
cmoveq %rcx, %rbx
movq %r12, %rdi
callq 0x4713e
testq %rax, %rax
je 0x310a2
movq 0x60(%rax), %r12
testq %r12, %r12
leaq 0x10788d(%rip), %rax    # 0x13891a
cmoveq %rax, %r12
jmp 0x310a9
movw $0x2d, 0x40(%rsp)
movq %rbx, %r15
movq %rbx, %r12
jmp 0x310a9
leaq 0x107871(%rip), %r12    # 0x13891a
movq %r13, %rdi
callq 0x401c2
movl 0x3c(%r13), %edx
movq %rbx, 0x8(%rsp)
movq %r12, (%rsp)
leaq 0x107857(%rip), %rdi    # 0x13891c
movl %eax, %esi
movq %rbp, %rcx
leaq 0x40(%rsp), %r8
movq %r15, %r9
xorl %eax, %eax
callq 0x27080
movq 0x28(%r13), %r13
testq %r13, %r13
leaq 0x107833(%rip), %rbx    # 0x13891a
jne 0x31011
movl $0x1, %r13d
movl 0x1c(%rsp), %ebx
jmp 0x3150a
movsd 0x468(%r14), %xmm0
mulsd 0x1072bb(%rip), %xmm0   # 0x1383c8
jmp 0x311ab
movsd 0x478(%r14), %xmm0
mulsd 0x1072a5(%rip), %xmm0   # 0x1383c8
movq (%r14), %rax
movq %r14, %rdi
movl %edx, %ebp
movl %esi, %r12d
movl %r8d, %r13d
callq *0x1d0(%rax)
jmp 0x3129c
movl 0x360(%r14), %eax
movl %eax, %ecx
incl %ecx
movslq %ecx, %rcx
imulq $-0x77777777, %rcx, %rcx # imm = 0x88888889
shrq $0x20, %rcx
addl %eax, %ecx
incl %ecx
movl %edx, %ebp
movl %ecx, %edx
shrl $0x1f, %edx
sarl $0x3, %ecx
addl %edx, %ecx
leal (%rcx,%rcx,4), %ecx
leal (%rcx,%rcx,2), %ecx
negl %ecx
movl %esi, %r12d
leal (%rax,%rcx), %esi
incl %esi
movq (%r14), %rax
movq %r14, %rdi
movl %r8d, %r13d
callq *0x158(%rax)
jmp 0x3129c
movl %esi, %r12d
movl 0x48c(%r14), %esi
addl %esi, %esi
jmp 0x3128b
movsd 0x468(%r14), %xmm0
mulsd 0x1071ad(%rip), %xmm0   # 0x138358
movq (%r14), %rax
movq %r14, %rdi
movl %edx, %ebp
movl %esi, %r12d
movl %r8d, %r13d
callq *0x1c8(%rax)
jmp 0x3129c
movsd 0x2e8(%r14), %xmm0
mulsd 0x107203(%rip), %xmm0   # 0x1383d8
movq (%r14), %rax
movq %r14, %rdi
movl %edx, %ebp
movl %esi, %r12d
movl %r8d, %r13d
callq *0x98(%rax)
jmp 0x3129c
movq (%r14), %rax
movq %r14, %rdi
movl %esi, %r12d
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %edx, %ebp
movl %r8d, %r13d
callq *0x118(%rax)
movq 0x2d0(%r14), %rsi
movq (%r14), %rax
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq *0x1c0(%rax)
jmp 0x3129c
movl %esi, %r12d
leaq 0x78(%r14), %rsi
movq (%r14), %rax
movq %r14, %rdi
movl %edx, %ebp
movl %r8d, %r13d
callq *0x318(%rax)
jmp 0x3129c
movl 0x360(%r14), %ecx
movq (%r14), %rax
movq 0x158(%rax), %rax
cmpl $0xc, %ecx
je 0x31558
cmpl $0x5, %ecx
je 0x3154b
movl %r8d, %ebp
movl %esi, %r12d
movq %r14, %rdi
testl %ecx, %ecx
jne 0x3156f
movl $0xc, %esi
jmp 0x31571
movl 0x48c(%r14), %eax
movl %esi, %r12d
movl %eax, %esi
shrl $0x1f, %esi
addl %eax, %esi
sarl %esi
movq (%r14), %rax
movq %r14, %rdi
movl %edx, %ebp
movl %r8d, %r13d
callq *0x1d8(%rax)
movl %r13d, %r8d
movl %r12d, %esi
movl %ebp, %edx
movl $0x1, %r13d
movl %esi, 0x4a8(%r14)
movl %r15d, 0x4ac(%r14)
movl %r8d, 0x4bc(%r14)
movl %ebx, 0x4c0(%r14)
movl %edx, 0x4c4(%r14)
movl %r13d, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r15d, %r13d
leaq 0x40(%rsp), %r15
movsd 0x10704e(%rip), %xmm0   # 0x138340
movsd 0x1070f6(%rip), %xmm1   # 0x1383f0
movq %r15, %rdi
callq 0xe76ca
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
movl %r13d, %r15d
callq *0x78(%rax)
jmp 0x30a7b
movq $0x12, 0x458(%r14)
jmp 0x312a4
xorl %eax, %eax
cmpl $0x3c, %ebp
movl %esi, 0x14(%rsp)
movl %r8d, %r12d
je 0x3133c
cmpl $0x3e, %ebp
jne 0x31342
movl %edx, %ebp
incl %eax
jmp 0x31344
movl %edx, %ebp
decl %eax
jmp 0x31344
movl %edx, %ebp
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
movq 0x8(%r14), %rcx
movl 0x9c(%rcx), %edx
leal -0x1(%rdx), %esi
cmpl %edx, %eax
cmovll %eax, %esi
movq (%r14), %rax
movq 0x90(%rcx), %rcx
movslq %esi, %rdx
movq (%rcx,%rdx,8), %rsi
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq *0x1c0(%rax)
movl $0x1, %r13d
movl %ebp, %edx
movl 0x14(%rsp), %esi
movl %r12d, %r8d
jmp 0x312aa
movl $0x1, %r13d
jmp 0x309db
leaq 0x1931b7(%rip), %r15    # 0x1c4558
leaq 0x8(%r15), %rsi
movq %r13, %rdi
callq 0xc409a
addq $0x20, %r15
movq %r12, %rdi
movq %r15, %rsi
callq 0xc409a
movl %ebp, %r8d
movq %r12, 0x20(%rsp)
movl %ebx, 0x1c(%rsp)
movl %r8d, 0x10(%rsp)
testl %r8d, %r8d
movq 0x8(%r14), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rax
movl $0x150, %ecx            # imm = 0x150
movl $0x138, %ebx            # imm = 0x138
cmoveq %rcx, %rbx
movq (%rax), %rdi
leaq 0x193164(%rip), %r15    # 0x1c4558
movq %r15, %rax
testq %rdi, %rdi
je 0x31401
callq 0x4003c
movq %r13, %rbp
leaq 0x120(%r14), %r12
movsd 0x30(%rax), %xmm0
subsd 0x18(%rax), %xmm0
mulsd 0x10700b(%rip), %xmm0   # 0x138428
jmp 0x314a5
leaq 0x19312f(%rip), %r15    # 0x1c4558
leaq 0x8(%r15), %rsi
movq %r13, %rdi
callq 0xc409a
addq $0x20, %r15
movq %r12, %rdi
movq %r15, %rsi
callq 0xc409a
movl %ebp, %r8d
movq %r12, 0x20(%rsp)
movl %ebx, 0x1c(%rsp)
movl %r8d, 0x10(%rsp)
testl %r8d, %r8d
movq 0x8(%r14), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rax
movl $0x150, %ecx            # imm = 0x150
movl $0x138, %ebx            # imm = 0x138
cmoveq %rcx, %rbx
movq (%rax), %rdi
leaq 0x1930dc(%rip), %r15    # 0x1c4558
movq %r15, %rax
testq %rdi, %rdi
je 0x31489
callq 0x4003c
movq %r13, %rbp
leaq 0x120(%r14), %r12
movsd 0x30(%rax), %xmm0
subsd 0x18(%rax), %xmm0
mulsd 0x106b83(%rip), %xmm0   # 0x138028
addsd (%r14,%rbx), %xmm0
movsd %xmm0, (%r14,%rbx)
movq 0x8(%r14), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x314cd
callq 0x4003c
movq %rax, %r15
movq %r12, %rdi
movq %r15, %rsi
callq 0x8a96a
movl $0x1, %r13d
testl %eax, %eax
movl 0x1c(%rsp), %ebx
je 0x3150a
leaq 0x19306b(%rip), %r15    # 0x1c4558
leaq 0x8(%r15), %rsi
movq %rbp, %rdi
callq 0xc409a
addq $0x20, %r15
movq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0xc409a
movl 0x10(%rsp), %r8d
movl 0x18(%rsp), %r15d
movl 0x100(%rsp), %edx
movl 0x14(%rsp), %esi
jmp 0x312aa
movsd 0x106e2c(%rip), %xmm0   # 0x138358
mulsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
movq (%r14), %rax
leaq 0x40(%rsp), %rsi
movq %r14, %rdi
callq *0x78(%rax)
jmp 0x309d4
movq %r14, %rdi
movl %esi, %r12d
movl $0x8, %esi
jmp 0x31563
movq %r14, %rdi
movl %esi, %r12d
movl $0x5, %esi
movl %edx, %ebp
movl %r8d, %r13d
callq *%rax
jmp 0x3129c
xorl %esi, %esi
callq *%rax
jmp 0x30a7b