// File: /workspace/github_cpp_makefile_star2_O2/mmoanis[P]mpegts_demux/MpegTsDemux.cpp
// Function: MpegTsDemuxer::RegisterStream(unsigned short, Program const&, bool)
bool MpegTsDemuxer::RegisterStream(PID id, const Program& prog, bool video)
{
    Streams::iterator s = m_streams.find(id);
    if (s == m_streams.end()) {
        string filename = GetFileName(video, id, prog.id);
        Stream *S = new Stream(filename.c_str(), id, prog.id);
        m_streams.insert( make_pair(id, S) );
        if (m_info)
            cout << "[INFO]: PKT#" << m_pnum << " STREAM=" << id << " PROGRAM=" << prog.id << " TYPE=" << (video? "VIDEO" : "AUDIO") << endl;
        else
            cout << "[INFO]: PKT#" << m_pnum << " STREAM=" << id << " TYPE=" << (video? "VIDEO" : "AUDIO") << endl;
        // expect packet for stream
        m_filters.insert( make_pair(id, DEMUXER_EVENT_PES) );
    }  else {
        if ((*s).second->GetPId() != prog.id && prog.id != MPEGTS_PID_NULL) {
            // Support updating stream information.
            cout << "[WARNING]: PKT#" << m_pnum << " STREAM=" << id << " PROGRAM=" << (*s).second->GetPId() << " appeared in PROGRAM=" << prog.id << endl;
            (*s).second->SetPId(prog.id);
        }
    }
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movl %ecx, %r15d
movq %rdx, %r14
movq %rdi, %rbx
leaq 0xa(%rsp), %rax
movw %si, (%rax)
leaq 0x30(%rdi), %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0x3ec2
movq %rax, %r13
leaq 0x38(%rbx), %rax
cmpq %rax, %r13
je 0x39c5
movq 0x28(%r13), %rax
movzwl (%r14), %ecx
cmpw %cx, 0xa(%rax)
sete %al
cmpw $0x1fff, %cx            # imm = 0x1FFF
sete %cl
orb %al, %cl
jne 0x3b65
movq 0x4695(%rip), %rdi      # 0x7fd0
leaq 0x1a6b(%rip), %rsi      # 0x53ad
callq 0x2110
movq 0x90(%rbx), %rsi
movq %rax, %rdi
callq 0x20a0
leaq 0x18bd(%rip), %rsi      # 0x521a
movq %rax, %rdi
callq 0x2110
movzwl 0xa(%rsp), %esi
movq %rax, %rdi
callq 0x21d0
leaq 0x1b0e(%rip), %rsi      # 0x5487
movq %rax, %rdi
callq 0x2110
movq 0x28(%r13), %rcx
movzwl 0xa(%rcx), %esi
movq %rax, %rdi
callq 0x21d0
leaq 0x1ca5(%rip), %rsi      # 0x563d
movq %rax, %rdi
callq 0x2110
movzwl (%r14), %esi
movq %rax, %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x2080
movq 0x28(%r13), %rax
movzwl (%r14), %ecx
movw %cx, 0xa(%rax)
jmp 0x3b65
movzwl 0xa(%rsp), %ebp
leaq 0x30(%rsp), %rdi
callq 0x20c0
leaq 0x40(%rsp), %r13
leaq 0x1c73(%rip), %rax      # 0x5653
leaq 0x1c72(%rip), %rsi      # 0x5659
movl %r15d, 0xc(%rsp)
testb %r15b, %r15b
cmovneq %rax, %rsi
movq %r13, %rdi
callq 0x2110
leaq 0x1c5d(%rip), %rsi      # 0x565f
movq %rax, %rdi
callq 0x2110
movzwl %bp, %esi
movq %r13, %rdi
callq 0x21d0
leaq 0x48(%rsp), %rsi
leaq 0x10(%rsp), %rdi
callq 0x21b0
leaq 0x30(%rsp), %rdi
callq 0x20d0
pushq $0x10
popq %rdi
callq 0x2130
movl 0xc(%rsp), %ebp
leaq 0xa(%rsp), %r15
movq %rax, %r13
movq 0x10(%rsp), %rsi
movzwl 0xa(%rsp), %edx
movzwl (%r14), %ecx
movq %rax, %rdi
callq 0x2694
movzwl 0xa(%rsp), %eax
leaq 0x30(%rsp), %rsi
movw %ax, (%rsi)
movq %r13, 0x8(%rsi)
movq %r12, %rdi
callq 0x4130
cmpb $0x1, 0x98(%rbx)
jne 0x3ac9
movq 0x454f(%rip), %rdi      # 0x7fd0
leaq 0x1b37(%rip), %rsi      # 0x55bf
callq 0x2110
movq 0x90(%rbx), %rsi
movq %rax, %rdi
callq 0x20a0
leaq 0x1777(%rip), %rsi      # 0x521a
movq %rax, %rdi
callq 0x2110
movzwl 0xa(%rsp), %esi
movq %rax, %rdi
callq 0x21d0
leaq 0x19c8(%rip), %rsi      # 0x5487
movq %rax, %rdi
callq 0x2110
jmp 0x3afd
movq 0x4500(%rip), %rdi      # 0x7fd0
leaq 0x1ae8(%rip), %rsi      # 0x55bf
callq 0x2110
movq 0x90(%rbx), %rsi
movq %rax, %rdi
callq 0x20a0
leaq 0x1728(%rip), %rsi      # 0x521a
movq %rax, %rdi
callq 0x2110
movq %r15, %r14
movzwl (%r14), %esi
movq %rax, %rdi
callq 0x21d0
leaq 0x1b1a(%rip), %rsi      # 0x562a
movq %rax, %rdi
callq 0x2110
leaq 0x1b12(%rip), %rcx      # 0x5631
leaq 0x1b11(%rip), %rsi      # 0x5637
testb %bpl, %bpl
cmovneq %rcx, %rsi
movq %rax, %rdi
callq 0x2110
movq %rax, %rdi
callq 0x2080
movzwl 0xa(%rsp), %eax
btsq $0x21, %rax
addq $0x60, %rbx
leaq 0x30(%rsp), %rsi
movq %rax, (%rsi)
movq %rbx, %rdi
callq 0x409c
leaq 0x10(%rsp), %rdi
callq 0x2070
movb $0x1, %al
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3b99
jmp 0x3b99
movq %rax, %rbx
movq %r13, %rdi
callq 0x2100
jmp 0x3b9c
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x20d0
jmp 0x3ba6
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x2070
movq %rbx, %rdi
callq 0x21f0