// File: tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelScene.cpp
// Function: gaps::R3SurfelScene::WriteTianqiangFile(char const*)
int R3SurfelScene::
WriteTianqiangFile(const char *filename) 
{
  // Open file
  FILE *fp = fopen(filename, "w");
  if (!fp) {
    RNFail("Unable to open file %s\n", filename);
    return 0;
  }
  
  // Get scene name
  char scene_name_buffer[2048];
  strncpy(scene_name_buffer, filename, 2047);
  char *scene_name = strrchr(scene_name_buffer, '.');
  if (scene_name) *scene_name = '\0';
  scene_name = strrchr(scene_name_buffer, '/');
  if (scene_name) scene_name++;
  else scene_name = scene_name_buffer;

  // Allocate node and leaf index
  int node_count = 0;
  int leaf_count = 0;
  int *node_index = new int [ NObjects() ];
  int *leaf_index = new int [ NObjects() ];
  for (int i = 0; i < NObjects(); i++) node_index[i] = -1;
  for (int i = 0; i < NObjects(); i++) leaf_index[i] = -1;

  // Compute node and leaf index
  RNArray<R3SurfelObject *> index_stack;
  index_stack.Insert(RootObject());
  while (!index_stack.IsEmpty()) {
    // Pop object off stack
    R3SurfelObject *object = index_stack.Tail();
    index_stack.RemoveTail();

    // Push children on stack
    for (int j = 0; j < object->NParts(); j++) {
      index_stack.Insert(object->Part(j));
    }

    // Check object
    if (object->NParts() == 0) {
      if (object->Parent() == RootObject()) {
        if (!object->GroundTruthLabel() && !object->HumanLabel()) {
          continue;
        }
      }
    }

    // Add object to node index
    node_index[object->SceneIndex()] = node_count++;

    // Add object to leaf index
    if (object->NParts() == 0) {
      leaf_index[object->SceneIndex()] = leaf_count++;
    }
  }

  // Create off directory
  char mkdir_command[4096];
  sprintf(mkdir_command, "mkdir -p %s_off_files", scene_name);
  system(mkdir_command);

  // Write off files
  for (int i = 0; i < NObjects(); i++) {
    R3SurfelObject *object = Object(i);
    if (leaf_index[i] < 0) continue;
    char off_filename[4096];
    sprintf(off_filename, "%s_off_files/%d.off", scene_name, leaf_index[i]);
    if (!WriteOffFile(object, off_filename)) return 0;
  }

  // Write header
  fprintf(fp, "root 0\n");
  fprintf(fp, "scene_name %s\n", scene_name);
  
  // Write objects
  RNArray<R3SurfelObject *> object_stack;
  object_stack.Insert(RootObject());
  while (!object_stack.IsEmpty()) {
    // Pop object off stack
    R3SurfelObject *object = object_stack.Tail();
    object_stack.RemoveTail();

    // Push children on stack
    for (int j = 0; j < object->NParts(); j++) {
      object_stack.Insert(object->Part(j));
    }

    // Check object
    if (node_index[object->SceneIndex()] < 0) continue;

    // Write object header
    fprintf(fp, "newModel %d\n", node_index[object->SceneIndex()]);

    // Write parent 
    R3SurfelObject *parent = object->Parent();
    int parent_index = (parent) ? node_index[parent->SceneIndex()] : -1;
    fprintf(fp, "parent %d\n", parent_index);

    // Write children
    fprintf(fp, "children ");
    for (int j = 0; j < object->NParts(); j++) {
      R3SurfelObject *part = object->Part(j);
      if (node_index[part->SceneIndex()] < 0) continue;
      fprintf(fp, "%d ", node_index[part->SceneIndex()]);
    }
    fprintf(fp, "\n");

    // Write leaf group
    fprintf(fp, "leaf_group");
    RNArray<R3SurfelObject *> part_stack;
    part_stack.Insert(object);
    while (!part_stack.IsEmpty()) {
      R3SurfelObject *part = part_stack.Tail();
      part_stack.RemoveTail();
      for (int j = 0; j < part->NParts(); j++) part_stack.Insert(part->Part(j));
      int g = leaf_index[part->SceneIndex()];
      if (g != -1) fprintf(fp, " %d", g);
    }
    fprintf(fp, "\n");
    
    // Write label
    R3SurfelLabel *label = object->GroundTruthLabel();
    if (!label) label = object->HumanLabel();
    if (!label && (object == RootObject())) label = RootLabel();
    if (label) fprintf(fp, "label %d %s\n", label->SceneIndex(), label->Name());;

    // Write feature vector
    // const R3SurfelFeatureVector& vector = object->FeatureVector();
    // fprintf(fp, "feature_vector ");
    // for (int j = 0; j < vector.NValues(); j++) 
    //   fprintf(fp, "%12.6f ", vector.Value(j));
    // fprintf(fp, "\n");
  }
  
  // Delete temporary data
  delete [] node_index;
  delete [] leaf_index;

  // Close file
  fclose(fp);

  // Return success
  return 1;
}

// Assembly:
subq $0x2ae8, %rsp           # imm = 0x2AE8
movq %rdi, 0x2ad8(%rsp)
movq %rsi, 0x2ad0(%rsp)
movq 0x2ad8(%rsp), %rax
movq %rax, 0x1e0(%rsp)
movq 0x2ad0(%rsp), %rdi
leaq 0x177a98(%rip), %rsi    # 0x1a6efe
callq 0x13690
movq %rax, 0x2ac8(%rsp)
cmpq $0x0, 0x2ac8(%rsp)
jne 0x2f4a4
movq 0x2ad0(%rsp), %rsi
leaq 0x175019(%rip), %rdi    # 0x1a44a6
movb $0x0, %al
callq 0x1464b0
movl $0x0, 0x2ae4(%rsp)
jmp 0x3023e
leaq 0x22c0(%rsp), %rdi
movq 0x2ad0(%rsp), %rsi
movl $0x7ff, %edx            # imm = 0x7FF
callq 0x132a0
leaq 0x22c0(%rsp), %rdi
movl $0x2e, %esi
callq 0x13630
movq %rax, 0x22b8(%rsp)
cmpq $0x0, 0x22b8(%rsp)
je 0x2f4ee
movq 0x22b8(%rsp), %rax
movb $0x0, (%rax)
leaq 0x22c0(%rsp), %rdi
movl $0x2f, %esi
callq 0x13630
movq %rax, 0x22b8(%rsp)
cmpq $0x0, 0x22b8(%rsp)
je 0x2f529
movq 0x22b8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x22b8(%rsp)
jmp 0x2f539
leaq 0x22c0(%rsp), %rax
movq %rax, 0x22b8(%rsp)
movq 0x1e0(%rsp), %rdi
movl $0x0, 0x22b4(%rsp)
movl $0x0, 0x22b0(%rsp)
callq 0x16c20
cltq
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x13030
movq 0x1e0(%rsp), %rdi
movq %rax, 0x22a8(%rsp)
callq 0x16c20
cltq
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x13030
movq %rax, 0x22a0(%rsp)
movl $0x0, 0x229c(%rsp)
movq 0x1e0(%rsp), %rdi
movl 0x229c(%rsp), %eax
movl %eax, 0x1dc(%rsp)
callq 0x16c20
movl %eax, %ecx
movl 0x1dc(%rsp), %eax
cmpl %ecx, %eax
jge 0x2f61c
movq 0x22a8(%rsp), %rax
movslq 0x229c(%rsp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movl 0x229c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x229c(%rsp)
jmp 0x2f5ca
movl $0x0, 0x2298(%rsp)
movq 0x1e0(%rsp), %rdi
movl 0x2298(%rsp), %eax
movl %eax, 0x1d8(%rsp)
callq 0x16c20
movl %eax, %ecx
movl 0x1d8(%rsp), %eax
cmpl %ecx, %eax
jge 0x2f679
movq 0x22a0(%rsp), %rax
movslq 0x2298(%rsp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movl 0x2298(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2298(%rsp)
jmp 0x2f627
leaq 0x2288(%rsp), %rdi
callq 0x1b920
movq 0x1e0(%rsp), %rdi
callq 0x31050
movq %rax, 0x1d0(%rsp)
jmp 0x2f69d
movq 0x1d0(%rsp), %rsi
leaq 0x2288(%rsp), %rdi
callq 0x1be70
jmp 0x2f6b4
jmp 0x2f6b6
leaq 0x2288(%rsp), %rdi
callq 0x31da0
movl %eax, 0x1cc(%rsp)
jmp 0x2f6cc
movl 0x1cc(%rsp), %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x2f6e4
jmp 0x2f953
leaq 0x2288(%rsp), %rdi
callq 0x30ad0
movq %rax, 0x1c0(%rsp)
jmp 0x2f6fb
movq 0x1c0(%rsp), %rax
movq %rax, 0x2270(%rsp)
leaq 0x2288(%rsp), %rdi
callq 0x1c0c0
jmp 0x2f71a
movl $0x0, 0x226c(%rsp)
movl 0x226c(%rsp), %eax
movl %eax, 0x1b8(%rsp)
movq 0x2270(%rsp), %rdi
callq 0x1bb10
movl %eax, 0x1bc(%rsp)
jmp 0x2f749
movl 0x1b8(%rsp), %eax
movl 0x1bc(%rsp), %ecx
cmpl %ecx, %eax
jge 0x2f7be
movq 0x2270(%rsp), %rdi
movl 0x226c(%rsp), %esi
callq 0x1bb30
movq %rax, 0x1b0(%rsp)
jmp 0x2f779
movq 0x1b0(%rsp), %rsi
leaq 0x2288(%rsp), %rdi
callq 0x1be70
jmp 0x2f790
jmp 0x2f792
movl 0x226c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x226c(%rsp)
jmp 0x2f725
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2280(%rsp)
movl %eax, 0x227c(%rsp)
jmp 0x3022f
movq 0x2270(%rsp), %rdi
callq 0x1bb10
movl %eax, 0x1ac(%rsp)
jmp 0x2f7d4
movl 0x1ac(%rsp), %eax
cmpl $0x0, %eax
jne 0x2f87a
movq 0x2270(%rsp), %rdi
callq 0x312c0
movq %rax, 0x1a0(%rsp)
jmp 0x2f7fb
movq 0x1e0(%rsp), %rdi
callq 0x31050
movq %rax, 0x198(%rsp)
jmp 0x2f812
movq 0x1a0(%rsp), %rax
movq 0x198(%rsp), %rcx
cmpq %rcx, %rax
jne 0x2f878
movq 0x2270(%rsp), %rdi
callq 0x19f30
movq %rax, 0x190(%rsp)
jmp 0x2f83e
movq 0x190(%rsp), %rax
cmpq $0x0, %rax
jne 0x2f876
movq 0x2270(%rsp), %rdi
callq 0x19f80
movq %rax, 0x188(%rsp)
jmp 0x2f863
movq 0x188(%rsp), %rax
cmpq $0x0, %rax
jne 0x2f876
jmp 0x2f6b6
jmp 0x2f878
jmp 0x2f87a
movl 0x22b4(%rsp), %eax
movl %eax, 0x174(%rsp)
incl %eax
movl %eax, 0x22b4(%rsp)
movq 0x22a8(%rsp), %rax
movq %rax, 0x178(%rsp)
movq 0x2270(%rsp), %rdi
callq 0x1bf60
movl %eax, 0x184(%rsp)
jmp 0x2f8b7
movq 0x178(%rsp), %rax
movl 0x174(%rsp), %edx
movl 0x184(%rsp), %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq 0x2270(%rsp), %rdi
callq 0x1bb10
movl %eax, 0x170(%rsp)
jmp 0x2f8e9
movl 0x170(%rsp), %eax
cmpl $0x0, %eax
jne 0x2f94e
movl 0x22b0(%rsp), %eax
movl %eax, 0x15c(%rsp)
incl %eax
movl %eax, 0x22b0(%rsp)
movq 0x22a0(%rsp), %rax
movq %rax, 0x160(%rsp)
movq 0x2270(%rsp), %rdi
callq 0x1bf60
movl %eax, 0x16c(%rsp)
jmp 0x2f932
movq 0x160(%rsp), %rax
movl 0x15c(%rsp), %edx
movl 0x16c(%rsp), %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x2f6b6
movq 0x22b8(%rsp), %rdx
leaq 0x17501c(%rip), %rsi    # 0x1a497e
xorl %eax, %eax
leaq 0x1260(%rsp), %rdi
movq %rdi, 0x150(%rsp)
callq 0x130f0
movq 0x150(%rsp), %rdi
callq 0x134a0
jmp 0x2f988
movl $0x0, 0x125c(%rsp)
movq 0x1e0(%rsp), %rdi
movl 0x125c(%rsp), %eax
movl %eax, 0x148(%rsp)
callq 0x16c20
movl %eax, 0x14c(%rsp)
jmp 0x2f9b7
movl 0x148(%rsp), %eax
movl 0x14c(%rsp), %ecx
cmpl %ecx, %eax
jge 0x2faac
movq 0x1e0(%rsp), %rdi
movl 0x125c(%rsp), %esi
callq 0x185f0
movq %rax, 0x140(%rsp)
jmp 0x2f9eb
movq 0x140(%rsp), %rax
movq %rax, 0x1250(%rsp)
movq 0x22a0(%rsp), %rax
movslq 0x125c(%rsp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jge 0x2fa16
jmp 0x2fa96
movq 0x22b8(%rsp), %rdx
movq 0x22a0(%rsp), %rax
movslq 0x125c(%rsp), %rcx
movl (%rax,%rcx,4), %ecx
leaq 0x174f5c(%rip), %rsi    # 0x1a4994
xorl %eax, %eax
leaq 0x250(%rsp), %rdi
movq %rdi, 0x130(%rsp)
callq 0x130f0
movq 0x130(%rsp), %rsi
movq 0x1250(%rsp), %rdi
callq 0x30260
movl %eax, 0x13c(%rsp)
jmp 0x2fa6d
movl 0x13c(%rsp), %eax
cmpl $0x0, %eax
jne 0x2fa94
movl $0x0, 0x2ae4(%rsp)
movl $0x1, 0x24c(%rsp)
jmp 0x30220
jmp 0x2fa96
movl 0x125c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x125c(%rsp)
jmp 0x2f993
movq 0x2ac8(%rsp), %rdi
leaq 0x174eed(%rip), %rsi    # 0x1a49a8
xorl %eax, %eax
movb %al, 0x12f(%rsp)
callq 0x13810
movb 0x12f(%rsp), %al
movq 0x2ac8(%rsp), %rdi
movq 0x22b8(%rsp), %rdx
leaq 0x174ec9(%rip), %rsi    # 0x1a49b0
callq 0x13810
leaq 0x238(%rsp), %rdi
callq 0x1b920
jmp 0x2fafb
movq 0x1e0(%rsp), %rdi
callq 0x31050
movq %rax, 0x120(%rsp)
jmp 0x2fb12
movq 0x120(%rsp), %rsi
leaq 0x238(%rsp), %rdi
callq 0x1be70
jmp 0x2fb29
jmp 0x2fb2b
leaq 0x238(%rsp), %rdi
callq 0x31da0
movl %eax, 0x11c(%rsp)
jmp 0x2fb41
movl 0x11c(%rsp), %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x2fb59
jmp 0x301a5
leaq 0x238(%rsp), %rdi
callq 0x30ad0
movq %rax, 0x110(%rsp)
jmp 0x2fb70
movq 0x110(%rsp), %rax
movq %rax, 0x230(%rsp)
leaq 0x238(%rsp), %rdi
callq 0x1c0c0
jmp 0x2fb8f
movl $0x0, 0x22c(%rsp)
movl 0x22c(%rsp), %eax
movl %eax, 0x108(%rsp)
movq 0x230(%rsp), %rdi
callq 0x1bb10
movl %eax, 0x10c(%rsp)
jmp 0x2fbbe
movl 0x108(%rsp), %eax
movl 0x10c(%rsp), %ecx
cmpl %ecx, %eax
jge 0x2fc33
movq 0x230(%rsp), %rdi
movl 0x22c(%rsp), %esi
callq 0x1bb30
movq %rax, 0x100(%rsp)
jmp 0x2fbee
movq 0x100(%rsp), %rsi
leaq 0x238(%rsp), %rdi
callq 0x1be70
jmp 0x2fc05
jmp 0x2fc07
movl 0x22c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x22c(%rsp)
jmp 0x2fb9a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2280(%rsp)
movl %eax, 0x227c(%rsp)
jmp 0x30211
movq 0x22a8(%rsp), %rax
movq %rax, 0xf0(%rsp)
movq 0x230(%rsp), %rdi
callq 0x1bf60
movl %eax, 0xfc(%rsp)
jmp 0x2fc59
movq 0xf0(%rsp), %rax
movl 0xfc(%rsp), %ecx
movslq %ecx, %rcx
cmpl $0x0, (%rax,%rcx,4)
jge 0x2fc76
jmp 0x2fb2b
movq 0x2ac8(%rsp), %rax
movq %rax, 0xd8(%rsp)
movq 0x22a8(%rsp), %rax
movq %rax, 0xe0(%rsp)
movq 0x230(%rsp), %rdi
callq 0x1bf60
movl %eax, 0xec(%rsp)
jmp 0x2fcac
movq 0xd8(%rsp), %rdi
movq 0xe0(%rsp), %rax
movl 0xec(%rsp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
leaq 0x174cef(%rip), %rsi    # 0x1a49bf
xorl %eax, %eax
callq 0x13810
movq 0x230(%rsp), %rdi
callq 0x312c0
movq %rax, 0xd0(%rsp)
jmp 0x2fcee
movq 0xd0(%rsp), %rax
movq %rax, 0x220(%rsp)
cmpq $0x0, 0x220(%rsp)
je 0x2fd4d
movq 0x22a8(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq 0x220(%rsp), %rdi
callq 0x1bf60
movl %eax, 0xcc(%rsp)
jmp 0x2fd2f
movq 0xc0(%rsp), %rax
movl 0xcc(%rsp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0xbc(%rsp)
jmp 0x2fd5b
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0xbc(%rsp)
jmp 0x2fd5b
movl 0xbc(%rsp), %eax
movl %eax, 0x21c(%rsp)
movq 0x2ac8(%rsp), %rdi
movl 0x21c(%rsp), %edx
leaq 0x174c4d(%rip), %rsi    # 0x1a49cc
movb $0x0, %al
callq 0x13810
movq 0x2ac8(%rsp), %rdi
leaq 0x174c42(%rip), %rsi    # 0x1a49d7
movb $0x0, %al
callq 0x13810
movl $0x0, 0x218(%rsp)
movl 0x218(%rsp), %eax
movl %eax, 0xb4(%rsp)
movq 0x230(%rsp), %rdi
callq 0x1bb10
movl %eax, 0xb8(%rsp)
jmp 0x2fdcb
movl 0xb4(%rsp), %eax
movl 0xb8(%rsp), %ecx
cmpl %ecx, %eax
jge 0x2fec6
movq 0x230(%rsp), %rdi
movl 0x218(%rsp), %esi
callq 0x1bb30
movq %rax, 0xa8(%rsp)
jmp 0x2fdff
movq 0xa8(%rsp), %rax
movq %rax, 0x210(%rsp)
movq 0x22a8(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0x210(%rsp), %rdi
callq 0x1bf60
movl %eax, 0xa4(%rsp)
jmp 0x2fe35
movq 0x98(%rsp), %rax
movl 0xa4(%rsp), %ecx
movslq %ecx, %rcx
cmpl $0x0, (%rax,%rcx,4)
jge 0x2fe4f
jmp 0x2feb0
movq 0x2ac8(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x22a8(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x210(%rsp), %rdi
callq 0x1bf60
movl %eax, 0x94(%rsp)
jmp 0x2fe85
movq 0x80(%rsp), %rdi
movq 0x88(%rsp), %rax
movl 0x94(%rsp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
leaq 0x1749d6(%rip), %rsi    # 0x1a487f
movb $0x0, %al
callq 0x13810
movl 0x218(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x218(%rsp)
jmp 0x2fda7
movq 0x2ac8(%rsp), %rdi
leaq 0x17b81d(%rip), %rsi    # 0x1ab6f2
xorl %eax, %eax
movb %al, 0x7f(%rsp)
callq 0x13810
movb 0x7f(%rsp), %al
movq 0x2ac8(%rsp), %rdi
leaq 0x174aee(%rip), %rsi    # 0x1a49e1
callq 0x13810
leaq 0x200(%rsp), %rdi
callq 0x1b920
jmp 0x2ff07
movq 0x230(%rsp), %rsi
leaq 0x200(%rsp), %rdi
callq 0x1be70
jmp 0x2ff1e
jmp 0x2ff20
leaq 0x200(%rsp), %rdi
callq 0x31da0
movl %eax, 0x78(%rsp)
jmp 0x2ff33
movl 0x78(%rsp), %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x2ff48
jmp 0x30079
leaq 0x200(%rsp), %rdi
callq 0x30ad0
movq %rax, 0x70(%rsp)
jmp 0x2ff5c
movq 0x70(%rsp), %rax
movq %rax, 0x1f8(%rsp)
leaq 0x200(%rsp), %rdi
callq 0x1c0c0
jmp 0x2ff78
movl $0x0, 0x1f4(%rsp)
movl 0x1f4(%rsp), %eax
movl %eax, 0x68(%rsp)
movq 0x1f8(%rsp), %rdi
callq 0x1bb10
movl %eax, 0x6c(%rsp)
jmp 0x2ffa1
movl 0x68(%rsp), %eax
movl 0x6c(%rsp), %ecx
cmpl %ecx, %eax
jge 0x30017
movq 0x1f8(%rsp), %rdi
movl 0x1f4(%rsp), %esi
callq 0x1bb30
movq %rax, 0x60(%rsp)
jmp 0x2ffc8
movq 0x60(%rsp), %rsi
leaq 0x200(%rsp), %rdi
callq 0x1be70
jmp 0x2ffdc
jmp 0x2ffde
movl 0x1f4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1f4(%rsp)
jmp 0x2ff83
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2280(%rsp)
movl %eax, 0x227c(%rsp)
leaq 0x200(%rsp), %rdi
callq 0x1b9e0
jmp 0x30211
movq 0x22a0(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x1f8(%rsp), %rdi
callq 0x1bf60
movl %eax, 0x5c(%rsp)
jmp 0x30037
movq 0x50(%rsp), %rax
movl 0x5c(%rsp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x1f0(%rsp)
cmpl $-0x1, 0x1f0(%rsp)
je 0x30074
movq 0x2ac8(%rsp), %rdi
movl 0x1f0(%rsp), %edx
leaq 0x17af5c(%rip), %rsi    # 0x1aafc9
movb $0x0, %al
callq 0x13810
jmp 0x2ff20
movq 0x2ac8(%rsp), %rdi
leaq 0x17b66a(%rip), %rsi    # 0x1ab6f2
xorl %eax, %eax
callq 0x13810
movq 0x230(%rsp), %rdi
callq 0x19f30
movq %rax, 0x48(%rsp)
jmp 0x300a3
movq 0x48(%rsp), %rax
movq %rax, 0x1e8(%rsp)
cmpq $0x0, 0x1e8(%rsp)
jne 0x300dc
movq 0x230(%rsp), %rdi
callq 0x19f80
movq %rax, 0x40(%rsp)
jmp 0x300cf
movq 0x40(%rsp), %rax
movq %rax, 0x1e8(%rsp)
cmpq $0x0, 0x1e8(%rsp)
jne 0x30138
movq 0x1e0(%rsp), %rdi
movq 0x230(%rsp), %rax
movq %rax, 0x30(%rsp)
callq 0x31050
movq %rax, 0x38(%rsp)
jmp 0x30108
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
cmpq %rcx, %rax
jne 0x30138
movq 0x1e0(%rsp), %rdi
callq 0x31070
movq %rax, 0x28(%rsp)
jmp 0x3012b
movq 0x28(%rsp), %rax
movq %rax, 0x1e8(%rsp)
cmpq $0x0, 0x1e8(%rsp)
je 0x30193
movq 0x2ac8(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x1e8(%rsp), %rdi
callq 0x31300
movl %eax, 0x24(%rsp)
jmp 0x30163
movq 0x1e8(%rsp), %rdi
callq 0x30850
movq %rax, 0x10(%rsp)
jmp 0x30177
movq 0x10(%rsp), %rcx
movl 0x24(%rsp), %edx
movq 0x18(%rsp), %rdi
leaq 0x174860(%rip), %rsi    # 0x1a49ec
movb $0x0, %al
callq 0x13810
leaq 0x200(%rsp), %rdi
callq 0x1b9e0
jmp 0x2fb2b
movq 0x22a8(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, %rax
je 0x301c2
movq 0x8(%rsp), %rdi
callq 0x13750
movq 0x22a0(%rsp), %rax
movq %rax, (%rsp)
cmpq $0x0, %rax
je 0x301dd
movq (%rsp), %rdi
callq 0x13750
movq 0x2ac8(%rsp), %rdi
callq 0x13560
jmp 0x301ec
movl $0x1, 0x2ae4(%rsp)
movl $0x1, 0x24c(%rsp)
leaq 0x238(%rsp), %rdi
callq 0x1b9e0
jmp 0x30220
leaq 0x238(%rsp), %rdi
callq 0x1b9e0
jmp 0x3022f
leaq 0x2288(%rsp), %rdi
callq 0x1b9e0
jmp 0x3023e
leaq 0x2288(%rsp), %rdi
callq 0x1b9e0
jmp 0x3024d
movl 0x2ae4(%rsp), %eax
addq $0x2ae8, %rsp           # imm = 0x2AE8
retq
movq 0x2280(%rsp), %rdi
callq 0x13970
nopw (%rax,%rax)