// File: /workspace/github_cpp_makefile_star2_O1/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 0x45a0
testl %eax, %eax
jne 0xed43
movq %r12, %rdi
movq %rbx, 0x10(%rsp)
movq %rbx, %rsi
callq 0x4550
testl %eax, %eax
jne 0xed62
leaq 0x28(%rsp), %rsi
movq %r12, %rdi
callq 0x45a0
movq $-0x1, 0x8(%rsp)
cmpl $0x1, %eax
jne 0xecd2
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 0xebeb
movq %r13, %rdi
movq 0x20(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x4130
testl %eax, %eax
jne 0xeb9c
incl 0x350(%r15)
cmpl $0x3, 0x350(%r15)
sete 0xc(%r15)
jne 0xebd1
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4310
testl %eax, %eax
jne 0xed24
movq %rbx, %rdi
movq %r14, %rsi
callq 0x44d0
testl %eax, %eax
jne 0xed05
movq %r12, %rdi
leaq 0x28(%rsp), %rsi
callq 0x45a0
cmpl $0x1, %eax
movq %r14, %rdi
je 0xeb78
jmp 0xecd2
cmpq $-0x1, 0x8(%rsp)
jne 0xed81
movq %rdi, 0x8(%rsp)
leaq 0x28(%rsp), %rsi
callq 0x41e0
testl %eax, %eax
jne 0xec1f
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0x42b0
testl %eax, %eax
jne 0xedbf
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4420
testl %eax, %eax
jle 0xec42
addl %eax, %ebp
movq %rbx, %rdi
movl %eax, %esi
callq 0x4560
testl %eax, %eax
je 0xec1f
jmp 0xece6
movq 0x48(%rsp), %rax
cmpq $-0x1, %rax
je 0xecc4
movq 0x10(%rsp), %rdi
movq %rax, 0x8(%rsp)
callq 0x4620
cmpq %rax, 0x8(%rsp)
jne 0xeda0
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 0x4620
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
movq 0x208(%r15), %rcx
cqto
idivq 0x8(%rcx)
movq 0x18(%rsp), %rcx
movq %rax, (%rcx)
jmp 0xebd1
movq $-0x1, 0x8(%rsp)
jmp 0xebd1
movq 0x8(%rsp), %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1317(%rip), %rdi      # 0x10004
leaq 0x2c4e(%rip), %rsi      # 0x11942
leaq 0x3228(%rip), %rcx      # 0x11f23
movl $0x143, %edx            # imm = 0x143
callq 0x4210
leaq 0x12f8(%rip), %rdi      # 0x10004
leaq 0x2c2f(%rip), %rsi      # 0x11942
leaq 0x3209(%rip), %rcx      # 0x11f23
movl $0x132, %edx            # imm = 0x132
callq 0x4210
leaq 0x12d9(%rip), %rdi      # 0x10004
leaq 0x2c10(%rip), %rsi      # 0x11942
leaq 0x31ea(%rip), %rcx      # 0x11f23
movl $0x130, %edx            # imm = 0x130
callq 0x4210
leaq 0x31ab(%rip), %rdi      # 0x11ef5
leaq 0x2bf1(%rip), %rsi      # 0x11942
leaq 0x31cb(%rip), %rcx      # 0x11f23
movl $0x120, %edx            # imm = 0x120
callq 0x4210
leaq 0x129b(%rip), %rdi      # 0x10004
leaq 0x2bd2(%rip), %rsi      # 0x11942
leaq 0x31ac(%rip), %rcx      # 0x11f23
movl $0x122, %edx            # imm = 0x122
callq 0x4210
leaq 0x19ea(%rip), %rdi      # 0x10772
leaq 0x2bb3(%rip), %rsi      # 0x11942
leaq 0x318d(%rip), %rcx      # 0x11f23
movl $0x138, %edx            # imm = 0x138
callq 0x4210
leaq 0x2fd3(%rip), %rdi      # 0x11d7a
leaq 0x2b94(%rip), %rsi      # 0x11942
leaq 0x316e(%rip), %rcx      # 0x11f23
movl $0x148, %edx            # imm = 0x148
callq 0x4210
leaq 0x123e(%rip), %rdi      # 0x10004
leaq 0x2b75(%rip), %rsi      # 0x11942
leaq 0x314f(%rip), %rcx      # 0x11f23
movl $0x13e, %edx            # imm = 0x13E
callq 0x4210