// File: schneebergerlab[P]DrLink/insert_raw_bp.cpp
// Function: insert_raw_bp(std::multimap<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::multimap<unsigned long, BPINFO, std::less<unsigned long>, std::allocator<std::pair<unsigned long const, BPINFO>>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, std::multimap<unsigned long, BPINFO, std::less<unsigned long>, std::allocator<std::pair<unsigned long const, BPINFO>>>>>>*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned long, unsigned long, double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
bool insert_raw_bp(multimap<string, multimap<unsigned long, BPINFO> >* rawbpmap,
                   string        chr,
                   unsigned long leftp,
                   unsigned long rightp,
                   double        score,
                   string        order,
                   string        bpline)
{
    /*  
      struct BPINFO
      {
          string         chr;
          unsigned long  leftp;
          unsigned long  rightp;
          unsigned long  leftMax;
          unsigned long  rightMin;
          double         score;
          string         order; // allele transition order, either "12" or "21"
          string         bpline;// raw bp info line
          string         ovline;// bp info line overlapping with the above, the smaller interval used as a representative
      };    
    */
    BPINFO tmpbp;
    tmpbp.chr      = chr;
    tmpbp.leftp    = leftp;
    tmpbp.rightp   = rightp;
    tmpbp.leftMax  = 0;
    tmpbp.rightMin = 0;
    tmpbp.bpline   = bpline;
    tmpbp.ovline   = "";
    tmpbp.score    = score;
    tmpbp.order    = order;
    //
    multimap<string, multimap<unsigned long, BPINFO> >::iterator chritr;
    chritr = (*rawbpmap).find(chr);
    if(chritr == (*rawbpmap).end())
    {
        // initialize map with new item of chr
        multimap<unsigned long, BPINFO> tmp;
        tmp.insert(std::pair<unsigned long, BPINFO>(leftp, tmpbp));
        //
        (*rawbpmap).insert(std::pair<string, multimap<unsigned long, BPINFO> >(chr, tmp));   
    } 
    else
    {
        // update map of chr
        ((*chritr).second).insert(std::pair<unsigned long, BPINFO>(leftp, tmpbp));
    }
    
    return true;
}

// Assembly:
subq $0x358, %rsp            # imm = 0x358
movq %rsi, 0x50(%rsp)
movq %r8, 0x38(%rsp)
movq %r9, 0x40(%rsp)
movq %rdi, 0x350(%rsp)
movq %rsi, 0x348(%rsp)
movq %rdx, 0x340(%rsp)
movq %rcx, 0x338(%rsp)
movsd %xmm0, 0x330(%rsp)
movq %r8, 0x328(%rsp)
movq %r9, 0x320(%rsp)
leaq 0x278(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x3e0f0
movq 0x48(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0x5050
jmp 0x612d2
movq 0x40(%rsp), %rsi
movq 0x340(%rsp), %rax
movq %rax, 0x298(%rsp)
movq 0x338(%rsp), %rax
movq %rax, 0x2a0(%rsp)
movq $0x0, 0x2a8(%rsp)
movq $0x0, 0x2b0(%rsp)
leaq 0x2e0(%rsp), %rdi
callq 0x5050
jmp 0x6131e
leaq 0x300(%rsp), %rdi
leaq 0x9867(%rip), %rsi      # 0x6ab94
callq 0x55d0
jmp 0x61334
movq 0x38(%rsp), %rsi
movsd 0x330(%rsp), %xmm0
movsd %xmm0, 0x2b8(%rsp)
leaq 0x2c0(%rsp), %rdi
callq 0x5050
jmp 0x6135a
leaq 0x260(%rsp), %rdi
callq 0x615e0
movq 0x50(%rsp), %rsi
movq 0x350(%rsp), %rdi
callq 0x61600
movq %rax, 0x30(%rsp)
jmp 0x61380
movq 0x30(%rsp), %rax
movq %rax, 0x258(%rsp)
movq 0x258(%rsp), %rax
movq %rax, 0x260(%rsp)
movq 0x350(%rsp), %rdi
callq 0x61650
movq %rax, 0x250(%rsp)
leaq 0x260(%rsp), %rdi
leaq 0x250(%rsp), %rsi
callq 0x61630
testb $0x1, %al
jne 0x613d0
jmp 0x61525
leaq 0x220(%rsp), %rdi
callq 0x61680
leaq 0x170(%rsp), %rdi
leaq 0x340(%rsp), %rsi
leaq 0x278(%rsp), %rdx
callq 0x616c0
jmp 0x613fc
leaq 0x220(%rsp), %rdi
leaq 0x170(%rsp), %rsi
callq 0x61690
movq %rax, 0x28(%rsp)
jmp 0x61418
movq 0x28(%rsp), %rax
movq %rax, 0x168(%rsp)
leaq 0x170(%rsp), %rdi
callq 0x61700
movq 0x50(%rsp), %rsi
movq 0x350(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x118(%rsp), %rdi
leaq 0x220(%rsp), %rdx
callq 0x61750
jmp 0x6145b
movq 0x20(%rsp), %rdi
leaq 0x118(%rsp), %rsi
callq 0x61720
movq %rax, 0x18(%rsp)
jmp 0x61474
movq 0x18(%rsp), %rax
movq %rax, 0x110(%rsp)
leaq 0x118(%rsp), %rdi
callq 0x617c0
leaq 0x220(%rsp), %rdi
callq 0x31e50
jmp 0x615a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x270(%rsp)
movl %eax, 0x26c(%rsp)
jmp 0x615bc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x270(%rsp)
movl %eax, 0x26c(%rsp)
jmp 0x61513
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x270(%rsp)
movl %eax, 0x26c(%rsp)
leaq 0x170(%rsp), %rdi
callq 0x61700
jmp 0x61513
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x270(%rsp)
movl %eax, 0x26c(%rsp)
leaq 0x118(%rsp), %rdi
callq 0x617c0
leaq 0x220(%rsp), %rdi
callq 0x31e50
jmp 0x615bc
leaq 0x260(%rsp), %rdi
callq 0x617f0
addq $0x20, %rax
movq %rax, 0x10(%rsp)
leaq 0x60(%rsp), %rdi
leaq 0x340(%rsp), %rsi
leaq 0x278(%rsp), %rdx
callq 0x616c0
jmp 0x61557
movq 0x10(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x61690
movq %rax, 0x8(%rsp)
jmp 0x6156d
movq 0x8(%rsp), %rax
movq %rax, 0x58(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x61700
jmp 0x615a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x270(%rsp)
movl %eax, 0x26c(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x61700
jmp 0x615bc
leaq 0x278(%rsp), %rdi
callq 0x31c80
movb $0x1, %al
andb $0x1, %al
addq $0x358, %rsp            # imm = 0x358
retq
leaq 0x278(%rsp), %rdi
callq 0x31c80
movq 0x270(%rsp), %rdi
callq 0x57b0
nopw %cs:(%rax,%rax)