// File: /workspace/github_cpp_makefile_star2_O1/mmoanis[P]mpegts_demux/MpegTsDemux.cpp
// Function: MpegTsDemuxer::DecodePacket(Packet const&)
bool MpegTsDemuxer::DecodePacket(const Packet& packet)
{
    ++m_pnum;

    Packet::const_iterator p = packet.begin(), e = packet.end();
    PacketHeader header;
    if (!ReadHeader(p, e, header))
        return false;

    PID &id = header.id;
    //cout << "DecodePacket: PID=" << id << endl;

    // Lookup this ID in our filters
    Filters::iterator f = m_filters.find(id);
    if (f != m_filters.end()) {
        DemuxerEvents E = (*f).second;
        switch (E) {
        case DEMUXER_EVENT_NIL:
            // NULL PACKET
            //cout << "[INFO]: PKT#" << m_pnum << " Null packet." << endl;
            return true;
        case DEMUXER_EVENT_PAT:
            if (!ReadPAT(p, e))
                return false;
            break;
        case DEMUXER_EVENT_PMT:
            if (!ReadPMT(p, e))
                return false;
            break;
        case DEMUXER_EVENT_PES:
            if (!ReadPES(p, e, header, id))
                return false;
            break;
        default:
            cout << "[WARNING]: PID=" << id << " filtered but not handled." << endl;
            break;
        }
    } else {
        // Check if orphaned PES with no program.
        if (CheckPES(p, e, header)) {
            if (!ReadPES(p, e, header, id))
                return false;
        }
    }
    return true;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
incq 0x90(%rdi)
movq %rsi, %rbx
movq %rsp, %rsi
movq %rbx, (%rsi)
leaq 0xe(%rsp), %rcx
callq 0x2d4a
testb %al, %al
je 0x2c8f
movq 0x70(%r14), %rdx
leaq 0x68(%r14), %rax
movq %rax, %rcx
testq %rdx, %rdx
je 0x2bee
movzwl 0x12(%rsp), %esi
movq %rax, %rcx
xorl %edi, %edi
cmpw %si, 0x20(%rdx)
setb %dil
cmovaeq %rdx, %rcx
movq 0x10(%rdx,%rdi,8), %rdx
testq %rdx, %rdx
jne 0x2bd6
movq %rax, %rdx
cmpq %rax, %rcx
je 0x2c06
movzwl 0x12(%rsp), %edx
cmpw 0x20(%rcx), %dx
cmovbq %rax, %rcx
movq %rcx, %rdx
addq $0xbc, %rbx
cmpq %rax, %rdx
je 0x2c43
movl 0x24(%rdx), %eax
decl %eax
cmpl $0x3, %eax
ja 0x2cd1
leaq 0x25a5(%rip), %rcx      # 0x51cc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rsp, %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x31ec
jmp 0x2cc7
cmpb $0x1, 0xf(%rsp)
jne 0x2d3d
movq (%rsp), %rax
cmpb $0x0, (%rax)
jne 0x2d3d
cmpb $0x0, 0x1(%rax)
jne 0x2d3d
cmpb $0x1, 0x2(%rax)
jne 0x2d3d
leaq 0xe(%rsp), %rcx
movzwl 0x4(%rcx), %r8d
movq %rsp, %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x3796
testb %al, %al
jne 0x2d3d
xorl %eax, %eax
jmp 0x2d3f
movq %rsp, %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x2e6a
jmp 0x2cc7
movb $0x1, %al
xorl %ecx, %ecx
jmp 0x2d39
leaq 0xe(%rsp), %rcx
movzwl 0x4(%rcx), %r8d
movq %rsp, %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x3796
testb %al, %al
jne 0x2d37
xorl %ecx, %ecx
xorl %eax, %eax
jmp 0x2d39
movq 0x52f8(%rip), %rbx      # 0x7fd0
leaq 0x256c(%rip), %rsi      # 0x524b
movl $0xf, %edx
movq %rbx, %rdi
callq 0x2170
movzwl 0x12(%rsp), %esi
movq %rbx, %rdi
callq 0x20c0
movq %rax, %rbx
leaq 0x2558(%rip), %rsi      # 0x525b
movl $0x1a, %edx
movq %rax, %rdi
callq 0x2170
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20d0
movb $0x1, %cl
testb %cl, %cl
je 0x2d3f
movb $0x1, %al
andb $0x1, %al
addq $0x18, %rsp
popq %rbx
popq %r14
retq
nop