// File: cpearce[P]OggIndex/src/OggIndex.cpp
// Function: main
int main(int argc, char** argv) 
{
  if (!gOptions.Parse(argc, argv)) {
    return -1;
  }

  string filename = gOptions.GetInputFilename();
  ifstream input(filename.c_str(), ios::in | ios::binary);
  ogg_sync_state state;
  ogg_int32_t ret = ogg_sync_init(&state);
  assert(ret==0);
 
  DecoderMap decoders;
  
  ogg_page page;
  memset(&page, 0, sizeof(ogg_page));

  ogg_uint64_t bytesRead = 0;
  ogg_int64_t offset = 0;
  ogg_uint32_t pageNumber = 0;
  bool gotAllHeaders = false;
  ogg_uint64_t endOfHeaders = 0;
  ogg_uint64_t oldSkeletonLength = 0;

  
  // We store all non-skeleton header pages in the order in which we read them,
  // so that we can rewrite them easily.
  vector<ogg_page*> headerPages;

  while (ReadPage(&state, &page, input, bytesRead)) {
    assert(IsPageAtOffset(filename, offset, &page));
    pageNumber++;
    ogg_uint32_t serial = ogg_page_serialno(&page);
    Decoder* decoder = 0;
    if (ogg_page_bos(&page)) {
      decoder = Decoder::Create(&page);
      decoders[serial] = decoder;
    } else {
      decoder = decoders[serial];
    }
    if (!decoder) {
      cerr << "FAIL: Unhandled stream type, serialno="
           << serial << " aborting indexing!" << endl;
      return -1;
    }

    ogg_uint32_t length = page.body_len + page.header_len;

    if (gOptions.GetDumpPages()) {
      ogg_int64_t granulepos = ogg_page_granulepos(&page);
      cout << "[" << decoder->TypeStr() << "] page @" << offset
           << " length=" << length << " granulepos=" << granulepos 
           << " end_time=" << decoder->GranuleposToTime(granulepos) << "ms"
           << " s=" << serial << " packet_starts=" << CountPacketStarts(&page)
           << " packet_ends=" << ogg_page_packets(&page)
           << " checksum=" << GetChecksum(&page) << endl;
    }

    decoder->Decode(&page, offset);
    
    if (!gotAllHeaders) {
      gotAllHeaders = true;
      DecoderMap::iterator itr = decoders.begin();
      while (itr != decoders.end()) {
        Decoder* d = itr->second;
        if (!d->GotAllHeaders()) {
          gotAllHeaders = false;
          break;
        }
        itr++;
      }
      if (decoder->Type() == TYPE_SKELETON) {
        oldSkeletonLength += length;
      } else {
        // Record all header pages except skeleton. We'll just rewrite the
        // skeleton, and the skeleton decoder will remember its packets.
        headerPages.push_back(Clone(&page));
      }
      if (gotAllHeaders) {
        endOfHeaders = offset + length;
      }
    }

    offset += length;
    memset(&page, 0, sizeof(ogg_page));
  }
  if (!gotAllHeaders) {
    // We've not completely read all the headers, assume the end of the last
    // page we've read is the end of headers. This will turn into the content
    // offset. The input file is probably corrupt.
    cout << "WARNING: Couldn't successfully read all header packets!" << endl;
    endOfHeaders = offset;
  }

  const ogg_int64_t fileLength = bytesRead;
  assert(input.eof());
  if (offset != fileLength) {
    cerr << "WARNING: Ogg page lengths don't sum to file length!" << endl;
  }  
  
  assert(fileLength == InputFileLength());
  
  ogg_sync_clear(&state);
  
  SkeletonEncoder encoder(decoders, fileLength, oldSkeletonLength, endOfHeaders);

  // Reopen the file so we can write it out with the index.
  input.close();
  input.clear();
  input.open(filename.c_str(), ios::in | ios::binary);
  assert(input.good());
  
  // Open output file.
  ofstream output(gOptions.GetOutputFilename().c_str(), ios::out | ios::binary);
  
  // Encode the new skeleton track.
  encoder.Encode();
  
  // Write out the new skeleton BOS page.
  encoder.WriteBosPage(output);
  if (!output.good()) {
    cerr << "ERROR: Failed to write new skeleton BOS page." << endl;
    return -1;
  }
  
  // Write out all the other tracks' header pages.
  for (ogg_uint32_t i=0; i<headerPages.size(); i++) {
    WritePage(output, *headerPages[i]);
    if (!output.good()) {
      cerr << "ERROR: Failed to write other tracks' header pages." << endl;
      return -1;
    }
    FreeClone(headerPages[i]);
  }

  // Write out remaining skeleton pages.
  encoder.WritePages(output);
  if (!output.good()) {
    cerr << "ERROR: Failed to write new skeleton index pages." << endl;
    return -1;
  }

  assert(encoder.ContentOffset() == output.tellp());

  // Copy content pages.
  input.seekg((std::streamoff)endOfHeaders);
  CopyFileData(input, output, fileLength - endOfHeaders);
  if (!output.good()) {
    cerr << "ERROR: Failed to write remaining content pages." << endl;
    return -1;
  }
  
  output.close();
  input.close();

  ogg_int64_t trackLength = encoder.GetTrackLength();
  cout << "Skeleton " << SKELETON_VERSION_MAJOR << "." << SKELETON_VERSION_MINOR 
       << " track with keyframe indexes uses " << trackLength << " bytes, "
       << ((float)trackLength / (float)(fileLength + trackLength)) * 100.0
       << "% overhead" << endl;

  int retval = 0;
  if (gOptions.GetVerifyIndex()) {
    cout << "Validating keyframe indexes..." << endl;
    if (!ValidateIndexedOgg(gOptions.GetOutputFilename())) {
      cerr << "FAIL: Verification of the index failed!" << endl;
      retval = -1;
    } else {
      cout << "SUCCESS: index is valid." << endl;
    }
  }

  return retval;
}

// Assembly:
subq $0x8a8, %rsp            # imm = 0x8A8
movl $0x0, 0x8a4(%rsp)
movl %edi, 0x8a0(%rsp)
movq %rsi, 0x898(%rsp)
movl 0x8a0(%rsp), %esi
movq 0x898(%rsp), %rdx
leaq 0x1ae49(%rip), %rdi     # 0x284e0
callq 0x10be0
testb $0x1, %al
jne 0xd6b0
movl $0xffffffff, 0x8a4(%rsp) # imm = 0xFFFFFFFF
jmp 0xe960
leaq 0x1ae29(%rip), %rsi     # 0x284e0
leaq 0x878(%rsp), %rdi
movq %rdi, 0x258(%rsp)
callq 0x10900
movq 0x258(%rsp), %rdi
callq 0x5180
movq %rax, 0x260(%rsp)
movl $0x8, %edi
movl $0x4, %esi
callq 0xe9f0
movl %eax, 0x26c(%rsp)
jmp 0xd6f9
movl 0x26c(%rsp), %edx
movq 0x260(%rsp), %rsi
leaq 0x670(%rsp), %rdi
callq 0x5840
jmp 0xd717
leaq 0x640(%rsp), %rdi
callq 0x51b0
movl %eax, 0x254(%rsp)
jmp 0xd72d
movl 0x254(%rsp), %eax
movl %eax, 0x63c(%rsp)
cmpl $0x0, 0x63c(%rsp)
jne 0xd747
jmp 0xd798
leaq 0x10142(%rip), %rdi     # 0x1d890
leaq 0x10142(%rip), %rsi     # 0x1d897
movl $0x46, %edx
leaq 0x10147(%rip), %rcx     # 0x1d8a8
callq 0x5280
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x668(%rsp)
movl %eax, 0x664(%rsp)
jmp 0xe951
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x668(%rsp)
movl %eax, 0x664(%rsp)
jmp 0xe944
leaq 0x608(%rsp), %rdi
callq 0xea10
leaq 0x5e8(%rsp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x5230
movq $0x0, 0x5e0(%rsp)
movq $0x0, 0x5d8(%rsp)
movl $0x0, 0x5d4(%rsp)
movb $0x0, 0x5d3(%rsp)
movq $0x0, 0x5c8(%rsp)
movq $0x0, 0x5c0(%rsp)
leaq 0x5a8(%rsp), %rdi
callq 0xea20
leaq 0x640(%rsp), %rdi
leaq 0x5e8(%rsp), %rsi
leaq 0x670(%rsp), %rdx
leaq 0x5e0(%rsp), %rcx
callq 0x15f20
movb %al, 0x253(%rsp)
jmp 0xd837
movb 0x253(%rsp), %al
testb $0x1, %al
jne 0xd847
jmp 0xdf3d
movq 0x5d8(%rsp), %rsi
leaq 0x878(%rsp), %rdi
leaq 0x5e8(%rsp), %rdx
callq 0x162e0
movb %al, 0x252(%rsp)
jmp 0xd86d
movb 0x252(%rsp), %al
testb $0x1, %al
jne 0xd87a
jmp 0xd87c
jmp 0xd8b4
leaq 0x1003c(%rip), %rdi     # 0x1d8bf
leaq 0x1000d(%rip), %rsi     # 0x1d897
movl $0x5a, %edx
leaq 0x10012(%rip), %rcx     # 0x1d8a8
callq 0x5280
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x668(%rsp)
movl %eax, 0x664(%rsp)
jmp 0xe92a
movl 0x5d4(%rsp), %eax
incl %eax
movl %eax, 0x5d4(%rsp)
leaq 0x5e8(%rsp), %rdi
callq 0x5350
movl %eax, 0x24c(%rsp)
jmp 0xd8da
movl 0x24c(%rsp), %eax
movl %eax, 0x5a4(%rsp)
movq $0x0, 0x598(%rsp)
leaq 0x5e8(%rsp), %rdi
callq 0x57f0
movl %eax, 0x248(%rsp)
jmp 0xd90a
movl 0x248(%rsp), %eax
cmpl $0x0, %eax
je 0xd981
leaq 0x5e8(%rsp), %rdi
callq 0x6760
movq %rax, 0x240(%rsp)
jmp 0xd92d
movq 0x240(%rsp), %rax
movq %rax, 0x598(%rsp)
movq 0x598(%rsp), %rax
movq %rax, 0x230(%rsp)
leaq 0x608(%rsp), %rdi
leaq 0x5a4(%rsp), %rsi
callq 0xea30
movq %rax, 0x238(%rsp)
jmp 0xd96c
movq 0x238(%rsp), %rax
movq 0x230(%rsp), %rcx
movq %rcx, (%rax)
jmp 0xd9b3
leaq 0x608(%rsp), %rdi
leaq 0x5a4(%rsp), %rsi
callq 0xea30
movq %rax, 0x228(%rsp)
jmp 0xd9a0
movq 0x228(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x598(%rsp)
cmpq $0x0, 0x598(%rsp)
jne 0xda4c
movq 0x1a627(%rip), %rdi     # 0x27ff0
leaq 0xff17(%rip), %rsi      # 0x1d8e7
callq 0x53d0
movq %rax, 0x220(%rsp)
jmp 0xd9df
movq 0x220(%rsp), %rdi
movl 0x5a4(%rsp), %esi
callq 0x5560
movq %rax, 0x218(%rsp)
jmp 0xd9fd
movq 0x218(%rsp), %rdi
leaq 0xff02(%rip), %rsi      # 0x1d90e
callq 0x53d0
movq %rax, 0x210(%rsp)
jmp 0xda1b
movq 0x210(%rsp), %rdi
movq 0x1a596(%rip), %rsi     # 0x27fc0
callq 0x5430
jmp 0xda31
movl $0xffffffff, 0x8a4(%rsp) # imm = 0xFFFFFFFF
movl $0x1, 0x594(%rsp)
jmp 0xe8f4
movl 0x5f0(%rsp), %ecx
movl 0x600(%rsp), %eax
addl %ecx, %eax
movl %eax, 0x590(%rsp)
leaq 0x1aa76(%rip), %rdi     # 0x284e0
callq 0x10980
movb %al, 0x20f(%rsp)
jmp 0xda78
movb 0x20f(%rsp), %al
testb $0x1, %al
jne 0xda88
jmp 0xdd84
leaq 0x5e8(%rsp), %rdi
callq 0x56e0
movq %rax, 0x200(%rsp)
jmp 0xda9f
movq 0x200(%rsp), %rax
movq %rax, 0x588(%rsp)
movq 0x1a51a(%rip), %rdi     # 0x27fd0
leaq 0x111f6(%rip), %rsi     # 0x1ecb3
callq 0x53d0
movq %rax, 0x1f8(%rsp)
jmp 0xdacc
movq 0x598(%rsp), %rdi
movq (%rdi), %rax
movq 0x30(%rax), %rax
callq *%rax
movq %rax, 0x1f0(%rsp)
jmp 0xdae7
movq 0x1f0(%rsp), %rsi
movq 0x1f8(%rsp), %rdi
callq 0x53d0
movq %rax, 0x1e8(%rsp)
jmp 0xdb06
movq 0x1e8(%rsp), %rdi
leaq 0xfe0d(%rip), %rsi      # 0x1d922
callq 0x53d0
movq %rax, 0x1e0(%rsp)
jmp 0xdb24
movq 0x1e0(%rsp), %rdi
movq 0x5d8(%rsp), %rsi
callq 0x5810
movq %rax, 0x1d8(%rsp)
jmp 0xdb43
movq 0x1d8(%rsp), %rdi
leaq 0xfdd9(%rip), %rsi      # 0x1d92b
callq 0x53d0
movq %rax, 0x1d0(%rsp)
jmp 0xdb61
movq 0x1d0(%rsp), %rdi
movl 0x590(%rsp), %esi
callq 0x5560
movq %rax, 0x1c8(%rsp)
jmp 0xdb7f
movq 0x1c8(%rsp), %rdi
leaq 0xfa46(%rip), %rsi      # 0x1d5d4
callq 0x53d0
movq %rax, 0x1c0(%rsp)
jmp 0xdb9d
movq 0x1c0(%rsp), %rdi
movq 0x588(%rsp), %rsi
callq 0x5810
movq %rax, 0x1b8(%rsp)
jmp 0xdbbc
movq 0x1b8(%rsp), %rdi
leaq 0xfd69(%rip), %rsi      # 0x1d934
callq 0x53d0
movq %rax, 0x1b0(%rsp)
jmp 0xdbda
movq 0x598(%rsp), %rdi
movq 0x588(%rsp), %rsi
movq (%rdi), %rax
movq 0x38(%rax), %rax
callq *%rax
movq %rax, 0x1a8(%rsp)
jmp 0xdbfd
movq 0x1a8(%rsp), %rsi
movq 0x1b0(%rsp), %rdi
callq 0x5810
movq %rax, 0x1a0(%rsp)
jmp 0xdc1c
movq 0x1a0(%rsp), %rdi
leaq 0x104a5(%rip), %rsi     # 0x1e0d0
callq 0x53d0
movq %rax, 0x198(%rsp)
jmp 0xdc3a
movq 0x198(%rsp), %rdi
leaq 0x10e83(%rip), %rsi     # 0x1eacc
callq 0x53d0
movq %rax, 0x190(%rsp)
jmp 0xdc58
movq 0x190(%rsp), %rdi
movl 0x5a4(%rsp), %esi
callq 0x5560
movq %rax, 0x188(%rsp)
jmp 0xdc76
movq 0x188(%rsp), %rdi
leaq 0xfcba(%rip), %rsi      # 0x1d93f
callq 0x53d0
movq %rax, 0x180(%rsp)
jmp 0xdc94
leaq 0x5e8(%rsp), %rdi
callq 0x16a30
movl %eax, 0x17c(%rsp)
jmp 0xdcaa
movl 0x17c(%rsp), %esi
movq 0x180(%rsp), %rdi
callq 0x57a0
movq %rax, 0x170(%rsp)
jmp 0xdcc8
movq 0x170(%rsp), %rdi
leaq 0xfc78(%rip), %rsi      # 0x1d94f
callq 0x53d0
movq %rax, 0x168(%rsp)
jmp 0xdce6
leaq 0x5e8(%rsp), %rdi
callq 0x5820
movl %eax, 0x164(%rsp)
jmp 0xdcfc
movl 0x164(%rsp), %esi
movq 0x168(%rsp), %rdi
callq 0x57a0
movq %rax, 0x158(%rsp)
jmp 0xdd1a
movq 0x158(%rsp), %rdi
leaq 0xfc34(%rip), %rsi      # 0x1d95d
callq 0x53d0
movq %rax, 0x150(%rsp)
jmp 0xdd38
leaq 0x5e8(%rsp), %rdi
callq 0x16810
movl %eax, 0x14c(%rsp)
jmp 0xdd4e
movl 0x14c(%rsp), %esi
movq 0x150(%rsp), %rdi
callq 0x5560
movq %rax, 0x140(%rsp)
jmp 0xdd6c
movq 0x140(%rsp), %rdi
movq 0x1a245(%rip), %rsi     # 0x27fc0
callq 0x5430
jmp 0xdd82
jmp 0xdd84
movq 0x598(%rsp), %rdi
movq 0x5d8(%rsp), %rdx
movq (%rdi), %rax
movq 0x10(%rax), %rax
leaq 0x5e8(%rsp), %rsi
callq *%rax
jmp 0xdda7
testb $0x1, 0x5d3(%rsp)
jne 0xdf0d
movb $0x1, 0x5d3(%rsp)
leaq 0x608(%rsp), %rdi
callq 0xeb20
movq %rax, 0x580(%rsp)
leaq 0x608(%rsp), %rdi
callq 0xeb70
movq %rax, 0x578(%rsp)
leaq 0x580(%rsp), %rdi
leaq 0x578(%rsp), %rsi
callq 0xeb50
testb $0x1, %al
jne 0xde02
jmp 0xde68
leaq 0x580(%rsp), %rdi
callq 0xeba0
movq 0x8(%rax), %rax
movq %rax, 0x570(%rsp)
movq 0x570(%rsp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movb %al, 0x13f(%rsp)
jmp 0xde35
movb 0x13f(%rsp), %al
testb $0x1, %al
jne 0xde4c
jmp 0xde42
movb $0x0, 0x5d3(%rsp)
jmp 0xde68
leaq 0x580(%rsp), %rdi
xorl %esi, %esi
callq 0xebc0
movq %rax, 0x568(%rsp)
jmp 0xddd2
movq 0x598(%rsp), %rdi
movq (%rdi), %rax
movq 0x28(%rax), %rax
callq *%rax
movl %eax, 0x138(%rsp)
jmp 0xde82
movl 0x138(%rsp), %eax
cmpl $0x4, %eax
jne 0xdea7
movl 0x590(%rsp), %eax
addq 0x5c0(%rsp), %rax
movq %rax, 0x5c0(%rsp)
jmp 0xdee7
leaq 0x5e8(%rsp), %rdi
callq 0x15ad0
movq %rax, 0x130(%rsp)
jmp 0xdebe
movq 0x130(%rsp), %rax
movq %rax, 0x560(%rsp)
leaq 0x5a8(%rsp), %rdi
leaq 0x560(%rsp), %rsi
callq 0xec00
jmp 0xdee5
jmp 0xdee7
testb $0x1, 0x5d3(%rsp)
je 0xdf0b
movq 0x5d8(%rsp), %rax
movl 0x590(%rsp), %ecx
addq %rcx, %rax
movq %rax, 0x5c8(%rsp)
jmp 0xdf0d
movl 0x590(%rsp), %eax
addq 0x5d8(%rsp), %rax
movq %rax, 0x5d8(%rsp)
leaq 0x5e8(%rsp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x5230
jmp 0xd809
testb $0x1, 0x5d3(%rsp)
jne 0xdf8a
movq 0x1a082(%rip), %rdi     # 0x27fd0
leaq 0xfa13(%rip), %rsi      # 0x1d968
callq 0x53d0
movq %rax, 0x128(%rsp)
jmp 0xdf64
movq 0x128(%rsp), %rdi
movq 0x1a04d(%rip), %rsi     # 0x27fc0
callq 0x5430
jmp 0xdf7a
movq 0x5d8(%rsp), %rax
movq %rax, 0x5c8(%rsp)
movq 0x5e0(%rsp), %rax
movq %rax, 0x558(%rsp)
movq 0x670(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x670(%rsp,%rax), %rdi
callq 0x5850
movb %al, 0x127(%rsp)
jmp 0xdfbc
movb 0x127(%rsp), %al
testb $0x1, %al
jne 0xdfc9
jmp 0xdfcb
jmp 0xdfea
leaq 0xf9ce(%rip), %rdi      # 0x1d9a0
leaq 0xf8be(%rip), %rsi      # 0x1d897
movl $0x9b, %edx
leaq 0xf8c3(%rip), %rcx      # 0x1d8a8
callq 0x5280
movq 0x5d8(%rsp), %rax
cmpq 0x558(%rsp), %rax
je 0xe031
movq 0x19fed(%rip), %rdi     # 0x27ff0
leaq 0xf9a2(%rip), %rsi      # 0x1d9ac
callq 0x53d0
movq %rax, 0x118(%rsp)
jmp 0xe019
movq 0x118(%rsp), %rdi
movq 0x19f98(%rip), %rsi     # 0x27fc0
callq 0x5430
jmp 0xe02f
jmp 0xe031
movq 0x558(%rsp), %rax
movq %rax, 0x108(%rsp)
callq 0xe980
movq %rax, 0x110(%rsp)
jmp 0xe050
movq 0x108(%rsp), %rax
movq 0x110(%rsp), %rcx
cmpq %rcx, %rax
jne 0xe067
jmp 0xe086
leaq 0xf972(%rip), %rdi      # 0x1d9e0
leaq 0xf822(%rip), %rsi      # 0x1d897
movl $0xa0, %edx
leaq 0xf827(%rip), %rcx      # 0x1d8a8
callq 0x5280
leaq 0x640(%rsp), %rdi
callq 0x58c0
jmp 0xe095
movq 0x558(%rsp), %rdx
movq 0x5c0(%rsp), %rcx
movq 0x5c8(%rsp), %r8
leaq 0x4e8(%rsp), %rdi
leaq 0x608(%rsp), %rsi
callq 0x112d0
jmp 0xe0c4
leaq 0x670(%rsp), %rdi
callq 0x50a0
jmp 0xe0d3
movq 0x670(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x670(%rsp,%rax), %rdi
xorl %esi, %esi
callq 0x5770
jmp 0xe0f0
leaq 0x878(%rsp), %rdi
callq 0x5180
movq %rax, 0xf8(%rsp)
movl $0x8, %edi
movl $0x4, %esi
callq 0xe9f0
movl %eax, 0x104(%rsp)
jmp 0xe11d
movl 0x104(%rsp), %edx
movq 0xf8(%rsp), %rsi
leaq 0x670(%rsp), %rdi
callq 0x5270
jmp 0xe13b
movq 0x670(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x670(%rsp,%rax), %rdi
callq 0x5780
movb %al, 0xf7(%rsp)
jmp 0xe15d
movb 0xf7(%rsp), %al
testb $0x1, %al
jne 0xe16a
jmp 0xe16c
jmp 0xe1a4
leaq 0xf88d(%rip), %rdi      # 0x1da00
leaq 0xf71d(%rip), %rsi      # 0x1d897
movl $0xaa, %edx
leaq 0xf722(%rip), %rcx      # 0x1d8a8
callq 0x5280
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x668(%rsp)
movl %eax, 0x664(%rsp)
jmp 0xe8e5
leaq 0x1a335(%rip), %rsi     # 0x284e0
leaq 0x2c8(%rsp), %rdi
callq 0x10930
jmp 0xe1ba
leaq 0x2c8(%rsp), %rdi
callq 0x5180
movq %rax, 0xe8(%rsp)
movl $0x10, %edi
movl $0x4, %esi
callq 0xe9f0
movl %eax, 0xf0(%rsp)
jmp 0xe1e7
movl 0xf0(%rsp), %edx
movq 0xe8(%rsp), %rsi
leaq 0x2e8(%rsp), %rdi
callq 0x5460
jmp 0xe205
leaq 0x2c8(%rsp), %rdi
callq 0x5260
leaq 0x4e8(%rsp), %rdi
callq 0x11860
jmp 0xe221
leaq 0x4e8(%rsp), %rdi
leaq 0x2e8(%rsp), %rsi
callq 0x13240
jmp 0xe238
movq 0x2e8(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x2e8(%rsp,%rax), %rdi
callq 0x5780
movb %al, 0xe7(%rsp)
jmp 0xe25a
movb 0xe7(%rsp), %al
testb $0x1, %al
jne 0xe2f8
jmp 0xe26b
movq 0x19d7e(%rip), %rdi     # 0x27ff0
leaq 0xf794(%rip), %rsi      # 0x1da0d
callq 0x53d0
movq %rax, 0xd8(%rsp)
jmp 0xe288
movq 0xd8(%rsp), %rdi
movq 0x19d29(%rip), %rsi     # 0x27fc0
callq 0x5430
jmp 0xe29e
movl $0xffffffff, 0x8a4(%rsp) # imm = 0xFFFFFFFF
movl $0x1, 0x594(%rsp)
jmp 0xe8bc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x668(%rsp)
movl %eax, 0x664(%rsp)
leaq 0x2c8(%rsp), %rdi
callq 0x5260
jmp 0xe8e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x668(%rsp)
movl %eax, 0x664(%rsp)
jmp 0xe8d8
movl $0x0, 0x2c4(%rsp)
movl 0x2c4(%rsp), %eax
movq %rax, 0xd0(%rsp)
leaq 0x5a8(%rsp), %rdi
callq 0xec30
movq %rax, %rcx
movq 0xd0(%rsp), %rax
cmpq %rcx, %rax
jae 0xe410
movl 0x2c4(%rsp), %eax
movl %eax, %esi
leaq 0x5a8(%rsp), %rdi
callq 0xec50
movq (%rax), %rsi
leaq 0x2e8(%rsp), %rdi
callq 0x15cf0
jmp 0xe35b
movq 0x2e8(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x2e8(%rsp,%rax), %rdi
callq 0x5780
movb %al, 0xcf(%rsp)
jmp 0xe37d
movb 0xcf(%rsp), %al
testb $0x1, %al
jne 0xe3d8
jmp 0xe38a
movq 0x19c5f(%rip), %rdi     # 0x27ff0
leaq 0xf6a3(%rip), %rsi      # 0x1da3b
callq 0x53d0
movq %rax, 0xc0(%rsp)
jmp 0xe3a7
movq 0xc0(%rsp), %rdi
movq 0x19c0a(%rip), %rsi     # 0x27fc0
callq 0x5430
jmp 0xe3bd
movl $0xffffffff, 0x8a4(%rsp) # imm = 0xFFFFFFFF
movl $0x1, 0x594(%rsp)
jmp 0xe8bc
movl 0x2c4(%rsp), %eax
movl %eax, %esi
leaq 0x5a8(%rsp), %rdi
callq 0xec50
movq (%rax), %rdi
callq 0x15ca0
jmp 0xe3f8
jmp 0xe3fa
movl 0x2c4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c4(%rsp)
jmp 0xe303
leaq 0x4e8(%rsp), %rdi
leaq 0x2e8(%rsp), %rsi
callq 0x132c0
jmp 0xe427
movq 0x2e8(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x2e8(%rsp,%rax), %rdi
callq 0x5780
movb %al, 0xbf(%rsp)
jmp 0xe449
movb 0xbf(%rsp), %al
testb $0x1, %al
jne 0xe4a4
jmp 0xe456
movq 0x19b93(%rip), %rdi     # 0x27ff0
leaq 0xf60a(%rip), %rsi      # 0x1da6e
callq 0x53d0
movq %rax, 0xb0(%rsp)
jmp 0xe473
movq 0xb0(%rsp), %rdi
movq 0x19b3e(%rip), %rsi     # 0x27fc0
callq 0x5430
jmp 0xe489
movl $0xffffffff, 0x8a4(%rsp) # imm = 0xFFFFFFFF
movl $0x1, 0x594(%rsp)
jmp 0xe8bc
leaq 0x4e8(%rsp), %rdi
callq 0xec70
movq %rax, 0xa8(%rsp)
jmp 0xe4bb
leaq 0x2e8(%rsp), %rdi
callq 0x5370
movq %rdx, 0x98(%rsp)
movq %rax, 0xa0(%rsp)
jmp 0xe4da
movq 0x98(%rsp), %rax
movq 0xa0(%rsp), %rcx
movq %rcx, 0x2b0(%rsp)
movq %rax, 0x2b8(%rsp)
leaq 0x2b0(%rsp), %rdi
callq 0xec80
movq %rax, 0x90(%rsp)
jmp 0xe511
movq 0xa8(%rsp), %rax
movq 0x90(%rsp), %rcx
cmpq %rcx, %rax
jne 0xe528
jmp 0xe547
leaq 0xf570(%rip), %rdi      # 0x1da9f
leaq 0xf361(%rip), %rsi      # 0x1d897
movl $0xca, %edx
leaq 0xf366(%rip), %rcx      # 0x1d8a8
callq 0x5280
movq 0x5c8(%rsp), %rsi
leaq 0x2a0(%rsp), %rdi
callq 0xec90
jmp 0xe55e
movq 0x2a0(%rsp), %rsi
movq 0x2a8(%rsp), %rdx
leaq 0x670(%rsp), %rdi
callq 0x5530
jmp 0xe57d
movq 0x558(%rsp), %rdx
movq 0x5c8(%rsp), %rax
subq %rax, %rdx
leaq 0x670(%rsp), %rdi
leaq 0x2e8(%rsp), %rsi
callq 0x16650
jmp 0xe5a7
movq 0x2e8(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x2e8(%rsp,%rax), %rdi
callq 0x5780
movb %al, 0x8f(%rsp)
jmp 0xe5c9
movb 0x8f(%rsp), %al
testb $0x1, %al
jne 0xe624
jmp 0xe5d6
movq 0x19a13(%rip), %rdi     # 0x27ff0
leaq 0xf4e5(%rip), %rsi      # 0x1dac9
callq 0x53d0
movq %rax, 0x80(%rsp)
jmp 0xe5f3
movq 0x80(%rsp), %rdi
movq 0x199be(%rip), %rsi     # 0x27fc0
callq 0x5430
jmp 0xe609
movl $0xffffffff, 0x8a4(%rsp) # imm = 0xFFFFFFFF
movl $0x1, 0x594(%rsp)
jmp 0xe8bc
leaq 0x2e8(%rsp), %rdi
callq 0x55d0
jmp 0xe633
leaq 0x670(%rsp), %rdi
callq 0x50a0
jmp 0xe642
leaq 0x4e8(%rsp), %rdi
callq 0x13160
movq %rax, 0x78(%rsp)
jmp 0xe656
movq 0x78(%rsp), %rax
movq %rax, 0x298(%rsp)
movq 0x19966(%rip), %rdi     # 0x27fd0
leaq 0xf535(%rip), %rsi      # 0x1dba6
callq 0x53d0
movq %rax, 0x70(%rsp)
jmp 0xe67d
movq 0x70(%rsp), %rdi
movl $0x4, %esi
callq 0x57a0
movq %rax, 0x68(%rsp)
jmp 0xe693
movq 0x68(%rsp), %rdi
leaq 0xf4ae(%rip), %rsi      # 0x1db4d
callq 0x53d0
movq %rax, 0x60(%rsp)
jmp 0xe6ab
movq 0x60(%rsp), %rdi
xorl %esi, %esi
callq 0x57a0
movq %rax, 0x58(%rsp)
jmp 0xe6be
movq 0x58(%rsp), %rdi
leaq 0xf42f(%rip), %rsi      # 0x1daf9
callq 0x53d0
movq %rax, 0x50(%rsp)
jmp 0xe6d6
movq 0x50(%rsp), %rdi
movq 0x298(%rsp), %rsi
callq 0x5810
movq %rax, 0x48(%rsp)
jmp 0xe6ef
movq 0x48(%rsp), %rdi
leaq 0xf421(%rip), %rsi      # 0x1db1c
callq 0x53d0
movq %rax, 0x40(%rsp)
jmp 0xe707
movq 0x40(%rsp), %rdi
movq 0x298(%rsp), %rcx
cvtsi2ss %rcx, %xmm0
movq 0x558(%rsp), %rax
addq %rcx, %rax
cvtsi2ss %rax, %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0xf14f(%rip), %xmm1     # 0x1d888
mulsd %xmm1, %xmm0
callq 0x5860
movq %rax, 0x38(%rsp)
jmp 0xe749
movq 0x38(%rsp), %rdi
leaq 0xf3d0(%rip), %rsi      # 0x1db25
callq 0x53d0
movq %rax, 0x30(%rsp)
jmp 0xe761
movq 0x30(%rsp), %rdi
movq 0x19853(%rip), %rsi     # 0x27fc0
callq 0x5430
jmp 0xe774
movl $0x0, 0x294(%rsp)
leaq 0x19d5a(%rip), %rdi     # 0x284e0
callq 0x10960
movb %al, 0x2f(%rsp)
jmp 0xe791
movb 0x2f(%rsp), %al
testb $0x1, %al
jne 0xe79e
jmp 0xe8a3
movq 0x1982b(%rip), %rdi     # 0x27fd0
leaq 0xf384(%rip), %rsi      # 0x1db30
callq 0x53d0
movq %rax, 0x20(%rsp)
jmp 0xe7b8
movq 0x20(%rsp), %rdi
movq 0x197fc(%rip), %rsi     # 0x27fc0
callq 0x5430
jmp 0xe7cb
leaq 0x19d0e(%rip), %rsi     # 0x284e0
leaq 0x270(%rsp), %rdi
callq 0x10930
jmp 0xe7e1
leaq 0x270(%rsp), %rdi
callq 0x179f0
movb %al, 0x1f(%rsp)
jmp 0xe7f4
movb 0x1f(%rsp), %al
xorb $-0x1, %al
movb %al, 0x1e(%rsp)
leaq 0x270(%rsp), %rdi
callq 0x5260
movb 0x1e(%rsp), %al
testb $0x1, %al
jne 0xe815
jmp 0xe872
movq 0x197d4(%rip), %rdi     # 0x27ff0
leaq 0xf32c(%rip), %rsi      # 0x1db4f
callq 0x53d0
movq %rax, 0x10(%rsp)
jmp 0xe82f
movq 0x10(%rsp), %rdi
movq 0x19785(%rip), %rsi     # 0x27fc0
callq 0x5430
jmp 0xe842
movl $0xffffffff, 0x294(%rsp) # imm = 0xFFFFFFFF
jmp 0xe8a1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x668(%rsp)
movl %eax, 0x664(%rsp)
leaq 0x270(%rsp), %rdi
callq 0x5260
jmp 0xe8d8
movq 0x19757(%rip), %rdi     # 0x27fd0
leaq 0xf2f7(%rip), %rsi      # 0x1db77
callq 0x53d0
movq %rax, 0x8(%rsp)
jmp 0xe88c
movq 0x8(%rsp), %rdi
movq 0x19728(%rip), %rsi     # 0x27fc0
callq 0x5430
jmp 0xe89f
jmp 0xe8a1
jmp 0xe8a3
movl 0x294(%rsp), %eax
movl %eax, 0x8a4(%rsp)
movl $0x1, 0x594(%rsp)
leaq 0x2e8(%rsp), %rdi
callq 0x5600
leaq 0x4e8(%rsp), %rdi
callq 0x11550
jmp 0xe8f4
leaq 0x2e8(%rsp), %rdi
callq 0x5600
leaq 0x4e8(%rsp), %rdi
callq 0x11550
jmp 0xe92a
leaq 0x5a8(%rsp), %rdi
callq 0xecc0
leaq 0x608(%rsp), %rdi
callq 0xed20
leaq 0x670(%rsp), %rdi
callq 0x50e0
leaq 0x878(%rsp), %rdi
callq 0x5260
jmp 0xe960
leaq 0x5a8(%rsp), %rdi
callq 0xecc0
leaq 0x608(%rsp), %rdi
callq 0xed20
leaq 0x670(%rsp), %rdi
callq 0x50e0
leaq 0x878(%rsp), %rdi
callq 0x5260
jmp 0xe96f
movl 0x8a4(%rsp), %eax
addq $0x8a8, %rsp            # imm = 0x8A8
retq
movq 0x668(%rsp), %rdi
callq 0x57d0
nopl (%rax)