// File: /workspace/github_cpp_makefile_star2_O2/cpearce[P]OggIndex/src/Decoder.cpp
// Function: TheoraDecoder::GetKeyframes()
virtual const vector<KeyFrameInfo>& GetKeyframes() {
    // Construct list of keyframes from page and frame info lists.
    // Need to determine frame start offsets and fill key points array.

    if (mKeyFrames.size() > 0 || mFrames.size() == 0) {
      return mKeyFrames;
    }

    // Packetno of the last packet which has started.
    ogg_int64_t started_packetno = mFirstPacketno - 1;
    // Must at least have header packets.
    assert(started_packetno >= 2);
    ogg_int64_t pageno = 0;
    ogg_int64_t prev_keyframe_pageno = -INT_MAX;
    ogg_int64_t prev_keyframe_start_time = -INT_MAX;
    for (unsigned f=0; f<mFrames.size(); f++) {
      Frame& frame = mFrames[f];
      ogg_int64_t packetno = frame.packetno;

      while (pageno < (ogg_int64_t) mPages.size() &&
             started_packetno + mPages[pageno].num_packets < packetno)
      {
        started_packetno += mPages[pageno].num_packets;
        pageno++;  
      } // pages
      assert(pageno < (ogg_int64_t) mPages.size());
      assert(started_packetno < packetno &&
             started_packetno + mPages[pageno].num_packets >= packetno);

      if (pageno == prev_keyframe_pageno) {
        // Only consider the pages' first key point.
        continue;
      }

      KeyFrameInfo k(mPages[pageno].offset,
                     StartTime(frame.granulepos));
      assert(k.mTime >= 0);

      // Only add the keyframe to the list if it's far enough after the
      // previous keyframe.
      if (k.mTime > prev_keyframe_start_time + gOptions.GetKeyPointInterval()) {
        prev_keyframe_start_time = k.mTime;
        mKeyFrames.push_back(k);
      }
      prev_keyframe_pageno = pageno;

    } // for each frame

    return mKeyFrames;
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
leaq 0x278(%rdi), %rax
movq %rax, (%rsp)
movq 0x280(%rdi), %rax
cmpq 0x278(%rdi), %rax
je 0x5cec
movq (%rsp), %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x260(%rdi), %rcx
movq 0x268(%rdi), %rsi
cmpq %rcx, %rsi
je 0x5cd9
movq 0x240(%rdi), %rbp
cmpq $0x2, %rbp
jle 0x5e6b
decq %rbp
xorl %r13d, %r13d
movq $-0x7fffffff, %r15      # imm = 0x80000001
pushq $0x18
popq %r14
movq $-0x7fffffff, 0x8(%rsp) # imm = 0x80000001
xorl %ebx, %ebx
movl %ebx, %ebx
movq %rsi, %rax
subq %rcx, %rax
cqto
idivq %r14
cmpq %rbx, %rax
jbe 0x5cd9
imulq $0x18, %rbx, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movq 0x248(%rdi), %r8
movq 0x250(%rdi), %r9
subq %r8, %r9
sarq $0x4, %r9
movq %r13, %r10
shlq $0x4, %r10
addq %r10, %r8
addq $0x8, %r8
cmpq %r9, %r13
jge 0x5e0e
movslq (%r8), %r10
addq %rbp, %r10
cmpq %rdx, %r10
jge 0x5d8d
incq %r13
addq $0x10, %r8
movq %r10, %rbp
jmp 0x5d6d
cmpq %rdx, %rbp
jge 0x5e2d
cmpq %r13, %r15
je 0x5e07
movq -0x8(%r8), %rcx
movq %rcx, 0x10(%rsp)
movq 0x8(%rax), %rsi
movq %rdi, %r15
callq 0x6012
movq %rax, %r12
movq 0x10(%rsp), %rax
movq %rax, 0x18(%rsp)
movq %r12, 0x20(%rsp)
testq %r12, %r12
js 0x5e4c
leaq 0xf62e(%rip), %rax      # 0x15400
movslq 0x48(%rax), %rax
addq 0x8(%rsp), %rax
cmpq %rax, %r12
jle 0x5df3
movq (%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x658a
movq %r12, 0x8(%rsp)
movq %r15, %rdi
movq 0x260(%r15), %rcx
movq 0x268(%r15), %rsi
movq %r13, %r15
incl %ebx
jmp 0x5d2c
leaq 0x882f(%rip), %rdi      # 0xe644
leaq 0x81f1(%rip), %rsi      # 0xe00d
leaq 0x87df(%rip), %rcx      # 0xe602
movl $0xad, %edx
callq 0x4210
leaq 0x8835(%rip), %rdi      # 0xe669
leaq 0x81d2(%rip), %rsi      # 0xe00d
leaq 0x87c0(%rip), %rcx      # 0xe602
movl $0xaf, %edx
callq 0x4210
leaq 0x886f(%rip), %rdi      # 0xe6c2
leaq 0x81b3(%rip), %rsi      # 0xe00d
leaq 0x87a1(%rip), %rcx      # 0xe602
movl $0xb8, %edx
callq 0x4210
leaq 0x877a(%rip), %rdi      # 0xe5ec
leaq 0x8194(%rip), %rsi      # 0xe00d
leaq 0x8782(%rip), %rcx      # 0xe602
movl $0x9f, %edx
callq 0x4210