// File: /workspace/github_cpp_makefile_star2_O3/cpearce[P]OggIndex/src/Validate.cpp
// Function: Vorbis::Decode(ogg_page*, long&)
virtual ogg_int64_t Decode(ogg_page* page, ogg_int64_t& end_time) {
    ogg_packet op;
    assert(ogg_stream_packetout(&mStreamState, &op) == 0);
    int ret = ogg_stream_pagein(&mStreamState, page);
    assert(ret == 0);
    int total_samples = 0;
    ogg_int64_t start_time = -1;
    int packet_count = 0;
    while (ogg_stream_packetout(&mStreamState, &op) == 1) {
      packet_count++;
      if (!mReadHeaders) {
        ogg_int32_t ret = vorbis_synthesis_headerin(&mInfo, &mComment, &op);
        if (ret == 0) {
          mHeaderPacketsRead++;
        }
        mReadHeaders = (mHeaderPacketsRead == 3);
        if (mReadHeaders) {
          ret = vorbis_synthesis_init(&mDsp, &mInfo);
          assert(ret == 0);
          ret = vorbis_block_init(&mDsp, &mBlock);
          assert(ret == 0);        
        }
        continue;
      }

      // We only expect the last packet in a page to have non -1 granulepos.
      assert(start_time == -1);
      int samples = 0;
      
      // Decode the vorbis to determine how many samples are in each packet.
      if (vorbis_synthesis(&mBlock, &op) == 0) {
        ret = vorbis_synthesis_blockin(&mDsp, &mBlock);
        assert(ret == 0);
      }
      while ((samples = vorbis_synthesis_pcmout(&mDsp, 0)) > 0) {
        total_samples += samples;
        ret = vorbis_synthesis_read(&mDsp, samples);
        assert(ret == 0);
      }
      // We only expect the last packet in a page to have a granulepos.
      assert(start_time == -1);
      if (op.granulepos != -1) {
        assert(op.granulepos == ogg_page_granulepos(page));
        ogg_int64_t start_granule =
          (total_samples < op.granulepos) ? (op.granulepos - total_samples) : 0;
        start_time = (1000 * start_granule) / mDsp.vi->rate;
        end_time = (1000 * ogg_page_granulepos(page)) / mDsp.vi->rate;
      }
    }

    return start_time;
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, 0x18(%rsp)
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x10(%rdi), %r12
leaq 0x28(%rsp), %rsi
movq %r12, %rdi
callq 0x4590
testl %eax, %eax
jne 0xea1f
movq %r12, %rdi
movq %rbx, 0x10(%rsp)
movq %rbx, %rsi
callq 0x4540
testl %eax, %eax
jne 0xea3e
leaq 0x28(%rsp), %rsi
movq %r12, %rdi
callq 0x4590
movq $-0x1, 0x8(%rsp)
cmpl $0x1, %eax
jne 0xe9ae
leaq 0x1a8(%r15), %r13
leaq 0x1e0(%r15), %rax
movq %rax, 0x20(%rsp)
leaq 0x200(%r15), %rbx
leaq 0x290(%r15), %rdi
movq $-0x1, 0x8(%rsp)
xorl %ebp, %ebp
movq %rdi, %r14
cmpb $0x0, 0xc(%r15)
jne 0xe8c7
movq %r13, %rdi
movq 0x20(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x4130
movl 0x350(%r15), %ecx
testl %eax, %eax
jne 0xe87d
incl %ecx
movl %ecx, 0x350(%r15)
cmpl $0x3, %ecx
sete 0xc(%r15)
jne 0xe8ad
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4310
testl %eax, %eax
jne 0xea00
movq %rbx, %rdi
movq %r14, %rsi
callq 0x44d0
testl %eax, %eax
jne 0xe9e1
movq %r12, %rdi
leaq 0x28(%rsp), %rsi
callq 0x4590
cmpl $0x1, %eax
movq %r14, %rdi
je 0xe850
jmp 0xe9ae
cmpq $-0x1, 0x8(%rsp)
jne 0xea5d
movq %rdi, 0x8(%rsp)
leaq 0x28(%rsp), %rsi
callq 0x41e0
testl %eax, %eax
jne 0xe8fb
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0x42b0
testl %eax, %eax
jne 0xea9b
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4420
testl %eax, %eax
jle 0xe91e
addl %eax, %ebp
movq %rbx, %rdi
movl %eax, %esi
callq 0x4550
testl %eax, %eax
je 0xe8fb
jmp 0xe9c2
movq 0x48(%rsp), %rax
cmpq $-0x1, %rax
je 0xe9a0
movq 0x10(%rsp), %rdi
movq %rax, 0x8(%rsp)
callq 0x4610
cmpq %rax, 0x8(%rsp)
jne 0xea7c
movl %ebp, %ecx
movq 0x48(%rsp), %rdx
movq %rdx, %rax
subq %rcx, %rax
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
cmpq %rcx, %rdx
movl $0x0, %ecx
cmovleq %rcx, %rax
movq 0x208(%r15), %rcx
cqto
idivq 0x8(%rcx)
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %rdi
callq 0x4610
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
movq 0x208(%r15), %rcx
cqto
idivq 0x8(%rcx)
movq 0x18(%rsp), %rcx
movq %rax, (%rcx)
jmp 0xe8ad
movq $-0x1, 0x8(%rsp)
jmp 0xe8ad
movq 0x8(%rsp), %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x163b(%rip), %rdi      # 0x10004
leaq 0x2f75(%rip), %rsi      # 0x11945
leaq 0x354f(%rip), %rcx      # 0x11f26
movl $0x143, %edx            # imm = 0x143
callq 0x4210
leaq 0x161c(%rip), %rdi      # 0x10004
leaq 0x2f56(%rip), %rsi      # 0x11945
leaq 0x3530(%rip), %rcx      # 0x11f26
movl $0x132, %edx            # imm = 0x132
callq 0x4210
leaq 0x15fd(%rip), %rdi      # 0x10004
leaq 0x2f37(%rip), %rsi      # 0x11945
leaq 0x3511(%rip), %rcx      # 0x11f26
movl $0x130, %edx            # imm = 0x130
callq 0x4210
leaq 0x34d2(%rip), %rdi      # 0x11ef8
leaq 0x2f18(%rip), %rsi      # 0x11945
leaq 0x34f2(%rip), %rcx      # 0x11f26
movl $0x120, %edx            # imm = 0x120
callq 0x4210
leaq 0x15bf(%rip), %rdi      # 0x10004
leaq 0x2ef9(%rip), %rsi      # 0x11945
leaq 0x34d3(%rip), %rcx      # 0x11f26
movl $0x122, %edx            # imm = 0x122
callq 0x4210
leaq 0x1d0e(%rip), %rdi      # 0x10772
leaq 0x2eda(%rip), %rsi      # 0x11945
leaq 0x34b4(%rip), %rcx      # 0x11f26
movl $0x138, %edx            # imm = 0x138
callq 0x4210
leaq 0x32fa(%rip), %rdi      # 0x11d7d
leaq 0x2ebb(%rip), %rsi      # 0x11945
leaq 0x3495(%rip), %rcx      # 0x11f26
movl $0x148, %edx            # imm = 0x148
callq 0x4210
leaq 0x1562(%rip), %rdi      # 0x10004
leaq 0x2e9c(%rip), %rsi      # 0x11945
leaq 0x3476(%rip), %rcx      # 0x11f26
movl $0x13e, %edx            # imm = 0x13E
callq 0x4210