// File: /workspace/github_cpp_makefile_star2_O1/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, %r15
movq $-0x1, (%rdx)
leaq 0x10(%rdi), %r12
movq %r12, %rdi
movq %rsi, 0x8(%rsp)
callq 0x4550
testl %eax, %eax
jne 0xf25c
leaq 0x18(%rsp), %rsi
movq %r12, %rdi
callq 0x45a0
testl %eax, %eax
je 0xf0ff
leaq 0x1a8(%r15), %rcx
movq %rcx, 0x10(%rsp)
leaq 0x18(%rsp), %rbx
movq 0x80c0(%rip), %r13      # 0x16fd0
xorl %ebp, %ebp
cmpb $0x1, 0xc(%r15)
je 0xf1bf
cmpl $0x1, %eax
jne 0xefad
movq %rbx, %rdi
callq 0xca6a
testb %al, %al
je 0xefee
movq %r12, %r14
movq %rbx, %r12
movq 0x18(%rsp), %rdi
addq $0x8, %rdi
callq 0xcd11
movl %eax, %r13d
movq 0x18(%rsp), %rdi
addq $0xa, %rdi
callq 0xcd11
movl %r13d, %ecx
shll $0x10, %ecx
movzwl %ax, %ebx
orl %ebx, %ecx
cmpl $0x40000, %ecx          # imm = 0x40000
jne 0xf1de
movq 0x18(%rsp), %rdi
addq $0x48, %rdi
callq 0xcb90
movq %rax, %rbx
movq %rax, 0x1e0(%r15)
testq %rax, %rax
je 0xf05a
movq 0x18(%rsp), %rdi
addq $0x40, %rdi
callq 0xcb90
movq %rax, 0x1d8(%r15)
jmp 0xf09d
movl $0x34, %edx
movq %r13, %rdi
leaq 0x3010(%rip), %rsi      # 0x11fcc
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
jmp 0xf0b3
movq %rbx, %rdi
callq 0xca8d
testb %al, %al
jne 0xf0b3
movq %rbx, %rdi
callq 0xc3a2
testb %al, %al
je 0xf0ca
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x505a
testb %al, %al
jne 0xf0b3
movl $0x28, %edx
movq 0x7fc1(%rip), %r14      # 0x16ff0
movq %r14, %rdi
leaq 0x301a(%rip), %rsi      # 0x12053
callq 0x4410
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4360
movsbl %al, %esi
movq %r14, %rdi
jmp 0xefdc
movl $0x29, %edx
movq 0x7f8a(%rip), %r13      # 0x16ff0
movq %r13, %rdi
leaq 0x2fb9(%rip), %rsi      # 0x12029
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
testq %rbx, %rbx
movq %r12, %rbx
movq %r14, %r12
movq 0x7f23(%rip), %r13      # 0x16fd0
je 0xf1aa
movq %r12, %rdi
movq %rbx, %rsi
callq 0x45a0
incl %ebp
testl %eax, %eax
jne 0xef12
jmp 0xf101
cmpq $0x0, 0x30(%rsp)
je 0xf0eb
movq 0x8(%rsp), %rdi
callq 0x4100
testl %eax, %eax
je 0xf27b
movb $0x1, 0xc(%r15)
jmp 0xf0b3
movl $0x2a, %edx
movq %r13, %rdi
leaq 0x2f9a(%rip), %rsi      # 0x12094
jmp 0xefbc
xorl %ebp, %ebp
movq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x4710
movl $0x1, %r14d
cmpl %eax, %ebp
je 0xf1ad
movq 0x7ead(%rip), %rbx      # 0x16fd0
leaq 0x2f95(%rip), %rsi      # 0x120bf
movl $0x16, %edx
movq %rbx, %rdi
callq 0x4410
movq %rbx, %rdi
movl %ebp, %esi
callq 0x46a0
movq %rax, %rbx
leaq 0x2f8b(%rip), %rsi      # 0x120d6
movl $0xe, %edx
movq %rax, %rdi
callq 0x4410
leaq 0x2f86(%rip), %rsi      # 0x120e5
movl $0x1b, %edx
movq %rbx, %rdi
callq 0x4410
movq %r15, %rdi
callq 0x4710
movq %rbx, %rdi
movl %eax, %esi
callq 0x46a0
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
jmp 0xf1ad
xorl %r14d, %r14d
movq %r14, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2df8(%rip), %rdi      # 0x11fbe
leaq 0x2775(%rip), %rsi      # 0x11942
leaq 0x2daa(%rip), %rcx      # 0x11f7e
movl $0x1d7, %edx            # imm = 0x1D7
callq 0x4210
movq 0x7e0b(%rip), %rdi      # 0x16ff0
leaq 0xf5a(%rip), %rsi       # 0x10146
callq 0x4370
movzwl %r13w, %esi
movq %rax, %rdi
callq 0x4670
leaq 0x1969(%rip), %r14      # 0x10b6d
movq %rax, %rdi
movq %r14, %rsi
callq 0x4370
movq %rax, %rdi
movl %ebx, %esi
callq 0x4670
leaq 0x2de1(%rip), %rsi      # 0x12001
movq %rax, %rdi
callq 0x4370
movq %rax, %rdi
movl $0x4, %esi
callq 0x46a0
movq %rax, %rdi
movq %r14, %rsi
callq 0x4370
movq %rax, %rdi
xorl %esi, %esi
callq 0x46a0
movq %rax, %rdi
callq 0x41c0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x4430
leaq 0xda1(%rip), %rdi       # 0x10004
leaq 0x26d8(%rip), %rsi      # 0x11942
leaq 0x2d0d(%rip), %rcx      # 0x11f7e
movl $0x1d2, %edx            # imm = 0x1D2
callq 0x4210
leaq 0x2dfa(%rip), %rdi      # 0x1207c
leaq 0x26b9(%rip), %rsi      # 0x11942
leaq 0x2cee(%rip), %rcx      # 0x11f7e
movl $0x1ff, %edx            # imm = 0x1FF
callq 0x4210