// File: tomfunkhouser[P]gaps/pkgs/RGBD/RGBDConfiguration.cpp
// Function: gaps::RGBDConfiguration::ReadNeRFFile(char const*, int)
int RGBDConfiguration::
ReadNeRFFile(const char *filename, int read_every_kth_image)
{
  // Open file
  FILE *fp = fopen(filename, "r");
  if (!fp) {
    RNFail("Unable to open NeRF 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);

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

  // Get top level stuff
  Json::Value *json_camera_angle_x = NULL;
  Json::Value *json_frames = NULL;
  if (!json_root.isObject() ||
      !GetJsonObjectMember(json_camera_angle_x, &json_root, "camera_angle_x") ||
      !GetJsonObjectMember(json_frames, &json_root, "frames")) {
    RNFail("NeRF file is not expected format\n", filename);
    return 0;
  }

  // Parse x fov 
  int width = 0;  // Gets filled from first image
  int height = 0; // Gets filled from first image
  double xfov = 0.5 * json_camera_angle_x->asDouble();
  if (xfov <= 0) {
    RNFail("Error parsing camera_angle_x in %s\n", filename);
    return 0;
  }

  // Parse frames
  for (Json::ArrayIndex i = 0; i < json_frames->size(); i++) {
    // Check if skipping images
    if ((read_every_kth_image > 1) && ((i % read_every_kth_image) != 0)) continue;
    
    // Get frame
    Json::Value *json_frame = NULL;
    GetJsonArrayEntry(json_frame, json_frames, i);
    if (!json_frame->isObject()) continue;

    // Parse filepath
    std::string file_path;
    Json::Value *json_file_path = NULL;
    Json::Value *json_transform = NULL;
    if (!GetJsonObjectMember(json_file_path, json_frame, "file_path") ||
        !GetJsonObjectMember(json_transform, json_frame, "transform_matrix") ||
        !json_transform->isArray() || (json_transform->size() != 4)) {
      RNFail("Error parsing frame %d\n", i);
      return 0;
    }

    // Parse image filenames
    std::string depth_filename = "-";
    std::string color_filename = json_file_path->asString();
    if (!RNFileExists(color_filename.c_str())) {
      color_filename = json_file_path->asString() + ".png";
      if (!RNFileExists(color_filename.c_str())) {
        color_filename = json_file_path->asString() + ".jpg";
      }
    }

    // Get width and height
    if ((width <= 0) || (height <= 0)) {
      R2Image color_image;
      if (!color_image.ReadFile(color_filename.c_str())) return 0;
      width = color_image.Width();
      height = color_image.Height();
      if ((width <= 0) || (height <= 0)) {
        RNFail("Error parsing image width and height in %s\n", filename);
        return 0;
      }
    }

    // Get intrinsics matrix
    R3Matrix intrinsics = R3identity_matrix;
    double focal = 0.5 * width / tan(xfov);
    intrinsics[0][0] = focal;
    intrinsics[1][1] = focal;
    intrinsics[0][2] = 0.5 * width;
    intrinsics[1][2] = 0.5 * height;
      
    // Parse rotation (what is this?)
    // XXX
    
    // Parse transformation matrix
    R4Matrix matrix = R4identity_matrix;
    for (int j = 0; j < 4; j++) {
      Json::Value *json_column = NULL;
      GetJsonArrayEntry(json_column, json_transform, j);
      if (!json_transform->isArray() || (json_column->size() != 4)) {
        RNFail("Error parsing tranform %d\n", i);
        return 0;
      }
      for (int k = 0; k < 4; k++) {
        Json::Value *json_value = NULL;
        GetJsonArrayEntry(json_value, json_column, k);
        matrix[j][k] = json_value->asDouble();
      }
    }

    // Compute camera-to-world matrix
    R4Matrix camera_to_world = R4identity_matrix;
    camera_to_world.XRotate(-RN_PI_OVER_TWO);
    camera_to_world = camera_to_world * matrix;

    // Create image
    RGBDImage *image = new RGBDImage(color_filename.c_str(), depth_filename.c_str(),
      intrinsics, camera_to_world, width, height);

    // Insert image
    InsertImage(image);
  }
  
  // Return success
  return 1;
}

// Assembly:
subq $0x5f8, %rsp            # imm = 0x5F8
movq %rdi, 0x5e8(%rsp)
movq %rsi, 0x5e0(%rsp)
movl %edx, 0x5dc(%rsp)
movq 0x5e8(%rsp), %rax
movq %rax, 0x108(%rsp)
movq 0x5e0(%rsp), %rdi
leaq 0x14d446(%rip), %rsi    # 0x16cba3
callq 0x12860
movq %rax, 0x5d0(%rsp)
cmpq $0x0, 0x5d0(%rsp)
jne 0x1f79b
movq 0x5e0(%rsp), %rsi
leaq 0x1473cd(%rip), %rdi    # 0x166b51
movb $0x0, %al
callq 0xdf990
movl $0x0, 0x5f4(%rsp)
jmp 0x2057a
leaq 0x5b0(%rsp), %rdi
callq 0x129f0
movq 0x5d0(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x2, %edx
callq 0x127b0
jmp 0x1f7c0
movq 0x5d0(%rsp), %rdi
callq 0x12030
movq %rax, 0x100(%rsp)
jmp 0x1f7d7
movq 0x100(%rsp), %rax
movq %rax, 0x598(%rsp)
movq 0x5d0(%rsp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x127b0
jmp 0x1f7fa
movq 0x598(%rsp), %rdi
incq %rdi
callq 0x12040
movq %rax, 0xf8(%rsp)
jmp 0x1f814
movq 0xf8(%rsp), %rax
movq %rax, 0x590(%rsp)
movq 0x598(%rsp), %rax
movq %rax, 0x588(%rsp)
movq 0x590(%rsp), %rdi
movq 0x588(%rsp), %rdx
movq 0x5d0(%rsp), %rcx
movl $0x1, %esi
callq 0x12a80
movq %rax, 0xf0(%rsp)
jmp 0x1f860
movq 0xf0(%rsp), %rax
cmpq 0x588(%rsp), %rax
je 0x1f8be
movq 0x5e0(%rsp), %rsi
leaq 0x1472ed(%rip), %rdi    # 0x166b6e
xorl %eax, %eax
callq 0xdf990
jmp 0x1f88a
movl $0x0, 0x5f4(%rsp)
movl $0x1, 0x584(%rsp)
jmp 0x2055c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
jmp 0x2056b
movq 0x590(%rsp), %rax
movq 0x598(%rsp), %rcx
movb $0x0, (%rax,%rcx)
movq 0x590(%rsp), %rsi
leaq 0x5b0(%rsp), %rdi
callq 0x129a0
jmp 0x1f8e9
jmp 0x1f8eb
movq 0x590(%rsp), %rax
movq %rax, 0xe8(%rsp)
cmpq $0x0, %rax
je 0x1f90e
movq 0xe8(%rsp), %rdi
callq 0x12920
movq 0x5d0(%rsp), %rdi
callq 0x126c0
jmp 0x1f91d
leaq 0x558(%rsp), %rdi
xorl %esi, %esi
callq 0xecc20
jmp 0x1f92e
leaq 0x448(%rsp), %rdi
callq 0xdfbd0
jmp 0x1f93d
leaq 0x448(%rsp), %rdi
leaq 0x5b0(%rsp), %rsi
leaq 0x558(%rsp), %rdx
xorl %ecx, %ecx
callq 0xdfe00
movb %al, 0xe7(%rsp)
jmp 0x1f965
movb 0xe7(%rsp), %al
testb $0x1, %al
jne 0x1f9d7
jmp 0x1f972
movq 0x5e0(%rsp), %rsi
leaq 0x147200(%rip), %rdi    # 0x166b81
xorl %eax, %eax
callq 0xdf990
jmp 0x1f98a
movl $0x0, 0x5f4(%rsp)
movl $0x1, 0x584(%rsp)
jmp 0x20524
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
jmp 0x2054d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
jmp 0x20540
movq $0x0, 0x440(%rsp)
movq $0x0, 0x438(%rsp)
leaq 0x558(%rsp), %rdi
callq 0xe0a80
movb %al, 0xe6(%rsp)
jmp 0x1fa05
movb 0xe6(%rsp), %al
testb $0x1, %al
jne 0x1fa12
jmp 0x1fa78
leaq 0x14717c(%rip), %rdx    # 0x166b95
leaq 0x440(%rsp), %rdi
leaq 0x558(%rsp), %rsi
xorl %ecx, %ecx
callq 0x205a0
movl %eax, 0xe0(%rsp)
jmp 0x1fa39
movl 0xe0(%rsp), %eax
cmpl $0x0, %eax
je 0x1fa78
leaq 0x147158(%rip), %rdx    # 0x166ba4
leaq 0x438(%rsp), %rdi
leaq 0x558(%rsp), %rsi
xorl %ecx, %ecx
callq 0x205a0
movl %eax, 0xdc(%rsp)
jmp 0x1fa6c
movl 0xdc(%rsp), %eax
cmpl $0x0, %eax
jne 0x1faab
movq 0x5e0(%rsp), %rsi
leaq 0x147124(%rip), %rdi    # 0x166bab
xorl %eax, %eax
callq 0xdf990
jmp 0x1fa90
movl $0x0, 0x5f4(%rsp)
movl $0x1, 0x584(%rsp)
jmp 0x20524
movl $0x0, 0x434(%rsp)
movl $0x0, 0x430(%rsp)
movq 0x440(%rsp), %rdi
callq 0xef060
movsd %xmm0, 0xd0(%rsp)
jmp 0x1fad9
movsd 0xd0(%rsp), %xmm1
movsd 0x14653e(%rip), %xmm0   # 0x166028
mulsd %xmm1, %xmm0
movsd %xmm0, 0x428(%rsp)
xorps %xmm0, %xmm0
ucomisd 0x428(%rsp), %xmm0
jb 0x1fb38
movq 0x5e0(%rsp), %rsi
leaq 0x1470b9(%rip), %rdi    # 0x166bcd
xorl %eax, %eax
callq 0xdf990
jmp 0x1fb1d
movl $0x0, 0x5f4(%rsp)
movl $0x1, 0x584(%rsp)
jmp 0x20524
movl $0x0, 0x424(%rsp)
movl 0x424(%rsp), %eax
movl %eax, 0xc8(%rsp)
movq 0x438(%rsp), %rdi
callq 0xeb340
movl %eax, 0xcc(%rsp)
jmp 0x1fb67
movl 0xc8(%rsp), %eax
movl 0xcc(%rsp), %ecx
cmpl %ecx, %eax
jae 0x2050e
cmpl $0x1, 0x5dc(%rsp)
jle 0x1fba1
movl 0x424(%rsp), %eax
xorl %edx, %edx
divl 0x5dc(%rsp)
cmpl $0x0, %edx
je 0x1fba1
jmp 0x204ac
movq $0x0, 0x418(%rsp)
movq 0x438(%rsp), %rsi
movl 0x424(%rsp), %edx
leaq 0x418(%rsp), %rdi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x206c0
jmp 0x1fbd0
movq 0x418(%rsp), %rdi
callq 0xe0a80
movb %al, 0xc7(%rsp)
jmp 0x1fbe6
movb 0xc7(%rsp), %al
testb $0x1, %al
jne 0x1fbf8
jmp 0x1fbf3
jmp 0x204ac
leaq 0x3f8(%rsp), %rdi
callq 0x129f0
movq $0x0, 0x3f0(%rsp)
movq $0x0, 0x3e8(%rsp)
movq 0x418(%rsp), %rsi
leaq 0x146fc5(%rip), %rdx    # 0x166bf1
leaq 0x3f0(%rsp), %rdi
xorl %ecx, %ecx
callq 0x205a0
movl %eax, 0xc0(%rsp)
jmp 0x1fc44
movl 0xc0(%rsp), %eax
cmpl $0x0, %eax
je 0x1fcc8
movq 0x418(%rsp), %rsi
leaq 0x146f9c(%rip), %rdx    # 0x166bfb
leaq 0x3e8(%rsp), %rdi
xorl %ecx, %ecx
callq 0x205a0
movl %eax, 0xbc(%rsp)
jmp 0x1fc77
movl 0xbc(%rsp), %eax
cmpl $0x0, %eax
je 0x1fcc8
movq 0x3e8(%rsp), %rdi
callq 0xe0a60
movb %al, 0xbb(%rsp)
jmp 0x1fc99
movb 0xbb(%rsp), %al
testb $0x1, %al
jne 0x1fca6
jmp 0x1fcc8
movq 0x3e8(%rsp), %rdi
callq 0xeb340
movl %eax, 0xb4(%rsp)
jmp 0x1fcbc
movl 0xb4(%rsp), %eax
cmpl $0x4, %eax
je 0x1fd13
movl 0x424(%rsp), %esi
leaq 0x146f36(%rip), %rdi    # 0x166c0c
xorl %eax, %eax
callq 0xdf990
jmp 0x1fcdf
movl $0x0, 0x5f4(%rsp)
movl $0x1, 0x584(%rsp)
jmp 0x20490
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
jmp 0x204ff
leaq 0x3c7(%rsp), %rdi
movq %rdi, 0xa8(%rsp)
callq 0x12c30
movq 0xa8(%rsp), %rdx
leaq 0x146616(%rip), %rsi    # 0x16634d
leaq 0x3c8(%rsp), %rdi
callq 0x22830
jmp 0x1fd46
leaq 0x3c7(%rsp), %rdi
callq 0x12760
movq 0x3f0(%rsp), %rsi
leaq 0x3a0(%rsp), %rdi
callq 0xe2e90
jmp 0x1fd6a
leaq 0x3a0(%rsp), %rdi
callq 0x12280
movq %rax, %rdi
callq 0xde770
movl %eax, 0xa4(%rsp)
jmp 0x1fd88
movl 0xa4(%rsp), %eax
cmpl $0x0, %eax
jne 0x1ff49
movq 0x3f0(%rsp), %rsi
leaq 0x360(%rsp), %rdi
callq 0xe2e90
jmp 0x1fdaf
leaq 0x146e6e(%rip), %rdx    # 0x166c24
leaq 0x380(%rsp), %rdi
leaq 0x360(%rsp), %rsi
callq 0x228f0
jmp 0x1fdcd
leaq 0x3a0(%rsp), %rdi
movq %rdi, 0x98(%rsp)
leaq 0x380(%rsp), %rsi
movq %rsi, 0x90(%rsp)
callq 0x128a0
movq 0x90(%rsp), %rdi
callq 0x12430
leaq 0x360(%rsp), %rdi
callq 0x12430
movq 0x98(%rsp), %rdi
callq 0x12280
movq %rax, %rdi
callq 0xde770
movl %eax, 0xa0(%rsp)
jmp 0x1fe2a
movl 0xa0(%rsp), %eax
cmpl $0x0, %eax
jne 0x1ff47
movq 0x3f0(%rsp), %rsi
leaq 0x320(%rsp), %rdi
callq 0xe2e90
jmp 0x1fe51
leaq 0x14714d(%rip), %rdx    # 0x166fa5
leaq 0x340(%rsp), %rdi
leaq 0x320(%rsp), %rsi
callq 0x228f0
jmp 0x1fe6f
leaq 0x3a0(%rsp), %rdi
leaq 0x340(%rsp), %rsi
callq 0x128a0
leaq 0x340(%rsp), %rdi
callq 0x12430
leaq 0x320(%rsp), %rdi
callq 0x12430
jmp 0x1ff47
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
leaq 0x3c7(%rsp), %rdi
callq 0x12760
jmp 0x204ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
jmp 0x204f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
jmp 0x204e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
leaq 0x360(%rsp), %rdi
callq 0x12430
jmp 0x204e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
leaq 0x320(%rsp), %rdi
callq 0x12430
jmp 0x204e5
jmp 0x1ff49
cmpl $0x0, 0x434(%rsp)
jle 0x1ff61
cmpl $0x0, 0x430(%rsp)
jg 0x2009a
leaq 0x308(%rsp), %rdi
callq 0xd1710
jmp 0x1ff70
leaq 0x3a0(%rsp), %rdi
callq 0x12280
movq %rax, %rsi
leaq 0x308(%rsp), %rdi
callq 0xd1790
movl %eax, 0x8c(%rsp)
jmp 0x1ff96
movl 0x8c(%rsp), %eax
cmpl $0x0, %eax
jne 0x1ffe3
movl $0x0, 0x5f4(%rsp)
movl $0x1, 0x584(%rsp)
jmp 0x2007a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
leaq 0x308(%rsp), %rdi
callq 0xd2160
jmp 0x204e5
leaq 0x308(%rsp), %rdi
callq 0x22940
movl %eax, 0x88(%rsp)
jmp 0x1fff9
movl 0x88(%rsp), %eax
movl %eax, 0x434(%rsp)
leaq 0x308(%rsp), %rdi
callq 0x22950
movl %eax, 0x84(%rsp)
jmp 0x2001d
movl 0x84(%rsp), %eax
movl %eax, 0x430(%rsp)
cmpl $0x0, 0x434(%rsp)
jle 0x2003f
cmpl $0x0, 0x430(%rsp)
jg 0x2006f
movq 0x5e0(%rsp), %rsi
leaq 0x146bdb(%rip), %rdi    # 0x166c29
xorl %eax, %eax
callq 0xdf990
jmp 0x20057
movl $0x0, 0x5f4(%rsp)
movl $0x1, 0x584(%rsp)
jmp 0x2007a
movl $0x0, 0x584(%rsp)
leaq 0x308(%rsp), %rdi
callq 0xd2160
movl 0x584(%rsp), %eax
testl %eax, %eax
jne 0x20476
jmp 0x20098
jmp 0x2009a
leaq 0x1944f7(%rip), %rsi    # 0x1b4598
leaq 0x2c0(%rsp), %rdi
callq 0xcc3e0
jmp 0x200b0
cvtsi2sdl 0x434(%rsp), %xmm0
movsd 0x145f67(%rip), %xmm1   # 0x166028
mulsd %xmm1, %xmm0
movsd %xmm0, 0x68(%rsp)
movsd 0x428(%rsp), %xmm0
callq 0x123a0
movaps %xmm0, %xmm1
movsd 0x68(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x2b8(%rsp)
movsd 0x2b8(%rsp), %xmm0
movsd %xmm0, 0x70(%rsp)
leaq 0x2c0(%rsp), %rdi
xorl %esi, %esi
callq 0x226f0
movq %rax, 0x78(%rsp)
jmp 0x20114
movq 0x78(%rsp), %rax
movsd 0x70(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x2b8(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
leaq 0x2c0(%rsp), %rdi
movl $0x1, %esi
callq 0x226f0
movq %rax, 0x60(%rsp)
jmp 0x2014b
movq 0x60(%rsp), %rax
movsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x8(%rax)
cvtsi2sdl 0x434(%rsp), %xmm0
movsd 0x145ebc(%rip), %xmm1   # 0x166028
mulsd %xmm1, %xmm0
movsd %xmm0, 0x48(%rsp)
leaq 0x2c0(%rsp), %rdi
xorl %esi, %esi
callq 0x226f0
movq %rax, 0x50(%rsp)
jmp 0x2018c
movq 0x50(%rsp), %rax
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x10(%rax)
cvtsi2sdl 0x430(%rsp), %xmm0
movsd 0x145e7b(%rip), %xmm1   # 0x166028
mulsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
leaq 0x2c0(%rsp), %rdi
movl $0x1, %esi
callq 0x226f0
movq %rax, 0x40(%rsp)
jmp 0x201d0
movq 0x40(%rsp), %rax
movsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x10(%rax)
leaq 0x192789(%rip), %rsi    # 0x1b2970
leaq 0x238(%rsp), %rdi
callq 0x84270
jmp 0x201f6
movl $0x0, 0x234(%rsp)
cmpl $0x4, 0x234(%rsp)
jge 0x20367
movq $0x0, 0x228(%rsp)
movq 0x3e8(%rsp), %rsi
movl 0x234(%rsp), %edx
leaq 0x228(%rsp), %rdi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x206c0
jmp 0x2023e
movq 0x3e8(%rsp), %rdi
callq 0xe0a60
movb %al, 0x37(%rsp)
jmp 0x20251
movb 0x37(%rsp), %al
testb $0x1, %al
jne 0x2025b
jmp 0x20277
movq 0x228(%rsp), %rdi
callq 0xeb340
movl %eax, 0x30(%rsp)
jmp 0x2026e
movl 0x30(%rsp), %eax
cmpl $0x4, %eax
je 0x202a9
movl 0x424(%rsp), %esi
leaq 0x1469d0(%rip), %rdi    # 0x166c55
xorl %eax, %eax
callq 0xdf990
jmp 0x2028e
movl $0x0, 0x5f4(%rsp)
movl $0x1, 0x584(%rsp)
jmp 0x20476
movl $0x0, 0x224(%rsp)
cmpl $0x4, 0x224(%rsp)
jge 0x2034f
movq $0x0, 0x218(%rsp)
movq 0x228(%rsp), %rsi
movl 0x224(%rsp), %edx
leaq 0x218(%rsp), %rdi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x206c0
jmp 0x202f1
movq 0x218(%rsp), %rdi
callq 0xef060
movsd %xmm0, 0x28(%rsp)
jmp 0x20306
movl 0x234(%rsp), %esi
leaq 0x238(%rsp), %rdi
callq 0x19ba0
movq %rax, 0x20(%rsp)
jmp 0x20321
movq 0x20(%rsp), %rax
movsd 0x28(%rsp), %xmm0
movslq 0x224(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x224(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x224(%rsp)
jmp 0x202b4
jmp 0x20351
movl 0x234(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x234(%rsp)
jmp 0x20201
leaq 0x192602(%rip), %rsi    # 0x1b2970
leaq 0x198(%rsp), %rdi
callq 0x84270
jmp 0x2037d
leaq 0x14918c(%rip), %rax    # 0x169510
movsd (%rax), %xmm0
movaps 0x1461e1(%rip), %xmm1   # 0x166570
pxor %xmm1, %xmm0
leaq 0x198(%rsp), %rdi
callq 0x85e40
jmp 0x203a2
leaq 0x118(%rsp), %rdi
leaq 0x198(%rsp), %rsi
leaq 0x238(%rsp), %rdx
callq 0x875b0
jmp 0x203c1
leaq 0x198(%rsp), %rdi
leaq 0x118(%rsp), %rsi
callq 0x86970
jmp 0x203d8
movl $0x210, %edi            # imm = 0x210
callq 0x126d0
movq %rax, 0x18(%rsp)
jmp 0x203e9
leaq 0x3a0(%rsp), %rdi
callq 0x12280
movq %rax, 0x10(%rsp)
leaq 0x3c8(%rsp), %rdi
callq 0x12280
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %rax, %rdx
movl 0x434(%rsp), %r9d
movl 0x430(%rsp), %ecx
movq %rsp, %rax
movl %ecx, (%rax)
leaq 0x2c0(%rsp), %rcx
leaq 0x198(%rsp), %r8
xorps %xmm0, %xmm0
callq 0x286c0
jmp 0x20443
movq 0x108(%rsp), %rdi
movq 0x18(%rsp), %rax
movq %rax, 0x110(%rsp)
movq 0x110(%rsp), %rsi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
jmp 0x2046b
movl $0x0, 0x584(%rsp)
leaq 0x3a0(%rsp), %rdi
callq 0x12430
leaq 0x3c8(%rsp), %rdi
callq 0x12430
leaq 0x3f8(%rsp), %rdi
callq 0x12430
movl 0x584(%rsp), %eax
testl %eax, %eax
jne 0x20524
jmp 0x204aa
jmp 0x204ac
movl 0x424(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x424(%rsp)
jmp 0x1fb43
movq 0x18(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
movl $0x210, %esi            # imm = 0x210
callq 0x126e0
leaq 0x3a0(%rsp), %rdi
callq 0x12430
leaq 0x3c8(%rsp), %rdi
callq 0x12430
leaq 0x3f8(%rsp), %rdi
callq 0x12430
jmp 0x20540
movl $0x1, 0x5f4(%rsp)
movl $0x1, 0x584(%rsp)
leaq 0x448(%rsp), %rdi
callq 0x22960
leaq 0x558(%rsp), %rdi
callq 0xed680
jmp 0x2055c
leaq 0x448(%rsp), %rdi
callq 0x22960
leaq 0x558(%rsp), %rdi
callq 0xed680
jmp 0x2056b
leaq 0x5b0(%rsp), %rdi
callq 0x12430
jmp 0x2057a
leaq 0x5b0(%rsp), %rdi
callq 0x12430
jmp 0x20589
movl 0x5f4(%rsp), %eax
addq $0x5f8, %rsp            # imm = 0x5F8
retq
movq 0x5a8(%rsp), %rdi
callq 0x12c20
nopw %cs:(%rax,%rax)