// File: tomfunkhouser[P]gaps/pkgs/R3Graphics/R3Scene.cpp
// Function: gaps::ReadObjMtlFile(gaps::R3Scene*, char const*, char const*, gaps::RNArray<gaps::R3Material*>*)
static int
ReadObjMtlFile(R3Scene *scene, const char *dirname, const char *mtlname, RNArray<R3Material *> *returned_materials)
{
  // Open file
  char filename[2048];
  if (dirname) sprintf(filename, "%s/%s", dirname, mtlname);
  else strncpy(filename, mtlname, 2047);
  FILE *fp = fopen(filename, "r");
  if (!fp) {
    RNFail("Unable to open file %s", filename);
    return 0;
  }

  // Initialize returned materials
  if (returned_materials) returned_materials->Empty();

  // Parse file
  char buffer[1024];
  int line_count = 0;
  R3Brdf *brdf = NULL;
  R3Material *material = NULL;
  RNSymbolTable<R2Texture *> texture_symbol_table;
  while (fgets(buffer, 1023, fp)) {
    // Increment line counter
    line_count++;

    // Skip white space
    char *bufferp = buffer;
    while (isspace(*bufferp)) bufferp++;

    // Skip blank lines and comments
    if (*bufferp == '#') continue;
    if (*bufferp == '\0') continue;

    // Get keyword
    char keyword[80];
    if (sscanf(bufferp, "%s", keyword) != 1) {
      RNFail("Syntax error on line %d in file %s", line_count, filename);
      return 0;
    }

    // Check keyword
    if (!strcmp(keyword, "newmtl")) {
      // Parse line
      char name[1024];
      if (sscanf(bufferp, "%s%s", keyword, name) != (unsigned int) 2) {
        RNFail("Syntax error on line %d in file %s", line_count, filename);
        return 0;
      }

      // Create new material
      brdf = new R3Brdf(name);
      brdf->SetDiffuse(RNwhite_rgb);
      scene->InsertBrdf(brdf);
      material = new R3Material(brdf, NULL, name);
      scene->InsertMaterial(material);
      if (returned_materials) returned_materials->Insert(material);
    }
    else if (!strcmp(keyword, "Ka")) {
      // Parse line
      double r, g, b;
      if (sscanf(bufferp, "%s%lf%lf%lf", keyword, &r, &g, &b) != (unsigned int) 4) {
        RNFail("Syntax error on line %d in file %s", line_count, filename);
        return 0;
      }

      // Set ambient reflectance 
      if (material && brdf) {
        brdf->SetAmbient(RNRgb(r, g, b));
        material->Update();
      }
    }
    else if (!strcmp(keyword, "Kd")) {
      // Parse line
      double r, g, b;
      if (sscanf(bufferp, "%s%lf%lf%lf", keyword, &r, &g, &b) != (unsigned int) 4) {
        RNFail("Syntax error on line %d in file %s", line_count, filename);
        return 0;
      }

      // Set diffuse reflectance 
      if (material && brdf) {
        brdf->SetDiffuse(RNRgb(r, g, b));
        material->Update();
      }
    }
    else if (!strcmp(keyword, "Ks")) {
      // Parse line
      double r, g, b;
      if (sscanf(bufferp, "%s%lf%lf%lf", keyword, &r, &g, &b) != (unsigned int) 4) {
        RNFail("Syntax error on line %d in file %s", line_count, filename);
        return 0;
      }

      // Set specular reflectance 
      if (material && brdf) {
        brdf->SetSpecular(RNRgb(r, g, b));
        material->Update();
      }
    }
    else if (!strcmp(keyword, "Ke")) {
      // Parse line
      double r, g, b;
      if (sscanf(bufferp, "%s%lf%lf%lf", keyword, &r, &g, &b) != (unsigned int) 4) {
        RNFail("Syntax error on line %d in file %s", line_count, filename);
        return 0;
      }

      // Set emission
      if (material && brdf) {
        brdf->SetEmission(RNRgb(r, g, b));
        material->Update();
      }
    }
    else if (!strcmp(keyword, "Tf")) {
      // Parse line
      double r, g, b;
      if (sscanf(bufferp, "%s%lf%lf%lf", keyword, &r, &g, &b) != (unsigned int) 4) {
        RNFail("Syntax error on line %d in file %s", line_count, filename);
        return 0;
      }

      // Set transmission
      if (material && brdf) {
        brdf->SetTransmission(RNRgb(r, g, b));
        material->Update();
      }
    }
    else if (!strcmp(keyword, "Tr")) {
      // Parse line
      double transparency;
      if (sscanf(bufferp, "%s%lf", keyword, &transparency) != (unsigned int) 2) {
        RNFail("Syntax error on line %d in file %s", line_count, filename);
        return 0;
      }

      // Set transmission
      if (material && brdf) {
        brdf->SetOpacity(1 - transparency);
        material->Update();
      }
    }
    else if (!strcmp(keyword, "d")) {
      // Parse line
      double opacity;
      if (sscanf(bufferp, "%s%lf", keyword, &opacity) != (unsigned int) 2) {
        RNFail("Syntax error on line %d in file %s", line_count, filename);
        return 0;
      }

      // Set transmission
      if (material && brdf) {
        brdf->SetOpacity(opacity);
        material->Update();
      }
    }
    else if (!strcmp(keyword, "Ns")) {
      // Parse line
      double ns;
      if (sscanf(bufferp, "%s%lf", keyword, &ns) != (unsigned int) 2) {
        RNFail("Syntax error on line %d in file %s", line_count, filename);
        return 0;
      }

      // Set shininess
      if (material && brdf) {
        brdf->SetShininess(ns);
        material->Update();
      }
    }
    else if (!strcmp(keyword, "Ni")) {
      // Parse line
      double index_of_refraction;
      if (sscanf(bufferp, "%s%lf", keyword, &index_of_refraction) != (unsigned int) 2) {
        RNFail("Syntax error on line %d in file %s", line_count, filename);
        return 0;
      }

      // Set index of refraction
      if (material && brdf) {
        brdf->SetIndexOfRefraction(index_of_refraction);
        material->Update();
      }
    }
    else if (!strcmp(keyword, "map_Kd")) {
      // Parse line
      char texture_name[1024];
      if (sscanf(bufferp, "%s%s", keyword, texture_name) != (unsigned int) 2) {
        RNFail("Syntax error on line %d in file %s", line_count, filename);
        return 0;
      }

      // Set texture
      if (material) {
        char texture_filename[2048];
        if (dirname) sprintf(texture_filename, "%s/%s", dirname, texture_name);
        if (!dirname || !RNFileExists(texture_filename)) strncpy(texture_filename, texture_name, 2047);
        R2Texture *texture = NULL;
        if (!texture_symbol_table.Find(texture_filename, &texture)) {
          R2Image *image = new R2Image();
          if (image->Read(texture_filename)) { 
            texture = new R2Texture(image);
            texture_symbol_table.Insert(texture_filename, texture);
            texture->SetFilename(texture_filename);
            texture->SetName(texture_filename);
            scene->InsertTexture(texture);
          }
        }
        material->SetTexture(texture);
        material->Update();
      }
    }
  }

  // Close file
  fclose(fp);

  // Return success
  return 1;
}

// Assembly:
subq $0x1ed8, %rsp           # imm = 0x1ED8
movq %rdi, 0x1ec8(%rsp)
movq %rsi, 0x1ec0(%rsp)
movq %rdx, 0x1eb8(%rsp)
movq %rcx, 0x1eb0(%rsp)
cmpq $0x0, 0x1ec0(%rsp)
je 0x45b0a
leaq 0x16b0(%rsp), %rdi
movq 0x1ec0(%rsp), %rdx
movq 0x1eb8(%rsp), %rcx
leaq 0x148bc7(%rip), %rsi    # 0x18e6c8
movb $0x0, %al
callq 0x22160
jmp 0x45b24
leaq 0x16b0(%rsp), %rdi
movq 0x1eb8(%rsp), %rsi
movl $0x7ff, %edx            # imm = 0x7FF
callq 0x224b0
leaq 0x16b0(%rsp), %rdi
leaq 0x14f770(%rip), %rsi    # 0x1952a3
callq 0x22c10
movq %rax, 0x16a8(%rsp)
cmpq $0x0, 0x16a8(%rsp)
jne 0x45b71
leaq 0x16b0(%rsp), %rsi
leaq 0x148b74(%rip), %rdi    # 0x18e6ce
movb $0x0, %al
callq 0xf3b00
movl $0x0, 0x1ed4(%rsp)
jmp 0x46b40
cmpq $0x0, 0x1eb0(%rsp)
je 0x45b8b
movq 0x1eb0(%rsp), %rdi
xorl %esi, %esi
callq 0xefba0
movl $0x0, 0x129c(%rsp)
movq $0x0, 0x1290(%rsp)
movq $0x0, 0x1288(%rsp)
leaq 0x1280(%rsp), %rdi
callq 0x49500
movq 0x16a8(%rsp), %rdx
leaq 0x12a0(%rsp), %rdi
movl $0x3ff, %esi            # imm = 0x3FF
callq 0x230f0
movq %rax, 0x88(%rsp)
jmp 0x45bdf
movq 0x88(%rsp), %rax
cmpq $0x0, %rax
je 0x46afd
movl 0x129c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x129c(%rsp)
leaq 0x12a0(%rsp), %rax
movq %rax, 0x1268(%rsp)
movq 0x1268(%rsp), %rax
movsbl (%rax), %edi
callq 0x220c0
cmpl $0x0, %eax
je 0x45c56
movq 0x1268(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x1268(%rsp)
jmp 0x45c12
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1278(%rsp)
movl %eax, 0x1274(%rsp)
jmp 0x46b31
movq 0x1268(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
jne 0x45c6b
jmp 0x45bbb
movq 0x1268(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x45c80
jmp 0x45bbb
movq 0x1268(%rsp), %rdi
leaq 0x1210(%rsp), %rdx
leaq 0x1685b0(%rip), %rsi    # 0x1ae247
movb $0x0, %al
callq 0x229a0
cmpl $0x1, %eax
je 0x45cdd
movl 0x129c(%rsp), %esi
leaq 0x1491ef(%rip), %rdi    # 0x18eea0
xorl %eax, %eax
leaq 0x16b0(%rsp), %rdx
callq 0xf3b00
jmp 0x45cc2
movl $0x0, 0x1ed4(%rsp)
movl $0x1, 0x120c(%rsp)
jmp 0x46b22
leaq 0x1210(%rsp), %rdi
leaq 0x149a17(%rip), %rsi    # 0x18f703
callq 0x22ec0
cmpl $0x0, %eax
jne 0x45e98
movq 0x1268(%rsp), %rdi
leaq 0x1210(%rsp), %rdx
leaq 0xe00(%rsp), %rcx
leaq 0x14a5b8(%rip), %rsi    # 0x1902d1
movb $0x0, %al
callq 0x229a0
cmpl $0x2, %eax
je 0x45d5f
movl 0x129c(%rsp), %esi
leaq 0x14916d(%rip), %rdi    # 0x18eea0
xorl %eax, %eax
leaq 0x16b0(%rsp), %rdx
callq 0xf3b00
jmp 0x45d44
movl $0x0, 0x1ed4(%rsp)
movl $0x1, 0x120c(%rsp)
jmp 0x46b22
movl $0xb8, %edi
callq 0x229e0
movq %rax, 0x80(%rsp)
jmp 0x45d73
movq 0x80(%rsp), %rdi
leaq 0xe00(%rsp), %rsi
callq 0x644b0
jmp 0x45d8a
movq 0x80(%rsp), %rax
movq %rax, 0x1290(%rsp)
movq 0x1290(%rsp), %rdi
leaq 0x1b9e9f(%rip), %rsi    # 0x1ffc48
callq 0x64e20
jmp 0x45db0
movq 0x1ec8(%rsp), %rdi
movq 0x1290(%rsp), %rsi
callq 0x2ccd0
jmp 0x45dc7
movl $0x30, %edi
callq 0x229e0
movq %rax, 0x78(%rsp)
jmp 0x45dd8
movq 0x78(%rsp), %rdi
movq 0x1290(%rsp), %rsi
xorl %eax, %eax
movl %eax, %edx
leaq 0xe00(%rsp), %rcx
callq 0x63f30
jmp 0x45df8
movq 0x78(%rsp), %rax
movq %rax, 0x1288(%rsp)
movq 0x1ec8(%rsp), %rdi
movq 0x1288(%rsp), %rsi
callq 0x2cbd0
jmp 0x45e1c
cmpq $0x0, 0x1eb0(%rsp)
je 0x45e93
movq 0x1eb0(%rsp), %rdi
movq 0x1288(%rsp), %rsi
callq 0x48420
jmp 0x45e3e
jmp 0x45e93
movq 0x80(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1278(%rsp)
movl %eax, 0x1274(%rsp)
movl $0xb8, %esi
callq 0x22a00
jmp 0x46b31
movq 0x78(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1278(%rsp)
movl %eax, 0x1274(%rsp)
movl $0x30, %esi
callq 0x22a00
jmp 0x46b31
jmp 0x46af8
leaq 0x1210(%rsp), %rdi
leaq 0x149863(%rip), %rsi    # 0x18f70a
callq 0x22ec0
cmpl $0x0, %eax
jne 0x45fa1
movq 0x1268(%rsp), %rdi
leaq 0x1210(%rsp), %rdx
leaq 0x1497cd(%rip), %rsi    # 0x18f699
leaq 0xdf8(%rsp), %rcx
leaq 0xdf0(%rsp), %r8
leaq 0xde8(%rsp), %r9
movb $0x0, %al
callq 0x229a0
cmpl $0x4, %eax
je 0x45f2a
movl 0x129c(%rsp), %esi
leaq 0x148fa2(%rip), %rdi    # 0x18eea0
xorl %eax, %eax
leaq 0x16b0(%rsp), %rdx
callq 0xf3b00
jmp 0x45f0f
movl $0x0, 0x1ed4(%rsp)
movl $0x1, 0x120c(%rsp)
jmp 0x46b22
cmpq $0x0, 0x1288(%rsp)
je 0x45f9c
cmpq $0x0, 0x1290(%rsp)
je 0x45f9c
movq 0x1290(%rsp), %rax
movq %rax, 0x70(%rsp)
movsd 0xdf8(%rsp), %xmm0
movsd 0xdf0(%rsp), %xmm1
movsd 0xde8(%rsp), %xmm2
leaq 0xdd0(%rsp), %rdi
callq 0xef340
jmp 0x45f77
movq 0x70(%rsp), %rdi
leaq 0xdd0(%rsp), %rsi
callq 0x64d80
jmp 0x45f8b
movq 0x1288(%rsp), %rdi
callq 0x63c90
jmp 0x45f9a
jmp 0x45f9c
jmp 0x46af6
leaq 0x1210(%rsp), %rdi
leaq 0x149779(%rip), %rsi    # 0x18f729
callq 0x22ec0
cmpl $0x0, %eax
jne 0x460aa
movq 0x1268(%rsp), %rdi
leaq 0x1210(%rsp), %rdx
leaq 0x1496c4(%rip), %rsi    # 0x18f699
leaq 0xdc8(%rsp), %rcx
leaq 0xdc0(%rsp), %r8
leaq 0xdb8(%rsp), %r9
movb $0x0, %al
callq 0x229a0
cmpl $0x4, %eax
je 0x46033
movl 0x129c(%rsp), %esi
leaq 0x148e99(%rip), %rdi    # 0x18eea0
xorl %eax, %eax
leaq 0x16b0(%rsp), %rdx
callq 0xf3b00
jmp 0x46018
movl $0x0, 0x1ed4(%rsp)
movl $0x1, 0x120c(%rsp)
jmp 0x46b22
cmpq $0x0, 0x1288(%rsp)
je 0x460a5
cmpq $0x0, 0x1290(%rsp)
je 0x460a5
movq 0x1290(%rsp), %rax
movq %rax, 0x68(%rsp)
movsd 0xdc8(%rsp), %xmm0
movsd 0xdc0(%rsp), %xmm1
movsd 0xdb8(%rsp), %xmm2
leaq 0xda0(%rsp), %rdi
callq 0xef340
jmp 0x46080
movq 0x68(%rsp), %rdi
leaq 0xda0(%rsp), %rsi
callq 0x64e20
jmp 0x46094
movq 0x1288(%rsp), %rdi
callq 0x63c90
jmp 0x460a3
jmp 0x460a5
jmp 0x46af4
leaq 0x1210(%rsp), %rdi
leaq 0x149654(%rip), %rsi    # 0x18f70d
callq 0x22ec0
cmpl $0x0, %eax
jne 0x461b3
movq 0x1268(%rsp), %rdi
leaq 0x1210(%rsp), %rdx
leaq 0x1495bb(%rip), %rsi    # 0x18f699
leaq 0xd98(%rsp), %rcx
leaq 0xd90(%rsp), %r8
leaq 0xd88(%rsp), %r9
movb $0x0, %al
callq 0x229a0
cmpl $0x4, %eax
je 0x4613c
movl 0x129c(%rsp), %esi
leaq 0x148d90(%rip), %rdi    # 0x18eea0
xorl %eax, %eax
leaq 0x16b0(%rsp), %rdx
callq 0xf3b00
jmp 0x46121
movl $0x0, 0x1ed4(%rsp)
movl $0x1, 0x120c(%rsp)
jmp 0x46b22
cmpq $0x0, 0x1288(%rsp)
je 0x461ae
cmpq $0x0, 0x1290(%rsp)
je 0x461ae
movq 0x1290(%rsp), %rax
movq %rax, 0x60(%rsp)
movsd 0xd98(%rsp), %xmm0
movsd 0xd90(%rsp), %xmm1
movsd 0xd88(%rsp), %xmm2
leaq 0xd70(%rsp), %rdi
callq 0xef340
jmp 0x46189
movq 0x60(%rsp), %rdi
leaq 0xd70(%rsp), %rsi
callq 0x64ec0
jmp 0x4619d
movq 0x1288(%rsp), %rdi
callq 0x63c90
jmp 0x461ac
jmp 0x461ae
jmp 0x46af2
leaq 0x1210(%rsp), %rdi
leaq 0x14954e(%rip), %rsi    # 0x18f710
callq 0x22ec0
cmpl $0x0, %eax
jne 0x462bc
movq 0x1268(%rsp), %rdi
leaq 0x1210(%rsp), %rdx
leaq 0x1494b2(%rip), %rsi    # 0x18f699
leaq 0xd68(%rsp), %rcx
leaq 0xd60(%rsp), %r8
leaq 0xd58(%rsp), %r9
movb $0x0, %al
callq 0x229a0
cmpl $0x4, %eax
je 0x46245
movl 0x129c(%rsp), %esi
leaq 0x148c87(%rip), %rdi    # 0x18eea0
xorl %eax, %eax
leaq 0x16b0(%rsp), %rdx
callq 0xf3b00
jmp 0x4622a
movl $0x0, 0x1ed4(%rsp)
movl $0x1, 0x120c(%rsp)
jmp 0x46b22
cmpq $0x0, 0x1288(%rsp)
je 0x462b7
cmpq $0x0, 0x1290(%rsp)
je 0x462b7
movq 0x1290(%rsp), %rax
movq %rax, 0x58(%rsp)
movsd 0xd68(%rsp), %xmm0
movsd 0xd60(%rsp), %xmm1
movsd 0xd58(%rsp), %xmm2
leaq 0xd40(%rsp), %rdi
callq 0xef340
jmp 0x46292
movq 0x58(%rsp), %rdi
leaq 0xd40(%rsp), %rsi
callq 0x65000
jmp 0x462a6
movq 0x1288(%rsp), %rdi
callq 0x63c90
jmp 0x462b5
jmp 0x462b7
jmp 0x46af0
leaq 0x1210(%rsp), %rdi
leaq 0x149448(%rip), %rsi    # 0x18f713
callq 0x22ec0
cmpl $0x0, %eax
jne 0x463c5
movq 0x1268(%rsp), %rdi
leaq 0x1210(%rsp), %rdx
leaq 0x1493a9(%rip), %rsi    # 0x18f699
leaq 0xd38(%rsp), %rcx
leaq 0xd30(%rsp), %r8
leaq 0xd28(%rsp), %r9
movb $0x0, %al
callq 0x229a0
cmpl $0x4, %eax
je 0x4634e
movl 0x129c(%rsp), %esi
leaq 0x148b7e(%rip), %rdi    # 0x18eea0
xorl %eax, %eax
leaq 0x16b0(%rsp), %rdx
callq 0xf3b00
jmp 0x46333
movl $0x0, 0x1ed4(%rsp)
movl $0x1, 0x120c(%rsp)
jmp 0x46b22
cmpq $0x0, 0x1288(%rsp)
je 0x463c0
cmpq $0x0, 0x1290(%rsp)
je 0x463c0
movq 0x1290(%rsp), %rax
movq %rax, 0x50(%rsp)
movsd 0xd38(%rsp), %xmm0
movsd 0xd30(%rsp), %xmm1
movsd 0xd28(%rsp), %xmm2
leaq 0xd10(%rsp), %rdi
callq 0xef340
jmp 0x4639b
movq 0x50(%rsp), %rdi
leaq 0xd10(%rsp), %rsi
callq 0x64f60
jmp 0x463af
movq 0x1288(%rsp), %rdi
callq 0x63c90
jmp 0x463be
jmp 0x463c0
jmp 0x46aee
leaq 0x1210(%rsp), %rdi
leaq 0x149342(%rip), %rsi    # 0x18f716
callq 0x22ec0
cmpl $0x0, %eax
jne 0x46497
movq 0x1268(%rsp), %rdi
leaq 0x1210(%rsp), %rdx
leaq 0x149320(%rip), %rsi    # 0x18f719
leaq 0xd08(%rsp), %rcx
movb $0x0, %al
callq 0x229a0
cmpl $0x2, %eax
je 0x46447
movl 0x129c(%rsp), %esi
leaq 0x148a85(%rip), %rdi    # 0x18eea0
xorl %eax, %eax
leaq 0x16b0(%rsp), %rdx
callq 0xf3b00
jmp 0x4642c
movl $0x0, 0x1ed4(%rsp)
movl $0x1, 0x120c(%rsp)
jmp 0x46b22
cmpq $0x0, 0x1288(%rsp)
je 0x46492
cmpq $0x0, 0x1290(%rsp)
je 0x46492
movq 0x1290(%rsp), %rdi
movsd 0xd08(%rsp), %xmm1
movsd 0x147b9a(%rip), %xmm0   # 0x18e010
subsd %xmm1, %xmm0
callq 0x65140
jmp 0x46481
movq 0x1288(%rsp), %rdi
callq 0x63c90
jmp 0x46490
jmp 0x46492
jmp 0x46aec
leaq 0x1210(%rsp), %rdi
leaq 0x14ea75(%rip), %rsi    # 0x194f1b
callq 0x22ec0
cmpl $0x0, %eax
jne 0x4655d
movq 0x1268(%rsp), %rdi
leaq 0x1210(%rsp), %rdx
leaq 0x14924e(%rip), %rsi    # 0x18f719
leaq 0xd00(%rsp), %rcx
movb $0x0, %al
callq 0x229a0
cmpl $0x2, %eax
je 0x46519
movl 0x129c(%rsp), %esi
leaq 0x1489b3(%rip), %rdi    # 0x18eea0
xorl %eax, %eax
leaq 0x16b0(%rsp), %rdx
callq 0xf3b00
jmp 0x464fe
movl $0x0, 0x1ed4(%rsp)
movl $0x1, 0x120c(%rsp)
jmp 0x46b22
cmpq $0x0, 0x1288(%rsp)
je 0x46558
cmpq $0x0, 0x1290(%rsp)
je 0x46558
movq 0x1290(%rsp), %rdi
movsd 0xd00(%rsp), %xmm0
callq 0x65140
jmp 0x46547
movq 0x1288(%rsp), %rdi
callq 0x63c90
jmp 0x46556
jmp 0x46558
jmp 0x46aea
leaq 0x1210(%rsp), %rdi
leaq 0x1491b3(%rip), %rsi    # 0x18f71f
callq 0x22ec0
cmpl $0x0, %eax
jne 0x46623
movq 0x1268(%rsp), %rdi
leaq 0x1210(%rsp), %rdx
leaq 0x149188(%rip), %rsi    # 0x18f719
leaq 0xcf8(%rsp), %rcx
movb $0x0, %al
callq 0x229a0
cmpl $0x2, %eax
je 0x465df
movl 0x129c(%rsp), %esi
leaq 0x1488ed(%rip), %rdi    # 0x18eea0
xorl %eax, %eax
leaq 0x16b0(%rsp), %rdx
callq 0xf3b00
jmp 0x465c4
movl $0x0, 0x1ed4(%rsp)
movl $0x1, 0x120c(%rsp)
jmp 0x46b22
cmpq $0x0, 0x1288(%rsp)
je 0x4661e
cmpq $0x0, 0x1290(%rsp)
je 0x4661e
movq 0x1290(%rsp), %rdi
movsd 0xcf8(%rsp), %xmm0
callq 0x650a0
jmp 0x4660d
movq 0x1288(%rsp), %rdi
callq 0x63c90
jmp 0x4661c
jmp 0x4661e
jmp 0x46ae8
leaq 0x1210(%rsp), %rdi
leaq 0x1490f0(%rip), %rsi    # 0x18f722
callq 0x22ec0
cmpl $0x0, %eax
jne 0x466e9
movq 0x1268(%rsp), %rdi
leaq 0x1210(%rsp), %rdx
leaq 0x1490c2(%rip), %rsi    # 0x18f719
leaq 0xcf0(%rsp), %rcx
movb $0x0, %al
callq 0x229a0
cmpl $0x2, %eax
je 0x466a5
movl 0x129c(%rsp), %esi
leaq 0x148827(%rip), %rdi    # 0x18eea0
xorl %eax, %eax
leaq 0x16b0(%rsp), %rdx
callq 0xf3b00
jmp 0x4668a
movl $0x0, 0x1ed4(%rsp)
movl $0x1, 0x120c(%rsp)
jmp 0x46b22
cmpq $0x0, 0x1288(%rsp)
je 0x466e4
cmpq $0x0, 0x1290(%rsp)
je 0x466e4
movq 0x1290(%rsp), %rdi
movsd 0xcf0(%rsp), %xmm0
callq 0x65270
jmp 0x466d3
movq 0x1288(%rsp), %rdi
callq 0x63c90
jmp 0x466e2
jmp 0x466e4
jmp 0x46ae6
leaq 0x1210(%rsp), %rdi
leaq 0x14902d(%rip), %rsi    # 0x18f725
callq 0x22ec0
cmpl $0x0, %eax
jne 0x46ae4
movq 0x1268(%rsp), %rdi
leaq 0x1210(%rsp), %rdx
leaq 0x8f0(%rsp), %rcx
leaq 0x149bac(%rip), %rsi    # 0x1902d1
movb $0x0, %al
callq 0x229a0
cmpl $0x2, %eax
je 0x4676b
movl 0x129c(%rsp), %esi
leaq 0x148761(%rip), %rdi    # 0x18eea0
xorl %eax, %eax
leaq 0x16b0(%rsp), %rdx
callq 0xf3b00
jmp 0x46750
movl $0x0, 0x1ed4(%rsp)
movl $0x1, 0x120c(%rsp)
jmp 0x46b22
cmpq $0x0, 0x1288(%rsp)
je 0x46ae2
cmpq $0x0, 0x1ec0(%rsp)
je 0x467ab
leaq 0xf0(%rsp), %rdi
movq 0x1ec0(%rsp), %rdx
leaq 0x8f0(%rsp), %rcx
leaq 0x147f24(%rip), %rsi    # 0x18e6c8
movb $0x0, %al
callq 0x22160
cmpq $0x0, 0x1ec0(%rsp)
je 0x467d2
leaq 0xf0(%rsp), %rdi
callq 0xf28e0
movl %eax, 0x4c(%rsp)
jmp 0x467c9
movl 0x4c(%rsp), %eax
cmpl $0x0, %eax
jne 0x467ec
leaq 0xf0(%rsp), %rdi
leaq 0x8f0(%rsp), %rsi
movl $0x7ff, %edx            # imm = 0x7FF
callq 0x224b0
movq $0x0, 0xe8(%rsp)
leaq 0xc7(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x232a0
movq 0x40(%rsp), %rdx
leaq 0xc8(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x485b0
jmp 0x46826
leaq 0x1280(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
leaq 0xe8(%rsp), %rdx
callq 0x4a440
movl %eax, 0x3c(%rsp)
jmp 0x46849
movl 0x3c(%rsp), %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
movb %al, 0x3b(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x22610
leaq 0xc7(%rsp), %rdi
callq 0x22ab0
movb 0x3b(%rsp), %al
testb $0x1, %al
jne 0x46880
jmp 0x46aba
movl $0x18, %edi
callq 0x229e0
movq %rax, 0x30(%rsp)
jmp 0x46891
movq 0x30(%rsp), %rdi
callq 0xe5730
jmp 0x4689d
movq 0x30(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0xb8(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x49390
movl %eax, 0x2c(%rsp)
jmp 0x468c5
movl 0x2c(%rsp), %eax
cmpl $0x0, %eax
je 0x46ab8
movl $0x50, %edi
callq 0x229e0
movq %rax, 0x20(%rsp)
jmp 0x468e3
movq 0x20(%rsp), %rdi
movq 0xb8(%rsp), %rsi
movq %rsp, %rax
movq $0x0, 0x8(%rax)
movl $0x2100, (%rax)         # imm = 0x2100
movl $0x2901, %ecx           # imm = 0x2901
movl $0x2703, %r8d           # imm = 0x2703
movl $0x2601, %r9d           # imm = 0x2601
movl %ecx, %edx
callq 0x65910
jmp 0x4691b
movq 0x20(%rsp), %rax
movq %rax, 0xe8(%rsp)
leaq 0x97(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x232a0
movq 0x18(%rsp), %rdx
leaq 0x98(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x485b0
jmp 0x46956
movq 0xe8(%rsp), %rdx
leaq 0x1280(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x4a4d0
jmp 0x46975
leaq 0x98(%rsp), %rdi
callq 0x22610
leaq 0x97(%rsp), %rdi
callq 0x22ab0
movq 0xe8(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x65c80
jmp 0x469a6
movq 0xe8(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x65c20
jmp 0x469bd
movq 0x1ec8(%rsp), %rdi
movq 0xe8(%rsp), %rsi
callq 0x2cdd0
jmp 0x469d4
jmp 0x46ab8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1278(%rsp)
movl %eax, 0x1274(%rsp)
jmp 0x46a10
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1278(%rsp)
movl %eax, 0x1274(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x22610
leaq 0xc7(%rsp), %rdi
callq 0x22ab0
jmp 0x46b31
movq 0x30(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1278(%rsp)
movl %eax, 0x1274(%rsp)
movl $0x18, %esi
callq 0x22a00
jmp 0x46b31
movq 0x20(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1278(%rsp)
movl %eax, 0x1274(%rsp)
movl $0x50, %esi
callq 0x22a00
jmp 0x46b31
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1278(%rsp)
movl %eax, 0x1274(%rsp)
jmp 0x46aa9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1278(%rsp)
movl %eax, 0x1274(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x22610
leaq 0x97(%rsp), %rdi
callq 0x22ab0
jmp 0x46b31
jmp 0x46aba
movq 0x1288(%rsp), %rdi
movq 0xe8(%rsp), %rsi
callq 0x64140
jmp 0x46ad1
movq 0x1288(%rsp), %rdi
callq 0x63c90
jmp 0x46ae0
jmp 0x46ae2
jmp 0x46ae4
jmp 0x46ae6
jmp 0x46ae8
jmp 0x46aea
jmp 0x46aec
jmp 0x46aee
jmp 0x46af0
jmp 0x46af2
jmp 0x46af4
jmp 0x46af6
jmp 0x46af8
jmp 0x45bbb
movq 0x16a8(%rsp), %rdi
callq 0x229d0
jmp 0x46b0c
movl $0x1, 0x1ed4(%rsp)
movl $0x1, 0x120c(%rsp)
leaq 0x1280(%rsp), %rdi
callq 0x49750
jmp 0x46b40
leaq 0x1280(%rsp), %rdi
callq 0x49750
jmp 0x46b4f
movl 0x1ed4(%rsp), %eax
addq $0x1ed8, %rsp           # imm = 0x1ED8
retq
movq 0x1278(%rsp), %rdi
callq 0x23290
nopl (%rax)