// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Graphics/R3Scene.cpp
// Function: gaps::R3Scene::ReadSUNCGFile(char const*, gaps::R3SceneNode*)
int R3Scene::
ReadSUNCGFile(const char *filename, R3SceneNode *parent_node)
{
  // Useful variables
  const char *input_data_directory = "../..";
  RNSymbolTable<R2Texture *> texture_symbol_table;
  RNSymbolTable<R3Scene *> model_symbol_table;
  if (!parent_node) parent_node = root;
  
  // Open file
  FILE* fp = fopen(filename, "rb");
  if (!fp) {
    RNFail("Unable to open SUNCG file %s\n", filename);
    return 0;
  }

  // Read file 
  std::string text;
  fseek(fp, 0, SEEK_END);
  long const size = ftell(fp);
  fseek(fp, 0, SEEK_SET);
  char* buffer = new char[size + 1];
  unsigned long const usize = static_cast<unsigned long const>(size);
  if (fread(buffer, 1, usize, fp) != usize) { RNFail("Unable to read %s\n", filename); return 0; }
  else { buffer[size] = 0; text = buffer; }
  delete[] buffer;

  // Close file
  fclose(fp);

  // Digest file
  Json::Value json_root;
  Json::Reader json_reader;
  Json::Value *json_items, *json_item, *json_value;
  if (!json_reader.parse(text, json_root, false)) {
    RNFail("Unable to parse %s\n", filename);
    return 0;
  }

  // Get/check version
  char version[1024];
  strncpy(version, "suncg@1.0.0", 1023);
  if (GetJsonObjectMember(json_value, &json_root, "version", Json::stringValue)) {
    strncpy(version, json_value->asString().c_str(), 1023);
    if (strncmp(version, "suncg", 5)) {
      RNFail("Unrecognized version %s in SUNCG file %s\n", version, filename);
      return 0;
    }
  }
  
  // Get scene id
  char scene_id[1024];
  strncpy(scene_id, "NoName", 1023);
  if (GetJsonObjectMember(json_value, &json_root, "id", Json::stringValue)) {
    strncpy(scene_id, json_value->asString().c_str(), 1023);
  }
  
  // Get scene up direction
  R3Vector scene_up(0, 1, 0);
  if (GetJsonObjectMember(json_items, &json_root, "up", Json::arrayValue)) {
    if (json_items->size() >= 3) {
      if (GetJsonArrayEntry(json_item, json_items, 0))
        scene_up[0] = json_item->asDouble();
      if (GetJsonArrayEntry(json_item, json_items, 1))
        scene_up[1] = json_item->asDouble();
      if (GetJsonArrayEntry(json_item, json_items, 2))
        scene_up[2] = json_item->asDouble();
      scene_up.Normalize();
    }
  }

  // Get scene front direction
  R3Vector scene_front(0, 0, 1);
  if (GetJsonObjectMember(json_items, &json_root, "front", Json::arrayValue)) {
    if (json_items->size() >= 3) {
      if (GetJsonArrayEntry(json_item, json_items, 0))
        scene_front[0] = json_item->asDouble();
      if (GetJsonArrayEntry(json_item, json_items, 1))
        scene_front[1] = json_item->asDouble();
      if (GetJsonArrayEntry(json_item, json_items, 2))
        scene_front[2] = json_item->asDouble();
      scene_front.Normalize();
    }
  }

  // Get scene scale factor (to convert to meters)
  double scaleToMeters = 1.0;
  if (GetJsonObjectMember(json_value, &json_root, "scaleToMeters")) {
    scaleToMeters = json_value->asDouble();
  }
  
  // Create scene node 
  R3SceneNode *scene_node = parent_node;
  scene_node->SetName(scene_id);

  // Set scene transformation
  R3Affine scene_transformation = R3identity_affine;
  // Set up and front directions
  scene_transformation.Scale(scaleToMeters);
  scene_node->SetTransformation(scene_transformation);

  // Parse levels
  Json::Value *json_levels, *json_level;
  if (!GetJsonObjectMember(json_levels, &json_root, "levels", Json::arrayValue)) return 0;
  for (Json::ArrayIndex index = 0; index < json_levels->size(); index++) {
    if (!GetJsonArrayEntry(json_level, json_levels, index)) return 0;
    if (json_level->type() != Json::objectValue) continue;
           
    // Parse level attributes
    int level_id = index;
    if (GetJsonObjectMember(json_value, json_level, "valid"))
      if (json_value->asString() == std::string("0"))  continue;
    if (GetJsonObjectMember(json_value, json_level, "id"))
      level_id = atoi(json_value->asString().c_str());

    // Create level node
    char level_name[1024];
    sprintf(level_name, "Level#%d", level_id);
    R3SceneNode *level_node = new R3SceneNode(this);
    level_node->SetName(level_name);
    scene_node->InsertChild(level_node);

    // Parse nodes
    Json::Value *json_nodes, *json_node, *json_materials;
    if (GetJsonObjectMember(json_nodes, json_level, "nodes", Json::arrayValue)) {
      if (json_nodes->size() == 0) continue;
      R3SceneNode **created_nodes = new R3SceneNode * [ json_nodes->size() ];
      for (unsigned int i = 0; i < json_nodes->size(); i++) created_nodes[i] = NULL;
      for (Json::ArrayIndex index = 0; index < json_nodes->size(); index++) {
        if (!GetJsonArrayEntry(json_node, json_nodes, index)) continue; 
        if (json_node->type() != Json::objectValue) continue;
 
        // Parse node attributes
        char node_id[1024] = { '\0' };;
        char modelId[1024] = { '\0' };;
        char node_type[1024] = { '\0' };
        int hideCeiling = 0, hideFloor = 0, hideWalls = 0;
        int isMirrored = 0, state = 0;
        if (GetJsonObjectMember(json_value, json_node, "valid"))
          if (json_value->asString() == std::string("0"))  continue;
        if (GetJsonObjectMember(json_value, json_node, "id"))
          strncpy(node_id, json_value->asString().c_str(), 1023);
        if (GetJsonObjectMember(json_value, json_node, "type")) 
          strncpy(node_type, json_value->asString().c_str(), 1023);
        if (GetJsonObjectMember(json_value, json_node, "modelId"))
          strncpy(modelId, json_value->asString().c_str(), 1023);
        if (GetJsonObjectMember(json_value, json_node, "hideCeiling")) 
          if (json_value->asString() == std::string("1")) hideCeiling = 1;
        if (GetJsonObjectMember(json_value, json_node, "hideFloor")) 
          if (json_value->asString() == std::string("1")) hideFloor = 1;
        if (GetJsonObjectMember(json_value, json_node, "hideWalls")) 
          if (json_value->asString() == std::string("1")) hideWalls = 1;
        if (GetJsonObjectMember(json_value, json_node, "isMirrored")) 
          if (json_value->asString() == std::string("1")) isMirrored = 1;
        if (GetJsonObjectMember(json_value, json_node, "state")) 
          if (json_value->asString() == std::string("1")) state = 1;

        // Parse node transformation
        R3Affine transformation = R3identity_affine;
        if (GetJsonObjectMember(json_items, json_node, "transform", Json::arrayValue)) {
          if (json_items->size() >= 16) {
            R4Matrix matrix = R4identity_matrix;
            for (Json::ArrayIndex index = 0; index < json_items->size(); index++) {
              if (!GetJsonArrayEntry(json_item, json_items, index)) continue;
              matrix[index%4][index/4] = json_item->asDouble();
            }
            transformation.Reset(matrix, isMirrored);
          }
        }

        // Create scene node(s) based on type
        char obj_name[4096], node_name[4096];
        if (!strcmp(node_type, "Ground")) {
          // Create node for ground
          sprintf(obj_name, "%s/room/%s/%sf.obj", input_data_directory, scene_id, modelId); 
          if (!hideFloor && RNFileExists(obj_name)) {
            R3Scene *model = new R3Scene();
            if (!ReadObj(model, model->Root(), obj_name)) return 0;
            sprintf(node_name, "Ground#%s", node_id);
            model->SetName(node_name);
            model->Root()->SetName(node_name);
            model->SetFilename(obj_name);
            InsertReferencedScene(model);
            R3SceneNode *node = new R3SceneNode(this);
            node->InsertReference(new R3SceneReference(model, materials));
            node->SetName(node_name);
            node->SetTransformation(transformation);
            level_node->InsertChild(node);
            // R3SceneNode *node = new R3SceneNode(this);
            // sprintf(node_name, "Ground#%s", node_id);
            // node->SetName(node_name);
            // if (!ReadObj(this, node, obj_name)) return 0;
            // level_node->InsertChild(node);
            created_nodes[index] = node;
          }
        }
        else if (!strcmp(node_type, "Room")) {
          // Create room node
          R3SceneNode *room_node = new R3SceneNode(this);
          sprintf(node_name, "Room#%s", node_id);
          room_node->SetName(node_name);
          // room_node->SetTransformation(transformation);
          level_node->InsertChild(room_node);
          created_nodes[index] = room_node;
          RNArray<R3Material *> materials;
          
           // Create node for floor
          sprintf(obj_name, "%s/room/%s/%sf.obj", input_data_directory, scene_id, modelId); 
          if (!hideFloor && RNFileExists(obj_name)) {
            R3Scene *model = new R3Scene();
            if (!ReadObj(model, model->Root(), obj_name)) return 0;
            sprintf(node_name, "Floor#%s", node_id);
            model->SetName(node_name);
            model->Root()->SetName(node_name);
            model->SetFilename(obj_name);
            InsertReferencedScene(model);
            R3SceneNode *node = new R3SceneNode(this);
            node->InsertReference(new R3SceneReference(model, materials));
            node->SetName(node_name);
            room_node->InsertChild(node);
            // R3SceneNode *node = new R3SceneNode(this);
            // sprintf(node_name, "Floor#%s", node_id);
            // node->SetName(node_name);
            // if (!ReadObj(this, node, obj_name)) return 0;
            // room_node->InsertChild(node);
          }

          // Create node for ceiling
          sprintf(obj_name, "%s/room/%s/%sc.obj", input_data_directory, scene_id, modelId); 
          if (!hideCeiling && RNFileExists(obj_name)) {
            R3Scene *model = new R3Scene();
            if (!ReadObj(model, model->Root(), obj_name)) return 0;
            sprintf(node_name, "Ceiling#%s", node_id);
            model->SetName(node_name);
            model->Root()->SetName(node_name);
            model->SetFilename(obj_name);
            InsertReferencedScene(model);
            R3SceneNode *node = new R3SceneNode(this);
            node->InsertReference(new R3SceneReference(model, materials));
            node->SetName(node_name);
            room_node->InsertChild(node);
            // R3SceneNode *node = new R3SceneNode(this);
            // sprintf(node_name, "Ceiling#%s", node_id);
            // node->SetName(node_name);
            // if (!ReadObj(this, node, obj_name)) return 0;
            // room_node->InsertChild(node);
          }
          
          // Create node for walls
          sprintf(obj_name, "%s/room/%s/%sw.obj", input_data_directory, scene_id, modelId); 
          if (!hideWalls && RNFileExists(obj_name)) {
            R3Scene *model = new R3Scene();
            if (!ReadObj(model, model->Root(), obj_name)) return 0;
            sprintf(node_name, "Wall#%s", node_id);
            model->SetName(node_name);
            model->Root()->SetName(node_name);
            model->SetFilename(obj_name);
            InsertReferencedScene(model);
            R3SceneNode *node = new R3SceneNode(this);
            node->InsertReference(new R3SceneReference(model, materials));
            node->SetName(node_name);
            room_node->InsertChild(node);
            // R3SceneNode *node = new R3SceneNode(this);
            // sprintf(node_name, "Wall#%s", node_id);
            // node->SetName(node_name);
            // if (!ReadObj(this, node, obj_name)) return 0;
            // room_node->InsertChild(node);
          }        
        }
        else if (!strcmp(node_type, "Object")) {
          // Read/get model 
          R3Scene *model = NULL;
          if (state) sprintf(obj_name, "%s/object/%s/%s_0.obj", input_data_directory, modelId, modelId); 
          else sprintf(obj_name, "%s/object/%s/%s.obj", input_data_directory, modelId, modelId); 
          if (!model_symbol_table.Find(obj_name, &model)) {
            model = new R3Scene();
            if (!ReadObj(model, model->Root(), obj_name)) return 0;
            sprintf(node_name, "Model#%s", modelId);
            model->SetName(modelId);
            model->Root()->SetName(node_name);
            model->SetFilename(obj_name);
            InsertReferencedScene(model);
            model_symbol_table.Insert(obj_name, model);
          }

          // Read materials
          RNArray<R3Material *> materials;
          if (GetJsonObjectMember(json_materials, json_node, "materials", Json::arrayValue)) {
            if (!ParseSUNCGMaterials(this, texture_symbol_table, model->materials, materials, json_materials)) return 0;
          }

          // Create node with reference to model
          R3SceneNode *node = new R3SceneNode(this);
          sprintf(node_name, "Object#%s", node_id);
          node->InsertReference(new R3SceneReference(model, materials));
          node->SetName(node_name);
          node->SetTransformation(transformation);
          level_node->InsertChild(node);
          created_nodes[index] = node;
        }
        else if (!strcmp(node_type, "Box")) {
          // Parse box dimensions
          RNScalar box_dimensions[3] = { 1, 1, 1 };
          if (GetJsonObjectMember(json_items, json_node, "dimensions", Json::arrayValue)) {
            if (json_items->size() >= 3) {
              if (GetJsonArrayEntry(json_item, json_items, 0))
                box_dimensions[0] = json_item->asDouble();
              if (GetJsonArrayEntry(json_item, json_items, 1))
                box_dimensions[1] = json_item->asDouble();
              if (GetJsonArrayEntry(json_item, json_items, 2))
                box_dimensions[2] = json_item->asDouble();
            }
          }

          // Read materials
          RNArray<R3Material *> materials;
          if (GetJsonObjectMember(json_materials, json_node, "materials", Json::arrayValue)) {
            if (!ParseSUNCGMaterials(this, texture_symbol_table, materials, materials, json_materials)) return 0;
          }

          // Create node for box
          R3SceneNode *node = new R3SceneNode(this);
          sprintf(node_name, "Box#%s", node_id);
          node->SetName(node_name);
          node->SetTransformation(transformation);
          if (!CreateBox(this, node, box_dimensions, materials)) return 0;
          level_node->InsertChild(node);
          created_nodes[index] = node;
        }
      }

      // Move created nodes to be children of room nodes
      for (Json::ArrayIndex index = 0; index < json_nodes->size(); index++) {
        if (!GetJsonArrayEntry(json_node, json_nodes, index)) continue; 
        if (json_node->type() != Json::objectValue) continue;
        if (!GetJsonObjectMember(json_value, json_node, "type")) continue;
        if (strcmp(json_value->asString().c_str(), "Room")) continue;
        R3SceneNode *room_node = created_nodes[index];
        if (!room_node) continue;
        if (GetJsonObjectMember(json_items, json_node, "nodeIndices", Json::arrayValue)) {
          for (Json::ArrayIndex room_index = 0; room_index < json_items->size(); room_index++) {
            GetJsonArrayEntry(json_item, json_items, room_index);
            if (json_item->isNumeric()) {
              int node_index = json_item->asInt();
              if ((node_index >= 0) && ((unsigned int) node_index < json_nodes->size())) {
                R3SceneNode *node = created_nodes[node_index];
                if (node) {
                  level_node->RemoveChild(node);
                  room_node->InsertChild(node); 
                }
              }
            }
          }
        }
      }
      
      // Delete array of created nodes
      delete [] created_nodes;
    }
  }
    
  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3e38, %rsp           # imm = 0x3E38
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, 0x20(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x3686a
leaq 0x90(%rsp), %rdi
callq 0x37158
testq %r14, %r14
jne 0x2c5d3
movq 0x20(%rsp), %rax
movq (%rax), %r14
movq %r14, 0xb8(%rsp)
leaq 0x99b1c(%rip), %rsi     # 0xc60fe
movq %rbx, %rdi
callq 0x21ab0
testq %rax, %rax
je 0x2c76f
movq %rax, %r14
leaq 0x278(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
pushq $0x2
popq %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x219d0
movq %r14, %rdi
callq 0x21030
movq %rax, %r15
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x219d0
leaq 0x1(%r15), %rdi
callq 0x21040
movq %rax, %r12
pushq $0x1
popq %rsi
movq %rax, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0x21e60
cmpq %r15, %rax
jne 0x2c787
movb $0x0, (%r12,%r15)
leaq 0x268(%rsp), %rdi
movq %r12, %rsi
callq 0x22290
movq %r12, %rdi
callq 0x21c20
movq %r14, %rdi
callq 0x218c0
leaq 0x168(%rsp), %rdi
xorl %esi, %esi
callq 0x84942
leaq 0x520(%rsp), %rdi
callq 0x7e9c6
leaq 0x520(%rsp), %rdi
leaq 0x268(%rsp), %rsi
leaq 0x168(%rsp), %rdx
xorl %ecx, %ecx
callq 0x7eb28
testb %al, %al
je 0x2c7a5
leaq 0x99a83(%rip), %rsi     # 0xc6146
leaq 0x3a30(%rsp), %rdi
movl $0x3ff, %edx            # imm = 0x3FF
callq 0x21440
leaq 0xa602b(%rip), %rdx     # 0xd2707
leaq 0x8(%rsp), %rdi
leaq 0x168(%rsp), %rsi
pushq $0x4
popq %rcx
callq 0x32249
testl %eax, %eax
je 0x2c7c3
movq 0x8(%rsp), %rsi
leaq 0x630(%rsp), %rdi
callq 0x80236
leaq 0x630(%rsp), %r14
movq (%r14), %rsi
leaq 0x3a30(%rsp), %r15
movl $0x3ff, %edx            # imm = 0x3FF
movq %r15, %rdi
callq 0x21440
movq %r14, %rdi
callq 0x213a0
leaq 0x99a18(%rip), %rsi     # 0xc6152
pushq $0x5
popq %rdx
movq %r15, %rdi
callq 0x21920
testl %eax, %eax
je 0x2c7c3
movl $0x0, 0x1c(%rsp)
leaq 0x99a00(%rip), %rdi     # 0xc6158
leaq 0x3a30(%rsp), %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x7e83e
jmp 0x2e235
xorl %ebp, %ebp
leaq 0x99989(%rip), %rdi     # 0xc6101
movq %rbx, %rsi
xorl %eax, %eax
callq 0x7e83e
jmp 0x2e260
movl $0x0, 0x1c(%rsp)
leaq 0x99989(%rip), %rdi     # 0xc611f
movq %rbx, %rsi
xorl %eax, %eax
callq 0x7e83e
jmp 0x2e24f
movl $0x0, 0x1c(%rsp)
leaq 0x9997e(%rip), %rdi     # 0xc6132
movq %rbx, %rsi
xorl %eax, %eax
callq 0x7e83e
jmp 0x2e235
leaq 0x989da(%rip), %rsi     # 0xc51a4
leaq 0x1e30(%rsp), %rdi
movl $0x3ff, %edx            # imm = 0x3FF
callq 0x21440
leaq 0x9a868(%rip), %rdx     # 0xc704b
leaq 0x8(%rsp), %rdi
leaq 0x168(%rsp), %rsi
pushq $0x4
popq %rcx
callq 0x32249
testl %eax, %eax
je 0x2c833
movq 0x8(%rsp), %rsi
leaq 0x630(%rsp), %rdi
callq 0x80236
leaq 0x630(%rsp), %rbx
movq (%rbx), %rsi
leaq 0x1e30(%rsp), %rdi
movl $0x3ff, %edx            # imm = 0x3FF
callq 0x21440
movq %rbx, %rdi
callq 0x213a0
leaq 0x1f0(%rsp), %rdi
movsd 0x987d5(%rip), %xmm1    # 0xc5018
xorpd %xmm0, %xmm0
xorps %xmm2, %xmm2
callq 0x6c034
leaq 0x9ef4d(%rip), %rdx     # 0xcb7a3
leaq 0x30(%rsp), %rdi
leaq 0x168(%rsp), %rsi
pushq $0x6
popq %rcx
callq 0x32249
testl %eax, %eax
je 0x2c90a
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
callq 0x83dd2
cmpl $0x3, %eax
jb 0x2c90a
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x322e6
testl %eax, %eax
je 0x2c8af
movq 0x10(%rsp), %rdi
callq 0x85794
movsd %xmm0, 0x1f0(%rsp)
leaq 0x10(%rsp), %rdi
pushq $0x1
popq %rdx
movq %rbx, %rsi
callq 0x322e6
testl %eax, %eax
je 0x2c8d6
movq 0x10(%rsp), %rdi
callq 0x85794
movsd %xmm0, 0x1f8(%rsp)
leaq 0x10(%rsp), %rdi
pushq $0x2
popq %rdx
movq %rbx, %rsi
callq 0x322e6
testl %eax, %eax
je 0x2c8fd
movq 0x10(%rsp), %rdi
callq 0x85794
movsd %xmm0, 0x200(%rsp)
leaq 0x1f0(%rsp), %rdi
callq 0x6c336
leaq 0x1d8(%rsp), %rdi
movsd 0x986fe(%rip), %xmm2    # 0xc5018
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
movsd %xmm2, 0x28(%rsp)
callq 0x6c034
leaq 0x9984e(%rip), %rdx     # 0xc6182
leaq 0x30(%rsp), %rdi
leaq 0x168(%rsp), %rsi
pushq $0x6
popq %rcx
callq 0x32249
testl %eax, %eax
je 0x2c9e8
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
callq 0x83dd2
cmpl $0x3, %eax
jb 0x2c9e8
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x322e6
testl %eax, %eax
je 0x2c98d
movq 0x10(%rsp), %rdi
callq 0x85794
movsd %xmm0, 0x1d8(%rsp)
leaq 0x10(%rsp), %rdi
pushq $0x1
popq %rdx
movq %rbx, %rsi
callq 0x322e6
testl %eax, %eax
je 0x2c9b4
movq 0x10(%rsp), %rdi
callq 0x85794
movsd %xmm0, 0x1e0(%rsp)
leaq 0x10(%rsp), %rdi
pushq $0x2
popq %rdx
movq %rbx, %rsi
callq 0x322e6
testl %eax, %eax
je 0x2c9db
movq 0x10(%rsp), %rdi
callq 0x85794
movsd %xmm0, 0x1e8(%rsp)
leaq 0x1d8(%rsp), %rdi
callq 0x6c336
leaq 0x99799(%rip), %rdx     # 0xc6188
leaq 0x8(%rsp), %rdi
leaq 0x168(%rsp), %rsi
xorl %ecx, %ecx
callq 0x32249
testl %eax, %eax
je 0x2ca17
movq 0x8(%rsp), %rdi
callq 0x85794
movsd %xmm0, 0x28(%rsp)
leaq 0x1e30(%rsp), %rsi
movq 0xb8(%rsp), %rdi
callq 0x38b2e
leaq 0x109c6d(%rip), %rsi    # 0x1366a0
leaq 0x410(%rsp), %rdi
callq 0x34464
leaq 0x410(%rsp), %rdi
movsd 0x28(%rsp), %xmm0
callq 0x3457c
leaq 0x410(%rsp), %rsi
movq 0xb8(%rsp), %rdi
callq 0x38b02
leaq 0x99727(%rip), %rdx     # 0xc6196
leaq 0x160(%rsp), %rdi
leaq 0x168(%rsp), %rsi
pushq $0x6
popq %rcx
callq 0x32249
testl %eax, %eax
je 0x2e220
pushq $0x1
popq %rax
movl %eax, 0x1c(%rsp)
movq 0x20(%rsp), %rax
leaq 0x58(%rax), %rcx
movq %rcx, 0x68(%rsp)
addq $0x28, %rax
movq %rax, 0x130(%rsp)
movl $0x0, 0x44(%rsp)
movq 0x160(%rsp), %rbx
movq %rbx, %rdi
callq 0x83dd2
movl 0x44(%rsp), %edx
cmpl %eax, %edx
jae 0x2e228
leaq 0x158(%rsp), %rdi
movq %rbx, %rsi
callq 0x322e6
testl %eax, %eax
je 0x2e220
movq 0x158(%rsp), %r14
movq %r14, %rdi
callq 0x84e4c
cmpl $0x7, %eax
jne 0x2e200
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
leaq 0x9a01b(%rip), %rdx     # 0xc6b2f
xorl %ecx, %ecx
callq 0x32249
testl %eax, %eax
je 0x2cb7d
movq 0x8(%rsp), %rsi
leaq 0x630(%rsp), %rdi
callq 0x80236
leaq 0x2230(%rsp), %r12
movq %r12, %rdi
leaq 0xa0054(%rip), %rsi     # 0xccb97
leaq 0x3630(%rsp), %rdx
callq 0x3438a
leaq 0x630(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x34592
movl %eax, %ebx
movq %r12, %rdi
callq 0x213a0
movq %r15, %rdi
callq 0x213a0
testb %bl, %bl
jne 0x2e200
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
leaq 0x9a4bf(%rip), %rdx     # 0xc704b
xorl %ecx, %ecx
callq 0x32249
movl 0x44(%rsp), %ebx
testl %eax, %eax
je 0x2cbc7
movq 0x8(%rsp), %rsi
leaq 0x630(%rsp), %r15
movq %r15, %rdi
callq 0x80236
movq 0x630(%rsp), %rdi
callq 0x21ef0
movl %eax, %ebx
movq %r15, %rdi
callq 0x213a0
leaq 0x3630(%rsp), %rdi
leaq 0x995c7(%rip), %rsi     # 0xc619d
movl %ebx, %edx
xorl %eax, %eax
callq 0x21140
movl $0x1b0, %edi            # imm = 0x1B0
callq 0x218d0
movq %rax, %rbx
movq %rax, %rdi
movq 0x20(%rsp), %rsi
callq 0x37a1e
movq %rbx, %rdi
leaq 0x3630(%rsp), %rsi
callq 0x38b2e
movq 0xb8(%rsp), %rdi
movq %rbx, %rsi
callq 0x3898c
movq %rbx, 0x70(%rsp)
leaq 0xf8(%rsp), %rdi
movq %r14, %rsi
leaq 0x99576(%rip), %rdx     # 0xc61a6
pushq $0x6
popq %rcx
callq 0x32249
testl %eax, %eax
je 0x2e200
movq 0xf8(%rsp), %rbx
movq %rbx, %rdi
callq 0x83dd2
testl %eax, %eax
je 0x2e200
movq %rbx, %rdi
callq 0x83dd2
movl %eax, %edi
shlq $0x3, %rdi
callq 0x21040
movq %rax, 0x38(%rsp)
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x83dd2
movl %eax, %eax
cmpq %rax, %r14
jae 0x2cc91
movq 0x38(%rsp), %rax
andq $0x0, (%rax,%r14,8)
incq %r14
jmp 0x2cc73
movq $0x0, 0x48(%rsp)
movq 0xf8(%rsp), %r14
movq %r14, %rdi
callq 0x83dd2
movl %eax, %eax
movq 0x48(%rsp), %rdx
cmpq %rax, %rdx
jae 0x2e0b6
leaq 0xc8(%rsp), %rdi
movq %r14, %rsi
callq 0x322e6
testl %eax, %eax
je 0x2e0ac
movq 0xc8(%rsp), %rdi
movq %rdi, %r13
callq 0x84e4c
cmpl $0x7, %eax
jne 0x2e0ac
movl $0x400, %edx            # imm = 0x400
leaq 0x1630(%rsp), %rdi
xorl %esi, %esi
callq 0x21490
movl $0x400, %edx            # imm = 0x400
leaq 0x1a30(%rsp), %rdi
xorl %esi, %esi
callq 0x21490
movl $0x400, %edx            # imm = 0x400
leaq 0x3230(%rsp), %rdi
xorl %esi, %esi
callq 0x21490
leaq 0x8(%rsp), %rdi
movq %r13, %rsi
leaq 0x99df9(%rip), %rdx     # 0xc6b2f
xorl %ecx, %ecx
callq 0x32249
testl %eax, %eax
je 0x2cd9f
movq 0x8(%rsp), %rsi
leaq 0x630(%rsp), %rdi
callq 0x80236
leaq 0x2230(%rsp), %r15
movq %r15, %rdi
leaq 0x9fe32(%rip), %rsi     # 0xccb97
leaq 0x300(%rsp), %rdx
callq 0x3438a
leaq 0x630(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x34592
movl %eax, %ebx
movq %r15, %rdi
callq 0x213a0
movq %r14, %rdi
callq 0x213a0
testb %bl, %bl
jne 0x2e0ac
leaq 0x8(%rsp), %rdi
movq %r13, %rsi
leaq 0x9a29d(%rip), %rdx     # 0xc704b
xorl %ecx, %ecx
callq 0x32249
testl %eax, %eax
je 0x2cdf0
movq 0x8(%rsp), %rsi
leaq 0x630(%rsp), %rbx
movq %rbx, %rdi
callq 0x80236
movq 0x630(%rsp), %rsi
movl $0x3ff, %edx            # imm = 0x3FF
leaq 0x1630(%rsp), %rdi
callq 0x21440
movq %rbx, %rdi
callq 0x213a0
leaq 0x8(%rsp), %rdi
movq %r13, %rsi
leaq 0xa4bc2(%rip), %rdx     # 0xd19c1
xorl %ecx, %ecx
callq 0x32249
testl %eax, %eax
je 0x2ce41
movq 0x8(%rsp), %rsi
leaq 0x630(%rsp), %rbx
movq %rbx, %rdi
callq 0x80236
movq 0x630(%rsp), %rsi
movl $0x3ff, %edx            # imm = 0x3FF
leaq 0x3230(%rsp), %rdi
callq 0x21440
movq %rbx, %rdi
callq 0x213a0
leaq 0x8(%rsp), %rdi
movq %r13, %rsi
leaq 0x9935c(%rip), %rdx     # 0xc61ac
xorl %ecx, %ecx
callq 0x32249
testl %eax, %eax
je 0x2ce92
movq 0x8(%rsp), %rsi
leaq 0x630(%rsp), %rbx
movq %rbx, %rdi
callq 0x80236
movq 0x630(%rsp), %rsi
movl $0x3ff, %edx            # imm = 0x3FF
leaq 0x1a30(%rsp), %rdi
callq 0x21440
movq %rbx, %rdi
callq 0x213a0
leaq 0x8(%rsp), %rdi
movq %r13, %rsi
leaq 0x99313(%rip), %rdx     # 0xc61b4
xorl %ecx, %ecx
callq 0x32249
testl %eax, %eax
je 0x2cf10
movq 0x8(%rsp), %rsi
leaq 0x630(%rsp), %rdi
callq 0x80236
leaq 0x2230(%rsp), %r14
movq %r14, %rdi
leaq 0xa7886(%rip), %rsi     # 0xd4756
leaq 0x300(%rsp), %rdx
callq 0x3438a
leaq 0x630(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x34592
movl %eax, %ebp
movq %r14, %rdi
callq 0x213a0
movq %rbx, %rdi
callq 0x213a0
xorb $0x1, %bpl
movb %bpl, 0x80(%rsp)
jmp 0x2cf18
movb $0x1, 0x80(%rsp)
leaq 0x8(%rsp), %rdi
movq %r13, %rsi
leaq 0x99299(%rip), %rdx     # 0xc61c0
xorl %ecx, %ecx
callq 0x32249
testl %eax, %eax
je 0x2cf93
movq 0x8(%rsp), %rsi
leaq 0x630(%rsp), %rdi
callq 0x80236
leaq 0x2230(%rsp), %r14
movq %r14, %rdi
leaq 0xa7800(%rip), %rsi     # 0xd4756
leaq 0x300(%rsp), %rdx
callq 0x3438a
leaq 0x630(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x34592
movl %eax, %ebp
movq %r14, %rdi
callq 0x213a0
movq %rbx, %rdi
callq 0x213a0
xorb $0x1, %bpl
movb %bpl, 0x28(%rsp)
jmp 0x2cf98
movb $0x1, 0x28(%rsp)
leaq 0x8(%rsp), %rdi
movq %r13, %rsi
leaq 0x99223(%rip), %rdx     # 0xc61ca
xorl %ecx, %ecx
callq 0x32249
testl %eax, %eax
je 0x2d013
movq 0x8(%rsp), %rsi
leaq 0x630(%rsp), %rdi
callq 0x80236
leaq 0x2230(%rsp), %r14
movq %r14, %rdi
leaq 0xa7780(%rip), %rsi     # 0xd4756
leaq 0x300(%rsp), %rdx
callq 0x3438a
leaq 0x630(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x34592
movl %eax, %ebp
movq %r14, %rdi
callq 0x213a0
movq %rbx, %rdi
callq 0x213a0
xorb $0x1, %bpl
movb %bpl, 0x78(%rsp)
jmp 0x2d018
movb $0x1, 0x78(%rsp)
leaq 0x8(%rsp), %rdi
movq %r13, %rsi
leaq 0x991ad(%rip), %rdx     # 0xc61d4
xorl %ecx, %ecx
callq 0x32249
testl %eax, %eax
je 0x2d08e
movq 0x8(%rsp), %rsi
leaq 0x630(%rsp), %rdi
callq 0x80236
leaq 0x2230(%rsp), %r15
movq %r15, %rdi
leaq 0xa7700(%rip), %rsi     # 0xd4756
leaq 0x300(%rsp), %rdx
callq 0x3438a
leaq 0x630(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x34592
movl %eax, %ebx
movq %r15, %rdi
callq 0x213a0
movq %r14, %rdi
callq 0x213a0
movzbl %bl, %r14d
jmp 0x2d091
xorl %r14d, %r14d
leaq 0x8(%rsp), %rdi
movq %r13, %rsi
leaq 0x9913f(%rip), %rdx     # 0xc61df
xorl %ecx, %ecx
callq 0x32249
leaq 0x991c7(%rip), %r15     # 0xc6275
testl %eax, %eax
je 0x2d11c
movq 0x8(%rsp), %rsi
leaq 0x630(%rsp), %rdi
callq 0x80236
leaq 0x2230(%rsp), %r12
movq %r12, %rdi
leaq 0xa7680(%rip), %rsi     # 0xd4756
leaq 0x300(%rsp), %rdx
callq 0x3438a
leaq 0x630(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x34592
movl %eax, %ebx
movq %r12, %rdi
callq 0x213a0
movq %r15, %rdi
callq 0x213a0
testb %bl, %bl
leaq 0x99164(%rip), %r15     # 0xc6275
leaq 0x99147(%rip), %rax     # 0xc625f
cmovneq %rax, %r15
leaq 0x300(%rsp), %rdi
leaq 0x109575(%rip), %rsi    # 0x1366a0
callq 0x34464
leaq 0x30(%rsp), %rdi
movq %r13, %rsi
leaq 0x98d2f(%rip), %rdx     # 0xc5e6e
pushq $0x6
popq %rcx
callq 0x32249
testl %eax, %eax
je 0x2d1d7
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
callq 0x83dd2
cmpl $0x10, %eax
jb 0x2d1d7
leaq 0x630(%rsp), %rdi
leaq 0x9aa48(%rip), %rsi     # 0xc7bb8
callq 0x68778
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x83dd2
cmpl %eax, %ebp
jae 0x2d1bf
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
movl %ebp, %edx
callq 0x322e6
testl %eax, %eax
je 0x2d1bb
movq 0x10(%rsp), %rdi
callq 0x85794
movl %ebp, %eax
andl $0x3, %eax
shll $0x5, %eax
addq %rsp, %rax
addq $0x630, %rax            # imm = 0x630
movl %ebp, %ecx
shrl $0x2, %ecx
movsd %xmm0, (%rax,%rcx,8)
incl %ebp
jmp 0x2d177
leaq 0x300(%rsp), %rdi
leaq 0x630(%rsp), %rsi
movl %r14d, %edx
callq 0x66e52
leaq 0x3230(%rsp), %rbx
movq %rbx, %rdi
leaq 0x98ffc(%rip), %rsi     # 0xc61e5
pushq $0x7
popq %rdx
callq 0x21920
testl %eax, %eax
je 0x2d8b6
movq %rbx, %rdi
leaq 0x99006(%rip), %rsi     # 0xc6209
pushq $0x5
popq %rdx
callq 0x21920
testl %eax, %eax
je 0x2da0f
movq %rbx, %rdi
leaq 0x9903b(%rip), %rsi     # 0xc6258
pushq $0x7
popq %rdx
callq 0x21920
testl %eax, %eax
je 0x2de15
cmpl $0x786f42, 0x3230(%rsp) # imm = 0x786F42
jne 0x2e09f
movapd 0x998fa(%rip), %xmm0    # 0xc6b40
movapd %xmm0, 0x110(%rsp)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x120(%rsp)
leaq 0x30(%rsp), %rdi
movq %r13, %rsi
leaq 0x9902c(%rip), %rdx     # 0xc629c
pushq $0x6
popq %rcx
callq 0x32249
testl %eax, %eax
je 0x2d306
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
callq 0x83dd2
cmpl $0x3, %eax
jb 0x2d306
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x322e6
testl %eax, %eax
je 0x2d2b8
movq 0x10(%rsp), %rdi
callq 0x85794
movsd %xmm0, 0x110(%rsp)
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
pushq $0x1
popq %rdx
callq 0x322e6
testl %eax, %eax
je 0x2d2df
movq 0x10(%rsp), %rdi
callq 0x85794
movsd %xmm0, 0x118(%rsp)
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
pushq $0x2
popq %rdx
callq 0x322e6
testl %eax, %eax
je 0x2d306
movq 0x10(%rsp), %rdi
callq 0x85794
movsd %xmm0, 0x120(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0x7c1c6
leaq 0xc0(%rsp), %rdi
movq %r13, %rsi
leaq 0x97f1d(%rip), %rdx     # 0xc5242
pushq $0x6
popq %rcx
callq 0x32249
testl %eax, %eax
je 0x2d35e
movq 0xc0(%rsp), %r8
movq 0x20(%rsp), %rdi
leaq 0x98(%rsp), %rsi
leaq 0xe0(%rsp), %rcx
movq %rcx, %rdx
callq 0x32350
testl %eax, %eax
je 0x2e28e
movl $0x1b0, %edi            # imm = 0x1B0
callq 0x218d0
movq %rax, %rdi
movq 0x20(%rsp), %rsi
movq %rax, %r14
callq 0x37a1e
leaq 0x2230(%rsp), %rbx
movq %rbx, %rdi
leaq 0x98f1d(%rip), %rsi     # 0xc62a7
leaq 0x1630(%rsp), %rdx
xorl %eax, %eax
callq 0x21140
movq %r14, %rdi
movq %rbx, %rsi
callq 0x38b2e
movq %r14, %rdi
leaq 0x300(%rsp), %rsi
movq %r14, 0x88(%rsp)
callq 0x38b02
movq 0x88(%rsp), %rsi
leaq 0x99795(%rip), %rax     # 0xc6b60
movq %rax, 0xf0(%rsp)
xorl %ecx, %ecx
cmpq $0x2, %rcx
je 0x2e06f
xorl %eax, %eax
movq %rcx, 0x138(%rsp)
testq %rcx, %rcx
sete %al
leaq 0x9815a(%rip), %rcx     # 0xc5550
movsd (%rcx,%rax,8), %xmm0
movsd %xmm0, 0x78(%rsp)
leaq 0x109450(%rip), %rsi    # 0x136858
xorl %r13d, %r13d
cmpq $0x3, %r13
je 0x2d895
movq %r13, %rcx
incq %r13
leal -0x1(%rcx), %ebx
cmpq $0x1, %r13
pushq $0x2
popq %rax
cmovel %eax, %ebx
cmpq $0x3, %r13
movl $0x0, %r14d
cmovneq %r13, %r14
movsd 0x110(%rsp,%r14,8), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x110(%rsp,%rbx,8), %xmm1
movq %rcx, 0x148(%rsp)
movsd 0x110(%rsp,%rcx,8), %xmm0
mulsd 0x78(%rsp), %xmm0
movsd %xmm1, 0x80(%rsp)
mulsd 0x97bc9(%rip), %xmm1    # 0xc5040
movsd %xmm1, 0x150(%rsp)
leaq 0x50(%rsp), %rdi
movq %rsi, 0x140(%rsp)
callq 0x6c72a
movsd 0x78(%rsp), %xmm0
mulsd 0x28(%rsp), %xmm0
imulq $0x18, %r14, %rsi
addq 0x100aff(%rip), %rsi    # 0x12dfa8
leaq 0xa0(%rsp), %rdi
callq 0x6c72a
movslq %ebx, %rax
imulq $0x18, %rax, %rsi
addq 0x100ae4(%rip), %rsi    # 0x12dfa8
leaq 0x220(%rsp), %rdi
movsd 0x150(%rsp), %xmm0
callq 0x6c72a
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
xorps %xmm2, %xmm2
leaq 0x208(%rsp), %rdi
callq 0x6b874
leaq 0x1c0(%rsp), %rdi
leaq 0x208(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x6bb3b
leaq 0x250(%rsp), %rdi
leaq 0x1c0(%rsp), %rsi
leaq 0xa0(%rsp), %rdx
callq 0x6bfc5
leaq 0x2a8(%rsp), %rdi
leaq 0x250(%rsp), %rsi
leaq 0x220(%rsp), %rdx
callq 0x6bfc5
leaq 0x1a8(%rsp), %rdi
leaq 0x208(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x6bb3b
leaq 0x1c0(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
leaq 0xa0(%rsp), %rdx
callq 0x6bb3b
leaq 0x250(%rsp), %rdi
leaq 0x1c0(%rsp), %rsi
leaq 0x220(%rsp), %rdx
callq 0x6bfc5
leaq 0x190(%rsp), %rdi
leaq 0x208(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x6bb3b
leaq 0x1a8(%rsp), %rdi
leaq 0x190(%rsp), %rsi
leaq 0xa0(%rsp), %rdx
callq 0x6bb3b
leaq 0x1c0(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
leaq 0x220(%rsp), %rdx
callq 0x6bb3b
leaq 0x238(%rsp), %rdi
leaq 0x208(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x6bb3b
leaq 0x190(%rsp), %rdi
leaq 0x238(%rsp), %rsi
leaq 0xa0(%rsp), %rdx
callq 0x6bfc5
leaq 0x1a8(%rsp), %rdi
leaq 0x190(%rsp), %rsi
leaq 0x220(%rsp), %rdx
callq 0x6bb3b
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
leaq 0x190(%rsp), %rdi
callq 0x76d94
xorpd %xmm1, %xmm1
leaq 0x238(%rsp), %rdi
movsd 0x28(%rsp), %xmm0
callq 0x76d94
leaq 0x298(%rsp), %rdi
movsd 0x28(%rsp), %xmm0
movsd 0x80(%rsp), %xmm1
callq 0x76d94
xorpd %xmm0, %xmm0
leaq 0x288(%rsp), %rdi
movsd 0x80(%rsp), %xmm1
callq 0x76d94
leaq 0xd0(%rsp), %rdi
callq 0x7c1c6
pushq $0x68
popq %rdi
callq 0x218d0
movq %rax, %r15
movq %rax, %rdi
leaq 0x2a8(%rsp), %rsi
leaq 0x190(%rsp), %rdx
callq 0x60a84
leaq 0xd0(%rsp), %rdi
movq %r15, %rsi
callq 0x2737a
pushq $0x68
popq %rdi
callq 0x218d0
movq %rax, %rbx
movq %rax, %rdi
leaq 0x250(%rsp), %rsi
leaq 0x238(%rsp), %rdx
callq 0x60a84
leaq 0xd0(%rsp), %rdi
movq %rbx, %rsi
callq 0x2737a
pushq $0x68
popq %rdi
callq 0x218d0
movq %rax, %rbp
movq %rax, %rdi
leaq 0x1c0(%rsp), %rsi
leaq 0x298(%rsp), %rdx
callq 0x60a84
leaq 0xd0(%rsp), %rdi
movq %rbp, %rsi
callq 0x2737a
pushq $0x68
popq %rdi
callq 0x218d0
movq %rax, %r12
movq %rax, %rdi
leaq 0x1a8(%rsp), %rsi
leaq 0x288(%rsp), %rdx
callq 0x60a84
leaq 0xd0(%rsp), %rdi
movq %r12, %rsi
callq 0x2737a
leaq 0x100(%rsp), %rdi
callq 0x7c1c6
movl $0x88, %edi
callq 0x218d0
movq %rax, %r14
movq %rax, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %rbp, %rcx
callq 0x60de0
leaq 0x100(%rsp), %rdi
movq %r14, %rsi
callq 0x2737a
movl $0x88, %edi
callq 0x218d0
movq %rax, %rbx
movq %rax, %rdi
movq %r15, %rsi
movq %rbp, %rdx
movq %r12, %rcx
callq 0x60de0
leaq 0x100(%rsp), %rdi
movq %rbx, %rsi
callq 0x2737a
pushq $0x70
popq %rdi
callq 0x218d0
movq %rax, %rbx
movq %rax, %rdi
leaq 0xd0(%rsp), %rsi
leaq 0x100(%rsp), %rdx
callq 0x5f2ae
movq 0xf0(%rsp), %rax
movq 0x148(%rsp), %rcx
movslq (%rax,%rcx,4), %rax
leaq 0x1069ac(%rip), %r14    # 0x1341d0
cmpl %eax, 0xec(%rsp)
jle 0x2d839
movq 0xe0(%rsp), %rcx
movq (%rcx,%rax,8), %r14
pushq $0x60
popq %rdi
callq 0x218d0
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x394c0
movq %r15, %rdi
movq %rbx, %rsi
callq 0x3971a
movq 0x88(%rsp), %rdi
movq %r15, %rsi
callq 0x389c8
leaq 0x100(%rsp), %rdi
callq 0x7c234
leaq 0xd0(%rsp), %rdi
callq 0x7c234
movq 0x140(%rsp), %rsi
addq $0x18, %rsi
jmp 0x2d40b
movq 0x138(%rsp), %rcx
incq %rcx
addq $0xc, 0xf0(%rsp)
movq 0x88(%rsp), %rsi
jmp 0x2d3d5
leaq 0x630(%rsp), %rdi
leaq 0x98927(%rip), %rsi     # 0xc61ec
leaq 0x9882c(%rip), %rdx     # 0xc60f8
leaq 0x1e30(%rsp), %rcx
leaq 0x1a30(%rsp), %r8
xorl %eax, %eax
callq 0x21140
cmpb $0x0, 0x28(%rsp)
je 0x2e09f
leaq 0x630(%rsp), %rdi
callq 0x7de10
testl %eax, %eax
je 0x2e09f
movl $0x160, %edi            # imm = 0x160
callq 0x218d0
movq %rax, %r14
movq %rax, %rdi
callq 0x273f6
movq (%r14), %rsi
movq %r14, %rdi
leaq 0x630(%rsp), %rdx
callq 0x2ede6
testl %eax, %eax
je 0x2e213
leaq 0x2230(%rsp), %rbx
movq %rbx, %rdi
leaq 0x988ba(%rip), %rsi     # 0xc61ff
leaq 0x1630(%rsp), %rdx
xorl %eax, %eax
callq 0x21140
movq %r14, %rdi
movq %rbx, %rsi
callq 0x27a52
movq (%r14), %rdi
leaq 0x2230(%rsp), %rsi
callq 0x38b2e
movq %r14, %rdi
leaq 0x630(%rsp), %rsi
callq 0x3442e
movq 0x68(%rsp), %rdi
movq %r14, %rsi
callq 0x2737a
movl $0x1b0, %edi            # imm = 0x1B0
callq 0x218d0
movq %rax, %rbx
movq %rax, %rdi
movq 0x20(%rsp), %rsi
callq 0x37a1e
pushq $0x30
popq %rdi
callq 0x218d0
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
movq 0x130(%rsp), %rdx
callq 0x39bce
movq %rbx, %rdi
movq %r15, %rsi
callq 0x389e2
movq %rbx, %rdi
leaq 0x2230(%rsp), %rsi
callq 0x38b2e
movq %rbx, %rdi
leaq 0x300(%rsp), %rsi
callq 0x38b02
movq 0x70(%rsp), %rdi
movq %rbx, %rsi
callq 0x3898c
movq 0x38(%rsp), %rax
movq 0x48(%rsp), %rcx
movq %rbx, (%rax,%rcx,8)
jmp 0x2e09f
movl $0x1b0, %edi            # imm = 0x1B0
callq 0x218d0
movq %rax, %r14
movq %rax, %rdi
movq 0x20(%rsp), %rsi
callq 0x37a1e
leaq 0x2230(%rsp), %rbx
movq %rbx, %rdi
leaq 0x987d3(%rip), %rsi     # 0xc620e
leaq 0x1630(%rsp), %rdx
xorl %eax, %eax
callq 0x21140
movq %r14, %rdi
movq %rbx, %rsi
callq 0x38b2e
movq 0x70(%rsp), %rdi
movq %r14, %rsi
callq 0x3898c
movq 0x38(%rsp), %rax
movq 0x48(%rsp), %rcx
movq %r14, (%rax,%rcx,8)
leaq 0x50(%rsp), %rdi
callq 0x7c1c6
leaq 0x630(%rsp), %rdi
leaq 0x98763(%rip), %rsi     # 0xc61ec
leaq 0x98668(%rip), %rdx     # 0xc60f8
leaq 0x1e30(%rsp), %rcx
leaq 0x1a30(%rsp), %r8
xorl %eax, %eax
callq 0x21140
cmpb $0x0, 0x28(%rsp)
je 0x2dbab
leaq 0x630(%rsp), %rdi
callq 0x7de10
testl %eax, %eax
je 0x2dbab
movl $0x160, %edi            # imm = 0x160
callq 0x218d0
movq %rax, %r15
movq %rax, %rdi
callq 0x273f6
movq (%r15), %rsi
movq %r15, %rdi
leaq 0x630(%rsp), %rdx
callq 0x2ede6
testl %eax, %eax
je 0x2e209
leaq 0x2230(%rsp), %rbx
movq %rbx, %rdi
leaq 0x9870d(%rip), %rsi     # 0xc6216
leaq 0x1630(%rsp), %rdx
xorl %eax, %eax
callq 0x21140
movq %r15, %rdi
movq %rbx, %rsi
callq 0x27a52
movq (%r15), %rdi
leaq 0x2230(%rsp), %rsi
callq 0x38b2e
movq %r15, %rdi
leaq 0x630(%rsp), %rsi
callq 0x3442e
movq 0x68(%rsp), %rdi
movq %r15, %rsi
callq 0x2737a
movl $0x1b0, %edi            # imm = 0x1B0
callq 0x218d0
movq %rax, %rbx
movq %rax, %rdi
movq 0x20(%rsp), %rsi
callq 0x37a1e
pushq $0x30
popq %rdi
callq 0x218d0
movq %rax, %r12
movq %rax, %rdi
movq %r15, %rsi
leaq 0x50(%rsp), %rdx
callq 0x39bce
movq %rbx, %rdi
movq %r12, %rsi
callq 0x389e2
movq %rbx, %rdi
leaq 0x2230(%rsp), %rsi
callq 0x38b2e
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3898c
leaq 0x630(%rsp), %rdi
leaq 0x98665(%rip), %rsi     # 0xc621f
leaq 0x98537(%rip), %rdx     # 0xc60f8
leaq 0x1e30(%rsp), %rcx
leaq 0x1a30(%rsp), %r8
xorl %eax, %eax
callq 0x21140
cmpb $0x0, 0x80(%rsp)
je 0x2dcdf
leaq 0x630(%rsp), %rdi
callq 0x7de10
testl %eax, %eax
je 0x2dcdf
movl $0x160, %edi            # imm = 0x160
callq 0x218d0
movq %rax, %r15
movq %rax, %rdi
callq 0x273f6
movq (%r15), %rsi
movq %r15, %rdi
leaq 0x630(%rsp), %rdx
callq 0x2ede6
testl %eax, %eax
je 0x2e209
leaq 0x2230(%rsp), %rbx
movq %rbx, %rdi
leaq 0x985f5(%rip), %rsi     # 0xc6232
leaq 0x1630(%rsp), %rdx
xorl %eax, %eax
callq 0x21140
movq %r15, %rdi
movq %rbx, %rsi
callq 0x27a52
movq (%r15), %rdi
leaq 0x2230(%rsp), %rsi
callq 0x38b2e
movq %r15, %rdi
leaq 0x630(%rsp), %rsi
callq 0x3442e
movq 0x68(%rsp), %rdi
movq %r15, %rsi
callq 0x2737a
movl $0x1b0, %edi            # imm = 0x1B0
callq 0x218d0
movq %rax, %rbx
movq %rax, %rdi
movq 0x20(%rsp), %rsi
callq 0x37a1e
pushq $0x30
popq %rdi
callq 0x218d0
movq %rax, %r12
movq %rax, %rdi
movq %r15, %rsi
leaq 0x50(%rsp), %rdx
callq 0x39bce
movq %rbx, %rdi
movq %r12, %rsi
callq 0x389e2
movq %rbx, %rdi
leaq 0x2230(%rsp), %rsi
callq 0x38b2e
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3898c
leaq 0x630(%rsp), %rdi
leaq 0x9854f(%rip), %rsi     # 0xc623d
leaq 0x98403(%rip), %rdx     # 0xc60f8
leaq 0x1e30(%rsp), %rcx
leaq 0x1a30(%rsp), %r8
xorl %eax, %eax
callq 0x21140
cmpb $0x0, 0x78(%rsp)
je 0x2e068
leaq 0x630(%rsp), %rdi
callq 0x7de10
testl %eax, %eax
je 0x2e068
movl $0x160, %edi            # imm = 0x160
callq 0x218d0
movq %rax, %r15
movq %rax, %rdi
callq 0x273f6
movq (%r15), %rsi
movq %r15, %rdi
leaq 0x630(%rsp), %rdx
callq 0x2ede6
testl %eax, %eax
je 0x2e209
leaq 0x2230(%rsp), %rbx
movq %rbx, %rdi
leaq 0x984e2(%rip), %rsi     # 0xc6250
leaq 0x1630(%rsp), %rdx
xorl %eax, %eax
callq 0x21140
movq %r15, %rdi
movq %rbx, %rsi
callq 0x27a52
movq (%r15), %rdi
leaq 0x2230(%rsp), %rsi
callq 0x38b2e
movq %r15, %rdi
leaq 0x630(%rsp), %rsi
callq 0x3442e
movq 0x68(%rsp), %rdi
movq %r15, %rsi
callq 0x2737a
movl $0x1b0, %edi            # imm = 0x1B0
callq 0x218d0
movq %rax, %rbx
movq %rax, %rdi
movq 0x20(%rsp), %rsi
callq 0x37a1e
pushq $0x30
popq %rdi
callq 0x218d0
movq %rax, %r12
movq %rax, %rdi
movq %r15, %rsi
leaq 0x50(%rsp), %rdx
callq 0x39bce
movq %rbx, %rdi
movq %r12, %rsi
callq 0x389e2
movq %rbx, %rdi
leaq 0x2230(%rsp), %rsi
callq 0x38b2e
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3898c
jmp 0x2e068
andq $0x0, 0xa0(%rsp)
leaq 0x630(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
leaq 0x982c5(%rip), %rdx     # 0xc60f8
leaq 0x1a30(%rsp), %rcx
movq %rcx, %r8
xorl %eax, %eax
callq 0x21140
leaq 0x2e0(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
leaq 0x50(%rsp), %rdx
callq 0x3438a
leaq 0x90(%rsp), %rdi
movq %r14, %rsi
leaq 0xa0(%rsp), %rdx
callq 0x345bc
movl %eax, %ebx
movq %r14, %rdi
callq 0x213a0
testl %ebx, %ebx
jne 0x2df6f
movl $0x160, %edi            # imm = 0x160
callq 0x218d0
movq %rax, %rbx
movq %rax, %rdi
callq 0x273f6
movq %rbx, 0xa0(%rsp)
movq (%rbx), %rsi
movq %rbx, %rdi
leaq 0x630(%rsp), %rdx
callq 0x2ede6
testl %eax, %eax
je 0x2e213
leaq 0x2230(%rsp), %rdi
leaq 0x983bb(%rip), %rsi     # 0xc6289
leaq 0x1a30(%rsp), %rbx
movq %rbx, %rdx
xorl %eax, %eax
callq 0x21140
movq 0xa0(%rsp), %rdi
movq %rbx, %rsi
callq 0x27a52
movq 0xa0(%rsp), %rax
movq (%rax), %rdi
leaq 0x2230(%rsp), %rsi
callq 0x38b2e
movq 0xa0(%rsp), %rdi
leaq 0x630(%rsp), %rsi
callq 0x3442e
movq 0xa0(%rsp), %rsi
movq 0x68(%rsp), %rdi
callq 0x2737a
leaq 0x2c0(%rsp), %r14
movq %r14, %rdi
leaq 0x630(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x3438a
movq 0xa0(%rsp), %rbx
movq 0x90(%rsp), %rdi
movq %r14, %rsi
callq 0x372d8
movq %rbx, (%rax)
movq %r14, %rdi
callq 0x213a0
leaq 0x50(%rsp), %rdi
callq 0x7c1c6
leaq 0xc0(%rsp), %rdi
movq %r13, %rsi
leaq 0x972b7(%rip), %rdx     # 0xc5242
pushq $0x6
popq %rcx
callq 0x32249
testl %eax, %eax
je 0x2dfca
movq 0xa0(%rsp), %rdx
addq $0x28, %rdx
movq 0xc0(%rsp), %r8
movq 0x20(%rsp), %rdi
leaq 0x98(%rsp), %rsi
leaq 0x50(%rsp), %rcx
callq 0x32350
testl %eax, %eax
je 0x2e209
movl $0x1b0, %edi            # imm = 0x1B0
callq 0x218d0
movq %rax, %rbx
movq %rax, %rdi
movq 0x20(%rsp), %rsi
callq 0x37a1e
leaq 0x2230(%rsp), %rdi
leaq 0x9829f(%rip), %rsi     # 0xc6292
leaq 0x1630(%rsp), %rdx
xorl %eax, %eax
callq 0x21140
pushq $0x30
popq %rdi
callq 0x218d0
movq %rax, %r14
movq 0xa0(%rsp), %rsi
movq %rax, %rdi
leaq 0x50(%rsp), %rdx
callq 0x39bce
movq %rbx, %rdi
movq %r14, %rsi
callq 0x389e2
movq %rbx, %rdi
leaq 0x2230(%rsp), %rsi
callq 0x38b2e
movq %rbx, %rdi
leaq 0x300(%rsp), %rsi
callq 0x38b02
movq 0x70(%rsp), %rdi
movq %rbx, %rsi
callq 0x3898c
movq 0x38(%rsp), %rax
movq 0x48(%rsp), %rcx
movq %rbx, (%rax,%rcx,8)
leaq 0x50(%rsp), %rdi
jmp 0x2e09a
movq 0x70(%rsp), %rdi
callq 0x3898c
movq 0x88(%rsp), %rcx
movq 0x38(%rsp), %rax
movq %rcx, %rdx
movq 0x48(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
leaq 0xe0(%rsp), %rdi
callq 0x7c234
leaq 0x300(%rsp), %rdi
callq 0x66856
incq 0x48(%rsp)
jmp 0x2cc9a
xorl %r13d, %r13d
movq %r14, %rdi
callq 0x83dd2
movl %eax, %eax
cmpq %rax, %r13
jae 0x2e1f6
leaq 0xc8(%rsp), %rdi
movq %r14, %rsi
movl %r13d, %edx
callq 0x322e6
testl %eax, %eax
je 0x2e149
movq 0xc8(%rsp), %rbx
movq %rbx, %rdi
callq 0x84e4c
cmpl $0x7, %eax
jne 0x2e149
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
leaq 0xa38ba(%rip), %rdx     # 0xd19c1
xorl %ecx, %ecx
callq 0x32249
testl %eax, %eax
je 0x2e149
movq 0x8(%rsp), %rsi
leaq 0x630(%rsp), %r15
movq %r15, %rdi
callq 0x80236
movq 0x630(%rsp), %rdi
leaq 0x980d3(%rip), %rsi     # 0xc6209
callq 0x21d30
movl %eax, %ebp
movq %r15, %rdi
callq 0x213a0
testl %ebp, %ebp
je 0x2e151
incq %r13
jmp 0x2e0b9
movq 0x38(%rsp), %rax
movq (%rax,%r13,8), %r15
testq %r15, %r15
je 0x2e149
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
leaq 0x98140(%rip), %rdx     # 0xc62ae
pushq $0x6
popq %rcx
callq 0x32249
testl %eax, %eax
je 0x2e149
xorl %ebx, %ebx
movq 0x30(%rsp), %rbp
movq %rbp, %rdi
callq 0x83dd2
cmpl %eax, %ebx
jae 0x2e149
leaq 0x10(%rsp), %rdi
movq %rbp, %rsi
movl %ebx, %edx
callq 0x322e6
movq 0x10(%rsp), %r12
movq %r12, %rdi
callq 0x85af8
testb %al, %al
je 0x2e1f2
movq %r12, %rdi
callq 0x83782
movl %eax, %r12d
testl %eax, %eax
js 0x2e1f2
movq %r14, %rdi
callq 0x83dd2
cmpl %eax, %r12d
jae 0x2e1f2
movl %r12d, %eax
movq 0x38(%rsp), %rcx
movq (%rcx,%rax,8), %r12
testq %r12, %r12
je 0x2e1f2
movq 0x70(%rsp), %rdi
movq %r12, %rsi
callq 0x37de8
movq %r15, %rdi
movq %r12, %rsi
callq 0x3898c
incl %ebx
jmp 0x2e181
movq 0x38(%rsp), %rdi
callq 0x21c20
incl 0x44(%rsp)
jmp 0x2cab8
leaq 0x50(%rsp), %rdi
callq 0x7c234
leaq 0x300(%rsp), %rdi
callq 0x66856
movl $0x0, 0x1c(%rsp)
leaq 0x410(%rsp), %rdi
callq 0x66856
leaq 0x520(%rsp), %rdi
callq 0x345f8
leaq 0x168(%rsp), %rdi
callq 0x84dbc
leaq 0x268(%rsp), %rdi
callq 0x213a0
movl 0x1c(%rsp), %ebp
leaq 0x90(%rsp), %rdi
callq 0x34626
leaq 0x98(%rsp), %rdi
callq 0x34644
movl %ebp, %eax
addq $0x3e38, %rsp           # imm = 0x3E38
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xe0(%rsp), %rdi
jmp 0x2e20e
movq %rax, %r13
leaq 0x2c0(%rsp), %rdi
jmp 0x2e35a
jmp 0x2e49d
movq %rax, %r13
movl $0x160, %esi            # imm = 0x160
jmp 0x2e2fb
jmp 0x2e2c2
jmp 0x2e32a
jmp 0x2e2c2
jmp 0x2e32a
movq %rax, %r13
pushq $0x30
popq %rsi
movq %r12, %rdi
jmp 0x2e340
jmp 0x2e32a
jmp 0x2e2d3
jmp 0x2e2d3
movq %rax, %r13
movl $0x160, %esi            # imm = 0x160
movq %r15, %rdi
jmp 0x2e340
jmp 0x2e441
movq %rax, %r13
pushq $0x30
popq %rsi
movq %r15, %rdi
jmp 0x2e3a1
movq %rax, %r13
movl $0x1b0, %esi            # imm = 0x1B0
movq %rbx, %rdi
jmp 0x2e3a1
movq %rax, %r13
movl $0x160, %esi            # imm = 0x160
jmp 0x2e39e
movq %rax, %r13
movl $0x1b0, %esi            # imm = 0x1B0
movq %r14, %rdi
callq 0x218f0
jmp 0x2e53d
jmp 0x2e49d
movq %rax, %r13
movl $0x1b0, %esi            # imm = 0x1B0
movq %rbx, %rdi
jmp 0x2e340
movq %rax, %r13
pushq $0x30
popq %rsi
movq %r14, %rdi
callq 0x218f0
jmp 0x2e44c
jmp 0x2e49d
movq %rax, %r13
leaq 0x2e0(%rsp), %rdi
callq 0x213a0
jmp 0x2e54a
jmp 0x2e49d
jmp 0x2e495
jmp 0x2e441
jmp 0x2e441
jmp 0x2e441
jmp 0x2e441
jmp 0x2e49d
jmp 0x2e53a
jmp 0x2e495
jmp 0x2e49d
movq %rax, %r13
movl $0x1b0, %esi            # imm = 0x1B0
movq %r14, %rdi
callq 0x218f0
jmp 0x2e54a
jmp 0x2e449
jmp 0x2e495
jmp 0x2e441
jmp 0x2e49d
jmp 0x2e495
jmp 0x2e495
jmp 0x2e449
jmp 0x2e449
jmp 0x2e449
jmp 0x2e449
jmp 0x2e49d
jmp 0x2e441
jmp 0x2e458
jmp 0x2e495
jmp 0x2e449
jmp 0x2e449
jmp 0x2e449
movq %rax, %r13
movl $0x1b0, %esi            # imm = 0x1B0
movq %rbx, %rdi
callq 0x218f0
jmp 0x2e557
jmp 0x2e53a
movq %rax, %r13
jmp 0x2e571
jmp 0x2e475
jmp 0x2e495
jmp 0x2e458
jmp 0x2e495
jmp 0x2e458
jmp 0x2e495
jmp 0x2e458
jmp 0x2e495
jmp 0x2e458
jmp 0x2e495
jmp 0x2e49d
jmp 0x2e495
jmp 0x2e495
jmp 0x2e458
jmp 0x2e495
movq %rax, %r13
jmp 0x2e58b
jmp 0x2e49d
jmp 0x2e49d
jmp 0x2e49d
jmp 0x2e495
jmp 0x2e441
jmp 0x2e441
jmp 0x2e495
movq %rax, %r13
jmp 0x2e564
movq %rax, %r13
leaq 0x50(%rsp), %rdi
jmp 0x2e545
jmp 0x2e495
movq %rax, %r13
leaq 0x630(%rsp), %rdi
callq 0x213a0
jmp 0x2e557
jmp 0x2e495
jmp 0x2e495
jmp 0x2e495
jmp 0x2e475
movq %rax, %r13
jmp 0x2e57e
jmp 0x2e495
jmp 0x2e49d
movq %rax, %r13
jmp 0x2e598
jmp 0x2e495
jmp 0x2e495
jmp 0x2e495
jmp 0x2e495
jmp 0x2e495
jmp 0x2e495
movq %rax, %r13
jmp 0x2e557
movq %rax, %r13
jmp 0x2e54a
movq %rax, %r13
pushq $0x60
popq %rsi
movq %r15, %rdi
jmp 0x2e503
movq %rax, %r13
movl $0x88, %esi
movq %r14, %rdi
jmp 0x2e503
movq %rax, %r13
pushq $0x68
popq %rsi
movq %rbp, %rdi
jmp 0x2e4f3
movq %rax, %r13
movl $0x88, %esi
jmp 0x2e500
movq %rax, %r13
pushq $0x68
popq %rsi
movq %r15, %rdi
jmp 0x2e4f3
movq %rax, %r13
pushq $0x68
popq %rsi
movq %r12, %rdi
jmp 0x2e4f3
jmp 0x2e51b
movq %rax, %r13
pushq $0x68
popq %rsi
movq %rbx, %rdi
callq 0x218f0
jmp 0x2e52b
movq %rax, %r13
pushq $0x70
popq %rsi
movq %rbx, %rdi
callq 0x218f0
jmp 0x2e51e
jmp 0x2e516
jmp 0x2e516
jmp 0x2e516
jmp 0x2e51b
jmp 0x2e51b
jmp 0x2e516
movq %rax, %r13
jmp 0x2e52b
movq %rax, %r13
leaq 0x100(%rsp), %rdi
callq 0x7c234
leaq 0xd0(%rsp), %rdi
callq 0x7c234
jmp 0x2e53d
movq %rax, %r13
leaq 0xe0(%rsp), %rdi
callq 0x7c234
leaq 0x300(%rsp), %rdi
callq 0x66856
leaq 0x410(%rsp), %rdi
callq 0x66856
leaq 0x520(%rsp), %rdi
callq 0x345f8
leaq 0x168(%rsp), %rdi
callq 0x84dbc
leaq 0x268(%rsp), %rdi
callq 0x213a0
leaq 0x90(%rsp), %rdi
callq 0x34626
leaq 0x98(%rsp), %rdi
callq 0x34644
movq %r13, %rdi
callq 0x220e0
nop