// File: /workspace/github_cpp_makefile_star2_O3/cpearce[P]OggIndex/src/Validate.cpp
// Function: Skeleton::Decode(ogg_page*, long&)
virtual ogg_int64_t Decode(ogg_page* page, ogg_int64_t& end_time) {
    end_time = -1;
    int ret = ogg_stream_pagein(&mStreamState, page);
    assert(ret == 0);
    ogg_packet op;
    int packets_decoded = 0;
    while ((ret = ogg_stream_packetout(&mStreamState, &op)) != 0) {
      packets_decoded++;
      assert(!mReadHeaders);
      if (ret != 1) {
        cout << "WARNING: out of sync while reading skeleton packets!" << endl;
        continue;
      }

      if (IsFisheadPacket(&op)) {
        ogg_uint16_t ver_maj = LEUint16(op.packet + SKELETON_VERSION_MAJOR_OFFSET);
        ogg_uint16_t ver_min = LEUint16(op.packet + SKELETON_VERSION_MINOR_OFFSET);
        ogg_uint32_t version = SKELETON_VERSION(ver_maj, ver_min);
        if (version != SKELETON_VERSION(SKELETON_VERSION_MAJOR,SKELETON_VERSION_MINOR)) { 
          cerr << "FAIL: Skeleton version " << ver_maj << "." <<ver_min   
               << " detected. I can only validate version "
               << SKELETON_VERSION_MAJOR << "." << SKELETON_VERSION_MINOR << endl;
          exit(-1);
        }
        mContentOffset = LEUint64(op.packet + SKELETON_CONTENT_OFFSET);
        if (mContentOffset == 0) {
          cerr << "Verification Failure: content offset is 0" << endl;
          return false;
        }

        mFileLength = LEUint64(op.packet + SKELETON_FILE_LENGTH_OFFSET);
        continue;
      }
      
      if (IsFisbonePacket(&op)) {
        // Nothing to check here.
        continue;
      }
      
      if (IsIndexPacket(&op)) {
        bool r = DecodeIndex(mIndex, &op);
        if (!r) {
          cerr << "FAIL: Can't parse skeleton index packet." << endl;
        }
        continue;
      }

      if (op.e_o_s) {
        assert(ogg_page_eos(page) != 0);
        mReadHeaders = true;
        continue;
      }

      cout << "WARNING: Unknown packet in skeleton track!" << endl;
    }  
    if (packets_decoded != ogg_page_packets(page)) {
      cout << "WARNING: Only decoded " << packets_decoded << " packets from "
           << "skeleon page, but expected " << ogg_page_packets(page) << endl;
    }
    return true;
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %r14
movq $-0x1, (%rdx)
leaq 0x10(%rdi), %r12
movq %r12, %rdi
movq %rsi, (%rsp)
callq 0x4540
testl %eax, %eax
jne 0xef13
leaq 0x18(%rsp), %rsi
movq %r12, %rdi
callq 0x4590
testl %eax, %eax
je 0xed98
leaq 0x1a8(%r14), %rcx
movq %rcx, 0x10(%rsp)
xorl %ebp, %ebp
leaq 0x18(%rsp), %r13
movq 0x83e3(%rip), %rbx      # 0x16fd0
leaq 0x33db(%rip), %r15      # 0x11fcf
movq %r14, 0x8(%rsp)
cmpb $0x1, 0xc(%r14)
je 0xee75
cmpl $0x1, %eax
jne 0xeca8
movq %r13, %rdi
callq 0xc7e0
testb %al, %al
je 0xecf9
movq %rbx, %r15
movq %r12, %rbx
movq %r13, %r12
movq 0x18(%rsp), %rdi
addq $0x8, %rdi
callq 0xca7f
movl %eax, %r13d
movq 0x18(%rsp), %rdi
addq $0xa, %rdi
callq 0xca7f
movl %r13d, %ecx
shll $0x10, %ecx
movzwl %ax, %r14d
orl %r14d, %ecx
cmpl $0x40000, %ecx          # imm = 0x40000
jne 0xee94
movq 0x18(%rsp), %rdi
addq $0x48, %rdi
callq 0xc8ef
movq 0x8(%rsp), %r14
movq %rax, 0x1e0(%r14)
testq %rax, %rax
je 0xee1f
movq 0x18(%rsp), %rdi
addq $0x40, %rdi
callq 0xc8ef
movq %rax, 0x1d8(%r14)
movq %r12, %r13
movq %rbx, %r12
movq %r15, %rbx
leaq 0x3329(%rip), %r15      # 0x11fcf
jmp 0xecdf
movl $0x34, %edx
movq %rbx, %rdi
movq %r15, %rsi
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
movq %r12, %rdi
movq %r13, %rsi
callq 0x4590
incl %ebp
testl %eax, %eax
jne 0xebf9
jmp 0xed9a
movq %r13, %rdi
callq 0xc803
testb %al, %al
jne 0xecdf
movq %r13, %rdi
callq 0xc15e
testb %al, %al
je 0xed61
movq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x4feb
testb %al, %al
jne 0xecdf
movl $0x28, %edx
movq 0x82c2(%rip), %r14      # 0x16ff0
movq %r14, %rdi
leaq 0x331e(%rip), %rsi      # 0x12056
callq 0x4410
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4360
movsbl %al, %esi
movq %r14, %rdi
movq 0x8(%rsp), %r14
jmp 0xecd2
cmpq $0x0, 0x30(%rsp)
je 0xed84
movq (%rsp), %rdi
callq 0x4100
testl %eax, %eax
je 0xef32
movb $0x1, 0xc(%r14)
jmp 0xecdf
movl $0x2a, %edx
movq %rbx, %rdi
leaq 0x3304(%rip), %rsi      # 0x12097
jmp 0xecb3
xorl %ebp, %ebp
movq (%rsp), %r14
movq %r14, %rdi
callq 0x4700
movl $0x1, %ebx
cmpl %eax, %ebp
je 0xee63
movq 0x8216(%rip), %rbx      # 0x16fd0
leaq 0x3301(%rip), %rsi      # 0x120c2
movl $0x16, %edx
movq %rbx, %rdi
callq 0x4410
movq %rbx, %rdi
movl %ebp, %esi
callq 0x4690
movq %rax, %rbx
leaq 0x32f7(%rip), %rsi      # 0x120d9
movl $0xe, %edx
movq %rax, %rdi
callq 0x4410
leaq 0x32f2(%rip), %rsi      # 0x120e8
movl $0x1b, %edx
movq %rbx, %rdi
callq 0x4410
movq %r14, %rdi
callq 0x4700
movq %rbx, %rdi
movl %eax, %esi
callq 0x4690
movq %rax, %r14
movl $0x1, %ebx
jmp 0xee3c
leaq 0x3206(%rip), %rsi      # 0x1202c
movl $0x29, %edx
movq 0x81be(%rip), %r14      # 0x16ff0
movq %r14, %rdi
callq 0x4410
xorl %ebx, %ebx
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 %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3145(%rip), %rdi      # 0x11fc1
leaq 0x2ac2(%rip), %rsi      # 0x11945
leaq 0x30f7(%rip), %rcx      # 0x11f81
movl $0x1d7, %edx            # imm = 0x1D7
callq 0x4210
movq 0x8155(%rip), %rdi      # 0x16ff0
leaq 0x12a4(%rip), %rsi      # 0x10146
callq 0x4370
movzwl %r13w, %esi
movq %rax, %rdi
callq 0x4660
leaq 0x1cb3(%rip), %rbx      # 0x10b6d
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4370
movq %rax, %rdi
movl %r14d, %esi
callq 0x4660
leaq 0x312d(%rip), %rsi      # 0x12004
movq %rax, %rdi
callq 0x4370
movq %rax, %rdi
movl $0x4, %esi
callq 0x4690
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4370
movq %rax, %rdi
xorl %esi, %esi
callq 0x4690
movq %rax, %rdi
callq 0x41c0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x4430
leaq 0x10ea(%rip), %rdi      # 0x10004
leaq 0x2a24(%rip), %rsi      # 0x11945
leaq 0x3059(%rip), %rcx      # 0x11f81
movl $0x1d2, %edx            # imm = 0x1D2
callq 0x4210
leaq 0x3146(%rip), %rdi      # 0x1207f
leaq 0x2a05(%rip), %rsi      # 0x11945
leaq 0x303a(%rip), %rcx      # 0x11f81
movl $0x1ff, %edx            # imm = 0x1FF
callq 0x4210
nop