// File: zeeev[P]DASVC/bamtools/src/api/internal/sam/SamHeaderValidator_p.cpp
// Function: BamTools::Internal::SamHeaderValidator::ContainsUniqueIDsAndPlatformUnits()
bool SamHeaderValidator::ContainsUniqueIDsAndPlatformUnits(void) {

    bool isValid = true;
    set<string> readGroupIds;
    set<string> platformUnits;
    set<string>::iterator idIter;
    set<string>::iterator puIter;

    // iterate over sequences
    const SamReadGroupDictionary& readGroups = m_header.ReadGroups;
    SamReadGroupConstIterator rgIter = readGroups.ConstBegin();
    SamReadGroupConstIterator rgEnd  = readGroups.ConstEnd();
    for ( ; rgIter != rgEnd; ++rgIter ) {
        const SamReadGroup& rg = (*rgIter);

        // --------------------------------
        // check for unique ID

        // lookup read group ID
        const string& id = rg.ID;
        idIter = readGroupIds.find(id);

        // error if found (duplicate entry)
        if ( idIter != readGroupIds.end() ) {
            AddError("Read group ID (ID): " + id + " is not unique");
            isValid = false;
        }

        // otherwise ok, store id
        readGroupIds.insert(id);

        // --------------------------------
        // check for unique platform unit

        // lookup platform unit
        const string& pu = rg.PlatformUnit;
        puIter = platformUnits.find(pu);

        // error if found (duplicate entry)
        if ( puIter != platformUnits.end() ) {
            AddError("Platform unit (PU): " + pu + " is not unique");
            isValid = false;
        }

        // otherwise ok, store platform unit
        platformUnits.insert(pu);
    }

    // return validation state
    return isValid;
}

// Assembly:
subq $0x1f8, %rsp            # imm = 0x1F8
movq %rdi, 0x1f0(%rsp)
movq 0x1f0(%rsp), %rax
movq %rax, 0x70(%rsp)
movb $0x1, 0x1ef(%rsp)
leaq 0x1b8(%rsp), %rdi
callq 0x75d80
leaq 0x188(%rsp), %rdi
callq 0x75d80
jmp 0xe7620
leaq 0x170(%rsp), %rdi
callq 0x74ef0
jmp 0xe762f
leaq 0x168(%rsp), %rdi
callq 0x74ef0
jmp 0xe763e
movq 0x70(%rsp), %rax
movq (%rax), %rax
addq $0xc0, %rax
movq %rax, 0x160(%rsp)
movq 0x160(%rsp), %rdi
callq 0x7ab20
movq %rax, 0x68(%rsp)
jmp 0xe7668
movq 0x68(%rsp), %rax
movq %rax, 0x158(%rsp)
movq 0x160(%rsp), %rdi
callq 0x7b990
movq %rax, 0x60(%rsp)
jmp 0xe7689
movq 0x60(%rsp), %rax
movq %rax, 0x150(%rsp)
leaq 0x158(%rsp), %rdi
leaq 0x150(%rsp), %rsi
callq 0x736e0
movb %al, 0x5f(%rsp)
jmp 0xe76b1
movb 0x5f(%rsp), %al
testb $0x1, %al
jne 0xe76be
jmp 0xe7a4e
leaq 0x158(%rsp), %rdi
callq 0x737d0
movq %rax, 0x50(%rsp)
jmp 0xe76d2
movq 0x50(%rsp), %rax
movq %rax, 0x148(%rsp)
movq 0x148(%rsp), %rax
addq $0x40, %rax
movq %rax, 0x140(%rsp)
movq 0x140(%rsp), %rsi
leaq 0x1b8(%rsp), %rdi
callq 0x78740
movq %rax, 0x48(%rsp)
jmp 0xe770f
movq 0x48(%rsp), %rax
movq %rax, 0x138(%rsp)
movq 0x138(%rsp), %rax
movq %rax, 0x170(%rsp)
leaq 0x1b8(%rsp), %rdi
callq 0x714b0
movq %rax, 0x40(%rsp)
jmp 0xe7740
movq 0x40(%rsp), %rax
movq %rax, 0x130(%rsp)
leaq 0x170(%rsp), %rdi
leaq 0x130(%rsp), %rsi
callq 0x713b0
movb %al, 0x3f(%rsp)
jmp 0xe7768
movb 0x3f(%rsp), %al
testb $0x1, %al
jne 0xe7775
jmp 0xe7871
movq 0x140(%rsp), %rdx
leaq 0x513e(%rip), %rsi      # 0xec8c2
leaq 0xf0(%rsp), %rdi
callq 0x75e70
jmp 0xe7793
leaq 0x5089(%rip), %rdx      # 0xec823
leaq 0x110(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x785a0
jmp 0xe77b1
movq 0x70(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x763a0
jmp 0xe77c5
leaq 0x110(%rsp), %rdi
callq 0x7cce8
jmp 0xe77d4
leaq 0xf0(%rsp), %rdi
callq 0x7cce8
jmp 0xe77e3
movb $0x0, 0x1ef(%rsp)
jmp 0xe7871
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x180(%rsp)
movl %eax, 0x17c(%rsp)
jmp 0xe7a94
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x180(%rsp)
movl %eax, 0x17c(%rsp)
jmp 0xe7a83
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x180(%rsp)
movl %eax, 0x17c(%rsp)
jmp 0xe785d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x180(%rsp)
movl %eax, 0x17c(%rsp)
leaq 0x110(%rsp), %rdi
callq 0x7cce8
jmp 0xe785b
jmp 0xe785d
leaq 0xf0(%rsp), %rdi
callq 0x7cce8
jmp 0xe786c
jmp 0xe7a83
movq 0x140(%rsp), %rsi
leaq 0x1b8(%rsp), %rdi
callq 0x76af0
movb %dl, 0x2f(%rsp)
movq %rax, 0x30(%rsp)
jmp 0xe7891
movb 0x2f(%rsp), %al
movq 0x30(%rsp), %rcx
movq %rcx, 0xe0(%rsp)
movb %al, 0xe8(%rsp)
movq 0x148(%rsp), %rax
addq $0xa0, %rax
movq %rax, 0xd8(%rsp)
movq 0xd8(%rsp), %rsi
leaq 0x188(%rsp), %rdi
callq 0x78740
movq %rax, 0x20(%rsp)
jmp 0xe78db
movq 0x20(%rsp), %rax
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x168(%rsp)
leaq 0x188(%rsp), %rdi
callq 0x714b0
movq %rax, 0x18(%rsp)
jmp 0xe790c
movq 0x18(%rsp), %rax
movq %rax, 0xc8(%rsp)
leaq 0x168(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x713b0
movb %al, 0x17(%rsp)
jmp 0xe7934
movb 0x17(%rsp), %al
testb $0x1, %al
jne 0xe7941
jmp 0xe7a05
movq 0xd8(%rsp), %rdx
leaq 0x4f87(%rip), %rsi      # 0xec8d7
leaq 0x88(%rsp), %rdi
callq 0x75e70
jmp 0xe795f
leaq 0x4ebd(%rip), %rdx      # 0xec823
leaq 0xa8(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x785a0
jmp 0xe797d
movq 0x70(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x763a0
jmp 0xe7991
leaq 0xa8(%rsp), %rdi
callq 0x7cce8
jmp 0xe79a0
leaq 0x88(%rsp), %rdi
callq 0x7cce8
jmp 0xe79af
movb $0x0, 0x1ef(%rsp)
jmp 0xe7a05
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x180(%rsp)
movl %eax, 0x17c(%rsp)
jmp 0xe79f4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x180(%rsp)
movl %eax, 0x17c(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x7cce8
jmp 0xe79f2
jmp 0xe79f4
leaq 0x88(%rsp), %rdi
callq 0x7cce8
jmp 0xe7a03
jmp 0xe7a83
movq 0xd8(%rsp), %rsi
leaq 0x188(%rsp), %rdi
callq 0x76af0
movb %dl, 0x7(%rsp)
movq %rax, 0x8(%rsp)
jmp 0xe7a25
movb 0x7(%rsp), %al
movq 0x8(%rsp), %rcx
movq %rcx, 0x78(%rsp)
movb %al, 0x80(%rsp)
leaq 0x158(%rsp), %rdi
callq 0x7aa70
jmp 0xe7a49
jmp 0xe7696
movb 0x1ef(%rsp), %al
movb %al, 0x6(%rsp)
leaq 0x188(%rsp), %rdi
callq 0x724c0
jmp 0xe7a68
leaq 0x1b8(%rsp), %rdi
callq 0x724c0
movb 0x6(%rsp), %al
andb $0x1, %al
addq $0x1f8, %rsp            # imm = 0x1F8
retq
leaq 0x188(%rsp), %rdi
callq 0x724c0
jmp 0xe7a92
jmp 0xe7a94
leaq 0x1b8(%rsp), %rdi
callq 0x724c0
jmp 0xe7aa3
jmp 0xe7aa5
movq 0x180(%rsp), %rdi
callq 0x7b550
movq %rax, %rdi
callq 0x88ef0
nopw (%rax,%rax)