// File: /workspace/github_cpp_makefile_star2_O3/mmoanis[P]mpegts_demux/MpegTsDemux.cpp
// Function: MpegTsDemuxer::RegisterProgram(unsigned short, unsigned short)
void MpegTsDemuxer::RegisterProgram(PID id, PID pid)
{
    assert(id != MPEGTS_PID_NULL);

    Programs::iterator p = m_programs.find(id);
    if (p == m_programs.end()) {
        cout << "[INFO]: PKT#" << m_pnum << " PROGRAM=" << id << " PMT=" << pid << endl;

        Program P;
        P.id = id;
        P.pid = pid;
        m_programs.insert(make_pair(id, P));

        // expect packet for PMT
        m_filters.insert( make_pair(pid, DEMUXER_EVENT_PMT) );
    } else {
        if (p->second.pid != pid) {
            // Support updating program information
            cout << "[WARNING]: PKT#" << m_pnum << " PROGRAM=" << id << " PMT=" << p->second.pid << " appeared with PMT=" << pid <<  endl;
            p->second.pid = pid;

            // expect packet for PMT
            m_filters.insert( make_pair(pid, DEMUXER_EVENT_PMT) );
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
cmpl $0x1fff, %esi           # imm = 0x1FFF
je 0x3e7e
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %rbx
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x3cab
leaq 0x8(%rbx), %rcx
movq %rcx, %r12
xorl %edx, %edx
cmpw %r14w, 0x20(%rax)
setb %dl
cmovaeq %rax, %r12
movq 0x10(%rax,%rdx,8), %rax
testq %rax, %rax
jne 0x3c82
cmpq %rcx, %r12
je 0x3cab
cmpw %r14w, 0x20(%r12)
jbe 0x3d98
movq 0x431e(%rip), %r15      # 0x7fd0
leaq 0x1906(%rip), %rsi      # 0x55bf
movl $0xc, %edx
movq %r15, %rdi
callq 0x2160
movq 0x90(%rbx), %rsi
movq %r15, %rdi
callq 0x20b0
movq %rax, %r15
leaq 0x17a8(%rip), %rsi      # 0x5487
movl $0x9, %edx
movq %rax, %rdi
callq 0x2160
movzwl %r14w, %r14d
movq %r15, %rdi
movq %r14, %rsi
callq 0x20b0
movq %rax, %r12
leaq 0x18d5(%rip), %rsi      # 0x55da
movl $0x5, %edx
movq %rax, %rdi
callq 0x2160
movzwl %bp, %r15d
movq %r12, %rdi
movq %r15, %rsi
callq 0x20b0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20c0
movl %ebp, %eax
shll $0x10, %eax
orl %r14d, %eax
shlq $0x10, %rax
orq %r14, %rax
leaq 0x8(%rsp), %r14
movw %bp, 0x4(%r14)
movl %eax, (%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4710
addq $0x60, %rbx
btsq $0x20, %r15
movq %r15, (%r14)
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x4854
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
cmpw %bp, 0x24(%r12)
je 0x3d8b
movq 0x4229(%rip), %r15      # 0x7fd0
leaq 0x15ff(%rip), %rsi      # 0x53ad
movl $0xf, %edx
movq %r15, %rdi
callq 0x2160
movq 0x90(%rbx), %rsi
movq %r15, %rdi
callq 0x20b0
movq %rax, %r15
leaq 0x16b3(%rip), %rsi      # 0x5487
movl $0x9, %edx
movq %rax, %rdi
callq 0x2160
movzwl %r14w, %esi
movq %r15, %rdi
callq 0x20b0
movq %rax, %r14
leaq 0x17e3(%rip), %rsi      # 0x55da
movl $0x5, %edx
movq %rax, %rdi
callq 0x2160
movzwl 0x24(%r12), %esi
movq %r14, %rdi
callq 0x20b0
movq %rax, %r15
leaq 0x17b0(%rip), %rsi      # 0x55cc
movl $0x13, %edx
movq %rax, %rdi
callq 0x2160
movzwl %bp, %r14d
movq %r15, %rdi
movq %r14, %rsi
callq 0x20b0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20c0
movw %r14w, 0x24(%r12)
addq $0x60, %rbx
btsq $0x20, %r14
leaq 0x8(%rsp), %rsi
movq %r14, (%rsi)
jmp 0x3d83
leaq 0x16f6(%rip), %rdi      # 0x557b
leaq 0x134c(%rip), %rsi      # 0x51d8
leaq 0x16fe(%rip), %rcx      # 0x5591
movl $0x1d1, %edx            # imm = 0x1D1
callq 0x20a0
nop