// File: /workspace/github_cpp_makefile_star2_O1/cpearce[P]OggIndex/src/SkeletonEncoder.cpp
// Function: SkeletonEncoder::AddFisbonePackets()
void
SkeletonEncoder::AddFisbonePackets() {
  if (HasFisbonePackets()) {
    // We have fisbone packets from the existing skeleton track. Convert to
    // Skeleton 4.0.
    for (ogg_uint32_t i=1; i<mSkeletonDecoder->mPackets.size()-1; i++) {
      ogg_packet* fisbone = UpdateFisbone(mSkeletonDecoder->mPackets[i]);
      if (fisbone) {
        mIndexPackets.push_back(fisbone);
      }
      mPacketCount++;
    }
  } else {
    // Have to construct fisbone packets.
    for (ogg_uint32_t i=0; i<mDecoders.size(); i++) {
      FisboneInfo info = mDecoders[i]->GetFisboneInfo();
      string headers = info.MessageHeaders();
      unsigned packetSize = FISBONE_HEADER_OFFSET + headers.size();

      ogg_packet* packet = new ogg_packet();
      memset(packet, 0, sizeof(ogg_packet));
      
      packet->packet = new unsigned char[packetSize];
      memset(packet->packet, 0, packetSize);

      // Magic bytes identifier.
      memcpy(packet->packet, FISBONE_MAGIC, FISBONE_MAGIC_LEN);
      
      // Offset of the message header fields.
      WriteLEInt32(packet->packet+FISBONE_HEADERS_OFFSET_FIELD_OFFSET,
                   FISBONE_HEADER_OFFSET);
      
      // Serialno of the stream.
      WriteLEUint32(packet->packet+FISBONE_SERIALNO_OFFSET,
                    mDecoders[i]->GetSerial());

      // Number of header packets. 3 for both vorbis and theora.
      WriteLEUint32(packet->packet+FISBONE_NUM_HEADERS_OFFSET, 3);
      
      // Granulrate numerator.
      WriteLEInt64(packet->packet+FISBONE_GRAN_NUMER_OFFSET, info.mGranNumer);
      
      // Granulrate denominator.
      WriteLEInt64(packet->packet+FISBONE_GRAN_DENOM_OFFSET, info.mGranDenom);
      
      // Start granule.
      WriteLEInt64(packet->packet+FISBONE_START_GRAN_OFFSET, 0);
      
      // Preroll.
      WriteLEUint32(packet->packet+FISBONE_PREROLL_OFFSET, info.mPreroll);
      
      // Granule shift.
      WriteLEUint32(packet->packet+FISBONE_GRAN_SHIFT_OFFSET, info.mGranuleShift);

      // Message header field, Content-Type */
      memcpy(packet->packet+FISBONE_HEADER_OFFSET,
             headers.c_str(),
             headers.size());

      packet->b_o_s = 0;
      packet->e_o_s = 0;
      packet->bytes = packetSize;

      packet->packetno = mPacketCount;      
      mIndexPackets.push_back(packet);
      mPacketCount++;
    }        
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdi, %rbx
movq 0x18(%rdi), %rax
testq %rax, %rax
je 0x9bfd
movq 0x1d8(%rax), %rcx
subq 0x1d0(%rax), %rcx
movq 0x8(%rbx), %rax
subq (%rbx), %rax
sarq $0x3, %rcx
sarq $0x3, %rax
addq $0x2, %rax
cmpq %rax, %rcx
jne 0x9bfd
movq 0x18(%rbx), %rcx
movq 0x1d0(%rcx), %rax
movq 0x1d8(%rcx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
addq $-0x3, %rcx
cmpq $-0x3, %rcx
ja 0x9e36
leaq 0x38(%rbx), %r14
movl $0x1, %ecx
movl $0x2, %ebp
leaq 0x38(%rsp), %r15
movq (%rax,%rcx,8), %rsi
movq %rbx, %rdi
callq 0xb108
movq %rax, 0x38(%rsp)
testq %rax, %rax
je 0x9bd0
movq 0x40(%rbx), %rsi
cmpq 0x48(%rbx), %rsi
je 0x9bc5
movq %rax, (%rsi)
addq $0x8, 0x40(%rbx)
jmp 0x9bd0
movq %r14, %rdi
movq %r15, %rdx
callq 0xbf76
incl 0x34(%rbx)
movl %ebp, %ecx
movq 0x18(%rbx), %rdx
movq 0x1d0(%rdx), %rax
movq 0x1d8(%rdx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
decq %rdx
incl %ebp
cmpq %rcx, %rdx
ja 0x9b9b
jmp 0x9e36
movq (%rbx), %rax
cmpq %rax, 0x8(%rbx)
je 0x9e36
leaq 0x38(%rbx), %rcx
movq %rcx, 0x30(%rsp)
movl $0x1, %r12d
xorl %r15d, %r15d
movq (%rax,%r15,8), %rsi
movq (%rsi), %rax
leaq 0x38(%rsp), %r14
movq %r14, %rdi
callq *0x40(%rax)
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0xb954
movq 0x18(%rsp), %rbp
movl $0x30, %edi
callq 0x4380
movq %rax, %r13
addl $0x34, %ebp
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rax)
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
movq %rax, 0x8(%rsp)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movq %rbp, %rdi
callq 0x4030
movq %rax, %r14
movq %rax, (%r13)
movq %rax, %rdi
xorl %esi, %esi
movq %rbp, %rdx
callq 0x41f0
movabsq $0x656e6f62736966, %rax # imm = 0x656E6F62736966
movq %rax, (%r14)
addq $0x8, %r14
movq %r14, %rdi
movl $0x34, %esi
callq 0xcc7a
movq 0x8(%rsp), %rax
movq (%rax), %rdi
addq $0xc, %rdi
movq (%rbx), %rax
movq (%rax,%r15,8), %rax
movl 0x1a0(%rax), %esi
callq 0xcc16
movq 0x8(%rsp), %rax
movq (%rax), %rdi
addq $0x10, %rdi
movl $0x3, %esi
callq 0xcc16
movq 0x8(%rsp), %rax
movq (%rax), %rdi
addq $0x14, %rdi
movq 0x38(%rsp), %rsi
callq 0xcb94
movq 0x8(%rsp), %rax
movq (%rax), %rdi
addq $0x1c, %rdi
movq 0x40(%rsp), %rsi
callq 0xcb94
movq 0x8(%rsp), %rax
movq (%rax), %rdi
addq $0x24, %rdi
xorl %esi, %esi
callq 0xcb94
movq 0x8(%rsp), %rax
movq (%rax), %rdi
addq $0x2c, %rdi
movl 0x48(%rsp), %esi
callq 0xcc16
movq 0x8(%rsp), %rax
movq (%rax), %rdi
addq $0x30, %rdi
movl 0x4c(%rsp), %esi
callq 0xcc16
movq 0x8(%rsp), %r14
movq (%r14), %rdi
addq $0x34, %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
callq 0x42c0
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r14)
movq %rbp, 0x8(%r14)
movslq 0x34(%rbx), %rax
movq %rax, 0x28(%r14)
movq 0x40(%rbx), %rsi
cmpq 0x48(%rbx), %rsi
je 0x9d88
movq %r14, (%rsi)
addq $0x8, 0x40(%rbx)
jmp 0x9d97
movq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0xbf76
incl 0x34(%rbx)
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x9db6
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x9ddb
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x9dfd
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x9e19
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x43a0
movl %r12d, %r15d
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
incl %r12d
cmpq %r15, %rcx
ja 0x9c1c
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x9e6c
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x9e6c
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x43a0
leaq 0x38(%rsp), %rdi
callq 0x6cf4
movq %rbx, %rdi
callq 0x46e0