// File: /workspace/github_cpp_makefile_star2_O1/cpearce[P]OggIndex/src/Validate.cpp
// Function: ValidateIndexedOgg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
bool ValidateIndexedOgg(const string& filename) {
  ifstream input(filename.c_str(), ios::in | ios::binary);
  ogg_sync_state state;
  ogg_int32_t ret = ogg_sync_init(&state);
  assert(ret==0);

  VerifyDecoderMap decoders;
  ogg_page page;
  memset(&page, 0, sizeof(ogg_page));
  ogg_uint64_t bytesRead = 0;
  Theora* theora = 0;
  Vorbis* vorbis = 0;
  Kate* kate = 0;
  Skeleton* skeleton = 0;
  bool index_valid = true;
  ogg_uint64_t contentOffset = 0;
  
  while (!ReadAllHeaders(theora, vorbis, kate, skeleton) && 
         ReadPage(&state, &page, input, bytesRead))
  {
    contentOffset += page.header_len + page.body_len;
    int serialno = ogg_page_serialno(&page);
    VerifyDecoder* decoder = 0;
    if (ogg_page_bos(&page)) {
      if (page.body_len > 8 &&
          strncmp("theora", (const char*)page.body+1, 6) == 0)
      {
        theora = new Theora(serialno);
        decoders[serialno] = theora;
      } else if (page.body_len > 8 &&
                 strncmp("vorbis", (const char*)page.body+1, 6) == 0)
      {
        vorbis = new Vorbis(serialno);
        decoders[serialno] = vorbis;
#ifdef HAVE_KATE
      } else if (page.body_len > 8 &&
                 memcmp("kate\0\0\0", (const char*)page.body+1, 7) == 0)
      {
        kate = new Kate(serialno);
        decoders[serialno] = kate;
#endif
      } else if (page.body_len > 8 &&
                 strncmp("fishead", (const char*)page.body, 8) == 0)
      {
        skeleton = new Skeleton(serialno);
        decoders[serialno] = skeleton;
      }
    }
    decoder = decoders[serialno];
    if (!decoder) {
      cout << "WARNING: Unknown stream type, serialno=" << serialno << endl;
      continue;
    }
    ogg_int64_t ignore;
    if (!decoder->Decode(&page, ignore)) {
      index_valid = false;
    }
  }

  if (!skeleton) {
    cerr << "FAIL: No skeleton track so therefore no keyframe indexes!" << endl;
    return false;
  }

  if (skeleton->mContentOffset != contentOffset) {
    cerr << "FAIL: skeleton header's reported content offset (" << skeleton->mContentOffset
         << ") does not match actual content offset (" << contentOffset << ")" << endl;
    index_valid = false;
  }

  ogg_int64_t fileLength = FileLength(filename.c_str());
  if (skeleton->mFileLength != fileLength) {
    cerr << "FAIL: index's reported file length (" << skeleton->mFileLength
         << ") doesn't match file's actual length (" << fileLength << ")" << endl;
    index_valid = false;
  }

  KeyFrameIndex::iterator itr = skeleton->mIndex.begin();
  if (itr == skeleton->mIndex.end()) {
    cerr << "WARNING: No tracks in skeleton index." << endl;
  }

  while (itr != skeleton->mIndex.end()) {
    vector<KeyFrameInfo>* v = itr->second;
    ogg_uint32_t serialno = itr->first;
    itr++;
    VerifyDecoder* decoder = decoders[serialno];

    if (!decoder) {
      cerr << "WARNING: No decoder for track s="
           << serialno << endl;
      continue;
    }

    if (v->size() == 0) {
      cerr << "WARNING: " << decoder->Type() << "/" <<  serialno
           << " index has no keyframes" << endl;
      continue;
    }

    cout << decoder->Type() << "/" << serialno
         << " index has " << v->size() << " keypoints." << endl;

    bool valid = true;
    for (ogg_uint32_t i=0; i<v->size(); i++) {
    
      KeyFrameInfo& keypoint = v->at(i);
      if (keypoint.mOffset > INT_MAX) {
        cerr << "WARNING: Only verified up to 2^31 bytes into the file." << endl;
        break;
      }
      
      if (keypoint.mOffset > fileLength) {
        valid = false;
        cerr << "FAIL: Keypoint " << i << " offset of " << keypoint.mOffset
             << " out of file range." << endl;
        break;
      }

      // Check that the checksum of the page here matches, and that the
      // presentation time of the stream matches what's reported in the index.
      ogg_sync_reset(&state);
      if (input.eof()) {
        // Probably hit eof while reading pages for previous keypoint.
        input.close();
        input.clear();        
        input.open(filename.c_str(), ios::in | ios::binary);
      }
      input.seekg(keypoint.mOffset);
      if (!input.good()) {
        cerr << "FAIL: Can't seek to keypoint at byte offset " << keypoint.mOffset << endl;
        return false;
      }
      decoder->Reset();
      ogg_int64_t pres_time = -1;
      ogg_int64_t page_offset = keypoint.mOffset;
      ogg_int64_t end_time = -1;
      while (pres_time  == -1) {
        int skip = 0;
        if ((skip = PageSeek(&state, &page, input, bytesRead)) != 0) {
          if (skip == -1) {
            cerr << "FAIL: Can't read page at offset " << page_offset << endl;
            return false;
          }
          assert(skip > 0);
          cerr << "FAIL: There's no page at offset " << page_offset
               << " as reported by keypoint. Next page is at offset "
               << (page_offset + skip) << endl;
          return false;
        }
        page_offset += page.header_len + page.body_len;
        // Extract the presentation time. Decode() returns -1 if it needs
        // another page.
        if ((ogg_uint32_t)ogg_page_serialno(&page) != decoder->mSerial) {
          // Skip until we read another page on this stream.
          continue;
        }
        pres_time = decoder->Decode(&page, end_time);
        // Vorbis decoders should never return -1 for prestime, it should be
        // calculable from only one page.
        assert(decoder != vorbis || pres_time != -1);
      }

      // We consider a theora the key point is invalid if it's reported time
      // doesn't match the presentation time of the first keyframe which
      // can be decoded from this page.
      if (decoder == theora && keypoint.mTime != pres_time) {
        cerr << "FAIL: theora keypoint " << i << " for page at offset "
             << keypoint.mOffset << " reports start time of "
             << keypoint.mTime << " but should be " << pres_time << endl;
        valid = false;
      }

      // A vorbis keypoint is considered invalid if lies before the start time
      // of this page, or after the end time.
      if (decoder == vorbis &&
          (keypoint.mTime < pres_time || keypoint.mTime > end_time))
      {
        cerr << "FAIL: vorbis keypoint " << i << " for page at offset "
             << keypoint.mOffset << " reports start time of "
             << keypoint.mTime << " but should lie in the range ["
             << pres_time << "," << end_time << "]" << endl;
        valid = false;
      }

#ifdef HAVE_KATE
      if (decoder == kate) {
        // We get the granpos of the page linked to, and check that the base part of the granpos
        // is higher or equal to the time of the keypoint
        ogg_int64_t base_time = kate->GetBaseTime(&page);
        if (base_time > pres_time) {
          cerr << "FAIL: kate keypoint " << i << " for page at offset "
               << keypoint.mOffset << " reports start time of "
               << keypoint.mTime << " but should be greater of equal to "
               << base_time << endl;
          valid = false;
        }
      }
#endif
    }
    if (valid) {
      cout << decoder->Type() << "/" << serialno
           << " index is accurate." << endl;
    } else {
      cout << "FAIL: " << decoder->Type() << "/" << serialno
           << " index is NOT accurate." << endl;
      index_valid = false;
    }
  }

  ogg_sync_clear(&state);
  
  return index_valid;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2d8, %rsp            # imm = 0x2D8
movq %rdi, 0x60(%rsp)
movq (%rdi), %rsi
leaq 0xd0(%rsp), %rdi
movl $0xc, %edx
callq 0x4730
leaq 0xb0(%rsp), %rdi
callq 0x4180
testl %eax, %eax
jne 0xe029
leaq 0x88(%rsp), %rax
movl $0x0, (%rax)
xorl %ecx, %ecx
movq %rcx, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
xorps %xmm0, %xmm0
leaq 0x40(%rsp), %r14
movaps %xmm0, 0x10(%r14)
movaps %xmm0, (%r14)
leaq 0x68(%rsp), %rax
movq %rcx, (%rax)
movb $0x1, %al
movl %eax, 0xc(%rsp)
leaq 0x28(%rsp), %rbp
xorl %ebx, %ebx
xorl %r13d, %r13d
movq $0x0, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
testq %r13, %r13
jne 0xd0f4
cmpq $0x0, 0x18(%rsp)
jne 0xd0f4
cmpq $0x0, 0x20(%rsp)
je 0xd134
cmpq $0x0, 0x20(%rsp)
je 0xd107
movq 0x20(%rsp), %rax
cmpb $0x1, 0xc(%rax)
jne 0xd134
movq 0x18(%rsp), %rax
testq %rax, %rax
je 0xd11f
movb 0xc(%rax), %al
testq %r13, %r13
je 0xd12c
testb %al, %al
jne 0xd128
jmp 0xd12c
testq %r13, %r13
je 0xd39b
movb 0xc(%r13), %al
testb %al, %al
jne 0xd39b
leaq 0xb0(%rsp), %rdi
movq %r14, %rsi
leaq 0xd0(%rsp), %rdx
leaq 0x68(%rsp), %rcx
callq 0xc3c8
testb %al, %al
je 0xd39b
addq 0x48(%rsp), %rbx
addq 0x58(%rsp), %rbx
movq %r14, %rdi
callq 0x42d0
movl %eax, %r12d
movq %r14, %rdi
callq 0x46f0
testl %eax, %eax
je 0xd301
movq 0x58(%rsp), %r15
cmpq $0x9, %r15
jl 0xd301
movq 0x50(%rsp), %rsi
incq %rsi
movl $0x6, %edx
leaq 0x3536(%rip), %rdi      # 0x106d7
callq 0x41a0
testl %eax, %eax
je 0xd290
cmpq $0x9, %r15
jl 0xd301
movq 0x50(%rsp), %rsi
incq %rsi
movl $0x6, %edx
leaq 0x364f(%rip), %rdi      # 0x1081b
callq 0x41a0
testl %eax, %eax
je 0xd2c8
cmpq $0x9, %r15
jl 0xd301
movq 0x50(%rsp), %rsi
movl $0x8, %edx
leaq 0x2fd8(%rip), %rdi      # 0x101cc
callq 0x41a0
testl %eax, %eax
jne 0xd301
movl $0x1e8, %edi            # imm = 0x1E8
callq 0x4380
movq %rax, %r13
leaq 0x9a9b(%rip), %rax      # 0x16cb0
movq %rax, (%r13)
movl %r12d, 0x8(%r13)
movb $0x0, 0xc(%r13)
leaq 0x10(%r13), %rdi
movl %r12d, %esi
callq 0x4720
leaq 0x9b03(%rip), %rax      # 0x16d38
movq %rax, (%r13)
movq %r13, %rax
addq $0x1b0, %rax            # imm = 0x1B0
movl $0x0, 0x1b0(%r13)
xorl %ecx, %ecx
movq %rcx, 0x1b8(%r13)
movq %rax, 0x1c0(%r13)
movq %rax, 0x1c8(%r13)
movq %rcx, 0x1d0(%r13)
movq $-0x1, 0x1d8(%r13)
movl %r12d, 0x28(%rsp)
leaq 0x80(%rsp), %rdi
movq %rbp, %rsi
callq 0xe172
movq %r13, (%rax)
jmp 0xd301
movl $0x240, %edi            # imm = 0x240
callq 0x4380
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rdi
movl %r12d, %esi
callq 0xe0c0
movl %r12d, 0x28(%rsp)
leaq 0x80(%rsp), %rdi
movq %rbp, %rsi
callq 0xe172
movq 0x20(%rsp), %rcx
jmp 0xd2fe
movl $0x358, %edi            # imm = 0x358
callq 0x4380
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rdi
movl %r12d, %esi
callq 0xe1d6
movl %r12d, 0x28(%rsp)
leaq 0x80(%rsp), %rdi
movq %rbp, %rsi
callq 0xe172
movq 0x18(%rsp), %rcx
movq %rcx, (%rax)
movl %r12d, 0x28(%rsp)
leaq 0x80(%rsp), %rdi
movq %rbp, %rsi
callq 0xe172
movq (%rax), %rdi
testq %rdi, %rdi
jne 0xd374
movl $0x27, %edx
movq 0x9ca6(%rip), %rdi      # 0x16fd0
leaq 0x464a(%rip), %rsi      # 0x1197b
callq 0x4410
movq 0x9c93(%rip), %rdi      # 0x16fd0
movl %r12d, %esi
callq 0x46a0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x4360
movsbl %al, %esi
movq %r12, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4250
jmp 0xd0df
movq (%rdi), %rax
movq %r14, %rsi
movq %rbp, %rdx
callq *0x10(%rax)
testq %rax, %rax
movl 0xc(%rsp), %eax
movzbl %al, %eax
movl $0x0, %ecx
cmovel %ecx, %eax
movl %eax, 0xc(%rsp)
jmp 0xd0df
testq %r13, %r13
je 0xdf72
cmpq %rbx, 0x1e0(%r13)
je 0xd444
movq 0x9c38(%rip), %rdi      # 0x16ff0
leaq 0x461e(%rip), %rsi      # 0x119dd
movl $0x31, %edx
callq 0x4410
movq 0x1e0(%r13), %rsi
movq 0x9c19(%rip), %rdi      # 0x16ff0
callq 0x4240
movq %rax, %r14
leaq 0x4629(%rip), %rsi      # 0x11a0f
movl $0x28, %edx
movq %rax, %rdi
callq 0x4410
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4240
movq %rax, %rbx
leaq 0x4571(%rip), %rsi      # 0x11979
movl $0x1, %edx
movq %rax, %rdi
callq 0x4410
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4360
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4250
movl $0x0, 0xc(%rsp)
movq 0x60(%rsp), %rax
movq (%rax), %rdi
callq 0xc2d0
movq %rax, %rbp
cmpq %rax, 0x1d8(%r13)
je 0xd4f4
movq 0x9b88(%rip), %rdi      # 0x16ff0
leaq 0x45c9(%rip), %rsi      # 0x11a38
movl $0x24, %edx
callq 0x4410
movq 0x1d8(%r13), %rsi
movq 0x9b69(%rip), %rdi      # 0x16ff0
callq 0x4340
movq %rax, %rbx
leaq 0x45c7(%rip), %rsi      # 0x11a5d
movl $0x26, %edx
movq %rax, %rdi
callq 0x4410
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x4340
movq %rax, %rbx
leaq 0x44c1(%rip), %rsi      # 0x11979
movl $0x1, %edx
movq %rax, %rdi
callq 0x4410
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4360
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4250
movl $0x0, 0xc(%rsp)
movq 0x1c0(%r13), %rax
addq $0x1b0, %r13            # imm = 0x1B0
movq %rax, %r14
cmpq %r13, %rax
jne 0xd550
movq 0x9adf(%rip), %rbx      # 0x16ff0
leaq 0x456c(%rip), %rsi      # 0x11a84
movl $0x25, %edx
movq %rbx, %rdi
callq 0x4410
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4360
movsbl %al, %esi
movq 0x9aad(%rip), %rdi      # 0x16ff0
callq 0x4040
movq %rax, %rdi
callq 0x4250
cmpq %r13, %r14
je 0xdf5f
movq %r14, %rdi
movq %r13, 0x70(%rsp)
movq %rbp, 0x38(%rsp)
movq 0x28(%rdi), %r15
movl 0x20(%rdi), %eax
movl %eax, 0x10(%rsp)
callq 0x4260
movq %rax, 0x78(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xe23e
movq (%rax), %r12
testq %r12, %r12
je 0xd5d3
movq 0x8(%r15), %rax
cmpq (%r15), %rax
je 0xd617
movq (%r12), %rax
movq %r12, %rdi
callq *0x20(%rax)
movq %rax, %rbx
testq %rax, %rax
je 0xd664
movq %rbx, %rdi
callq 0x4170
movq 0x9a0d(%rip), %rdi      # 0x16fd0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x4410
jmp 0xd682
movl $0x20, %edx
movq 0x9a11(%rip), %rdi      # 0x16ff0
leaq 0x44c4(%rip), %rsi      # 0x11aaa
callq 0x4410
movl 0x10(%rsp), %esi
movq 0x99fa(%rip), %rdi      # 0x16ff0
callq 0x4240
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4360
jmp 0xde08
movl $0x9, %edx
movq 0x99cd(%rip), %rdi      # 0x16ff0
leaq 0x44a1(%rip), %rsi      # 0x11acb
callq 0x4410
movq (%r12), %rax
movq %r12, %rdi
callq *0x20(%rax)
movq %rax, %rbx
testq %rax, %rax
je 0xdd97
movq %rbx, %rdi
callq 0x4170
movq 0x999c(%rip), %rdi      # 0x16ff0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x4410
jmp 0xddb5
movq 0x9965(%rip), %rcx      # 0x16fd0
movq (%rcx), %rax
movq -0x18(%rax), %rax
leaq (%rcx,%rax), %rdi
movl 0x20(%rcx,%rax), %esi
orl $0x1, %esi
callq 0x4690
movl $0x1, %edx
movq 0x9942(%rip), %rdi      # 0x16fd0
leaq 0x3a61(%rip), %rsi      # 0x110f6
callq 0x4410
movl 0x10(%rsp), %esi
movq 0x992b(%rip), %rdi      # 0x16fd0
callq 0x4240
movq %rax, %r14
movl $0xb, %edx
movq %rax, %rdi
leaq 0x4431(%rip), %rsi      # 0x11aed
callq 0x4410
movq 0x8(%r15), %rsi
subq (%r15), %rsi
sarq $0x4, %rsi
movq %r14, %rdi
callq 0x4240
movq %rax, %r14
movl $0xb, %edx
movq %rax, %rdi
leaq 0x4413(%rip), %rsi      # 0x11af9
callq 0x4410
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4360
movsbl %al, %esi
movq %r14, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4250
movq %r12, 0x30(%rsp)
movq (%r15), %r12
cmpq %r12, 0x8(%r15)
je 0xdcf3
movb $0x1, %al
movl %eax, 0x14(%rsp)
xorl %r14d, %r14d
movq %r14, %rax
shlq $0x4, %rax
movq (%r12,%rax), %rcx
movl $0x80000000, %edx       # imm = 0x80000000
cmpq %rdx, %rcx
jl 0xd796
movl $0x36, %edx
movq 0x98a2(%rip), %rdi      # 0x16ff0
leaq 0x43b0(%rip), %rsi      # 0x11b05
callq 0x4410
movq 0x988f(%rip), %rcx      # 0x16ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x4360
movsbl %al, %esi
movq 0x9871(%rip), %rdi      # 0x16ff0
callq 0x4040
movl $0x6, %ebx
movq %rax, %rdi
callq 0x4250
jmp 0xd925
addq %rax, %r12
cmpq %rbp, %rcx
jle 0xd83d
movl $0xf, %edx
movq 0x9842(%rip), %rdi      # 0x16ff0
leaq 0x4387(%rip), %rsi      # 0x11b3c
callq 0x4410
movq 0x982f(%rip), %rdi      # 0x16ff0
movq %r14, %rsi
callq 0x4240
movq %rax, %rbx
movl $0xb, %edx
movq %rax, %rdi
leaq 0x4371(%rip), %rsi      # 0x11b4c
callq 0x4410
movq (%r12), %rsi
movq %rbx, %rdi
callq 0x4340
movq %rax, %r13
movl $0x13, %edx
movq %rax, %rdi
leaq 0x435a(%rip), %rsi      # 0x11b58
callq 0x4410
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x4360
movsbl %al, %esi
movq %r13, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4250
movl $0x6, %ebx
movl $0x0, 0x14(%rsp)
jmp 0xd925
leaq 0xb0(%rsp), %rdi
callq 0x4190
movq 0xd0(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0xf0(%rsp,%rax)
je 0xd8a5
leaq 0xd0(%rsp), %rdi
callq 0x40a0
movq 0xd0(%rsp), %rax
movq -0x18(%rax), %rdi
leaq 0xd0(%rsp), %rax
addq %rax, %rdi
xorl %esi, %esi
callq 0x4690
movq 0x60(%rsp), %rax
movq (%rax), %rsi
leaq 0xd0(%rsp), %rdi
movl $0xc, %edx
callq 0x4200
movq (%r12), %rsi
leaq 0xd0(%rsp), %rdi
xorl %edx, %edx
callq 0x4480
movq 0xd0(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0xf0(%rsp,%rax)
je 0xd94c
movl $0x2c, %edx
movq 0x9716(%rip), %rdi      # 0x16ff0
leaq 0x428b(%rip), %rsi      # 0x11b6c
callq 0x4410
movq (%r12), %rsi
movq 0x96ff(%rip), %rdi      # 0x16ff0
callq 0x4340
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4360
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movl $0x1, %ebx
movq %rax, %rdi
callq 0x4250
testl %ebx, %ebx
jne 0xdd01
incl %r14d
movq (%r15), %r12
movq 0x8(%r15), %rax
subq %r12, %rax
sarq $0x4, %rax
cmpq %r14, %rax
ja 0xd72d
jmp 0xdcfc
movq 0x30(%rsp), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movq (%r12), %rbp
movq $-0x1, 0x28(%rsp)
leaq 0xb0(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0xd0(%rsp), %rdx
leaq 0x68(%rsp), %rcx
callq 0xc541
movl %eax, %r13d
testl %eax, %eax
je 0xd9d7
cmpl $-0x1, %r13d
jne 0xda2c
movl $0x20, %edx
movq 0x9650(%rip), %rdi      # 0x16ff0
leaq 0x41f2(%rip), %rsi      # 0x11b99
callq 0x4410
movq 0x963d(%rip), %rdi      # 0x16ff0
movq %rbp, %rsi
callq 0x4340
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x4360
jmp 0xda98
addq 0x48(%rsp), %rbp
addq 0x58(%rsp), %rbp
leaq 0x40(%rsp), %rdi
callq 0x42d0
movq 0x30(%rsp), %rdi
cmpl 0x8(%rdi), %eax
jne 0xdab9
movq (%rdi), %rax
leaq 0x40(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq *0x10(%rax)
movq %rax, %r13
movq 0x30(%rsp), %rax
xorq 0x18(%rsp), %rax
movq %r13, %rcx
notq %rcx
orq %rax, %rcx
je 0xe00a
xorl %ebx, %ebx
jmp 0xdac5
testl %r13d, %r13d
jle 0xdfeb
movl $0x20, %edx
movq 0x95af(%rip), %rdi      # 0x16ff0
leaq 0x417b(%rip), %rsi      # 0x11bc3
callq 0x4410
movq 0x959c(%rip), %rdi      # 0x16ff0
movq %rbp, %rsi
callq 0x4340
movq %rax, %rbx
movl $0x31, %edx
movq %rax, %rdi
leaq 0x4176(%rip), %rsi      # 0x11be4
callq 0x4410
movl %r13d, %esi
addq %rbp, %rsi
movq %rbx, %rdi
callq 0x4340
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x4360
movsbl %al, %esi
movq %r13, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4250
movq $-0x1, %r13
movl $0x1, %ebx
jmp 0xdac5
movq $-0x1, %r13
movl $0x9, %ebx
cmpl $0x9, %ebx
je 0xdace
testl %ebx, %ebx
jne 0xdaee
cmpq $-0x1, %r13
je 0xd964
movq 0x30(%rsp), %rax
cmpq 0x20(%rsp), %rax
je 0xdaf8
movq 0x38(%rsp), %rbp
jmp 0xdbca
movq 0x38(%rsp), %rbp
jmp 0xd925
cmpq %r13, 0x8(%r12)
movq 0x38(%rsp), %rbp
je 0xdbca
movl $0x16, %edx
movq 0x94dc(%rip), %rdi      # 0x16ff0
leaq 0x4120(%rip), %rsi      # 0x11c3b
callq 0x4410
movq 0x94c9(%rip), %rdi      # 0x16ff0
movq %r14, %rsi
callq 0x4240
movq %rax, %rbx
movl $0x14, %edx
movq %rax, %rdi
leaq 0x3b7d(%rip), %rsi      # 0x116be
callq 0x4410
movq (%r12), %rsi
movq %rbx, %rdi
callq 0x4340
movq %rax, %rbx
movl $0x17, %edx
movq %rax, %rdi
leaq 0x40ee(%rip), %rsi      # 0x11c52
callq 0x4410
movq 0x8(%r12), %rsi
movq %rbx, %rdi
callq 0x4340
movq %rax, %rbx
movl $0xf, %edx
movq %rax, %rdi
leaq 0x40e2(%rip), %rsi      # 0x11c6a
callq 0x4410
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4340
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4360
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4250
movl $0x0, 0x14(%rsp)
xorl %ebx, %ebx
movq 0x30(%rsp), %rax
cmpq 0x18(%rsp), %rax
jne 0xd925
movq 0x8(%r12), %rax
cmpq %r13, %rax
jl 0xdbf1
cmpq 0x28(%rsp), %rax
jle 0xd925
movl $0x16, %edx
movq 0x93f3(%rip), %rdi      # 0x16ff0
leaq 0x4076(%rip), %rsi      # 0x11c7a
callq 0x4410
movq 0x93e0(%rip), %rdi      # 0x16ff0
movq %r14, %rsi
callq 0x4240
movq %rax, %rbx
movl $0x14, %edx
movq %rax, %rdi
leaq 0x3a94(%rip), %rsi      # 0x116be
callq 0x4410
movq (%r12), %rsi
movq %rbx, %rdi
callq 0x4340
movq %rax, %rbx
movl $0x17, %edx
movq %rax, %rdi
leaq 0x4005(%rip), %rsi      # 0x11c52
callq 0x4410
movq 0x8(%r12), %rsi
movq %rbx, %rdi
callq 0x4340
movq %rax, %rbx
movl $0x1e, %edx
movq %rax, %rdi
leaq 0x4020(%rip), %rsi      # 0x11c91
callq 0x4410
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4340
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x348b(%rip), %rsi      # 0x1111e
callq 0x4410
movq 0x28(%rsp), %rsi
movq %rbx, %rdi
callq 0x4340
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x24d4(%rip), %rsi      # 0x1018b
callq 0x4410
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x4360
movsbl %al, %esi
movq %r13, %rdi
callq 0x4040
xorl %ebx, %ebx
movq %rax, %rdi
callq 0x4250
movl $0x0, 0x14(%rsp)
jmp 0xd925
movb $0x1, %al
movl $0x6, %ebx
jmp 0xdd05
movl $0x6, %ebx
movl 0x14(%rsp), %eax
cmpl $0x6, %ebx
movq 0x30(%rsp), %r14
jne 0xde20
testb $0x1, %al
je 0xdd4b
movq (%r14), %rax
movq %r14, %rdi
callq *0x20(%rax)
movq %rax, %rbx
testq %rax, %rax
je 0xde41
movq %rbx, %rdi
callq 0x4170
movq 0x9295(%rip), %rdi      # 0x16fd0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x4410
jmp 0xde5f
movl $0x6, %edx
movq 0x9279(%rip), %rdi      # 0x16fd0
leaq 0x3f66(%rip), %rsi      # 0x11cc4
callq 0x4410
movq (%r14), %rax
movq %r14, %rdi
callq *0x20(%rax)
movq %rax, %rbx
testq %rax, %rax
je 0xdecc
movq %rbx, %rdi
callq 0x4170
movq 0x9249(%rip), %rdi      # 0x16fd0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x4410
jmp 0xdeea
movq 0x9252(%rip), %rcx      # 0x16ff0
movq (%rcx), %rax
movq -0x18(%rax), %rax
leaq (%rcx,%rax), %rdi
movl 0x20(%rcx,%rax), %esi
orl $0x1, %esi
callq 0x4690
movl $0x1, %edx
movq 0x922f(%rip), %rdi      # 0x16ff0
leaq 0x332e(%rip), %rsi      # 0x110f6
callq 0x4410
movl 0x10(%rsp), %esi
movq 0x9218(%rip), %rdi      # 0x16ff0
callq 0x4240
movq %rax, %r14
movl $0x17, %edx
movq %rax, %rdi
leaq 0x3ce6(%rip), %rsi      # 0x11ad5
callq 0x4410
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4360
movsbl %al, %esi
movq %r14, %rdi
callq 0x4040
movl $0x4, %ebx
movq %rax, %rdi
callq 0x4250
testb $0xb, %bl
jne 0xdfb8
movq 0x70(%rsp), %r13
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
jne 0xd566
jmp 0xdf5f
movq 0x9188(%rip), %rcx      # 0x16fd0
movq (%rcx), %rax
movq -0x18(%rax), %rax
leaq (%rcx,%rax), %rdi
movl 0x20(%rcx,%rax), %esi
orl $0x1, %esi
callq 0x4690
movl $0x1, %edx
movq 0x9165(%rip), %rdi      # 0x16fd0
leaq 0x3284(%rip), %rsi      # 0x110f6
callq 0x4410
movl 0x10(%rsp), %esi
movq 0x914e(%rip), %rdi      # 0x16fd0
callq 0x4240
movq %rax, %r14
movl $0x13, %edx
movq %rax, %rdi
leaq 0x3e17(%rip), %rsi      # 0x11cb0
callq 0x4410
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4360
movsbl %al, %esi
movq %r14, %rdi
callq 0x4040
xorl %ebx, %ebx
movq %rax, %rdi
callq 0x4250
jmp 0xde20
movq 0x90fd(%rip), %rcx      # 0x16fd0
movq (%rcx), %rax
movq -0x18(%rax), %rax
leaq (%rcx,%rax), %rdi
movl 0x20(%rcx,%rax), %esi
orl $0x1, %esi
callq 0x4690
movl $0x1, %edx
movq 0x90da(%rip), %rdi      # 0x16fd0
leaq 0x31f9(%rip), %rsi      # 0x110f6
callq 0x4410
movl 0x10(%rsp), %esi
movq 0x90c3(%rip), %rdi      # 0x16fd0
callq 0x4240
movq %rax, %r14
movl $0x17, %edx
movq %rax, %rdi
leaq 0x3da7(%rip), %rsi      # 0x11ccb
callq 0x4410
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4360
movsbl %al, %esi
movq %r14, %rdi
callq 0x4040
movl $0x0, 0xc(%rsp)
movq %rax, %rdi
callq 0x4250
xorl %ebx, %ebx
jmp 0xde20
leaq 0xb0(%rsp), %rdi
callq 0x4760
movl 0xc(%rsp), %ebx
jmp 0xdfba
movq 0x9077(%rip), %rbx      # 0x16ff0
leaq 0x3a23(%rip), %rsi      # 0x119a3
movl $0x39, %edx
movq %rbx, %rdi
callq 0x4410
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4360
movsbl %al, %esi
movq 0x9045(%rip), %rdi      # 0x16ff0
callq 0x4040
movq %rax, %rdi
callq 0x4250
xorl %ebx, %ebx
leaq 0x80(%rsp), %rdi
callq 0xf2a4
leaq 0xd0(%rsp), %rdi
callq 0x40c0
andb $0x1, %bl
movl %ebx, %eax
addq $0x2d8, %rsp            # imm = 0x2D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3bc8(%rip), %rdi      # 0x11bba
leaq 0x3949(%rip), %rsi      # 0x11942
leaq 0x3953(%rip), %rcx      # 0x11953
movl $0x2ab, %edx            # imm = 0x2AB
callq 0x4210
leaq 0x3c05(%rip), %rdi      # 0x11c16
leaq 0x392a(%rip), %rsi      # 0x11942
leaq 0x3934(%rip), %rcx      # 0x11953
movl $0x2bb, %edx            # imm = 0x2BB
callq 0x4210
leaq 0x2880(%rip), %rdi      # 0x108b0
leaq 0x390b(%rip), %rsi      # 0x11942
leaq 0x3915(%rip), %rcx      # 0x11953
movl $0x21f, %edx            # imm = 0x21F
callq 0x4210
jmp 0xe09b
movq %rax, %rbx
movl $0x1e8, %esi            # imm = 0x1E8
movq %r13, %rdi
jmp 0xe080
jmp 0xe09b
jmp 0xe09b
movq %rax, %rbx
movl $0x358, %esi            # imm = 0x358
movq 0x18(%rsp), %rdi
jmp 0xe080
movq %rax, %rbx
jmp 0xe0ab
jmp 0xe09b
jmp 0xe09b
movq %rax, %rbx
movl $0x240, %esi            # imm = 0x240
movq 0x20(%rsp), %rdi
callq 0x43a0
jmp 0xe09e
jmp 0xe09b
jmp 0xe09b
jmp 0xe09b
jmp 0xe09b
jmp 0xe09b
jmp 0xe09b
jmp 0xe09b
jmp 0xe09b
jmp 0xe09b
jmp 0xe09b
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0xf2a4
leaq 0xd0(%rsp), %rdi
callq 0x40c0
movq %rbx, %rdi
callq 0x46e0