// File: schneebergerlab[P]DrLink/analyze_molecule.cpp
// Function: decipher_cigar(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
int decipher_cigar(string cigar)
{
    // CIGAR alphabet: M I D N S H P; * = X: 23S23M1D8M1I16M1D29M
    char *cstr = (char*)cigar.c_str();
    string numstr("");
    int covlen = 0;
    for (int i=0; i<cigar.size(); i++)
    {
        if(cstr[i]>='0' && cstr[i]<='9')
        {
            numstr += cstr[i];
        }
        else
        if(cstr[i] == 'M' || cstr[i] == 'I'|| cstr[i] == 'D'|| cstr[i] == 'N'|| 
           cstr[i] == 'S' || cstr[i] == 'H'|| cstr[i] == 'P')
        {
            if(cstr[i] == 'M' || cstr[i] == 'D')
            {
                covlen += atoi(numstr.c_str());
            }
            numstr.clear();
        }
    }    
    return covlen;
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x18(%rsp)
movq %rdi, 0x70(%rsp)
callq 0x51d0
movq %rax, 0x68(%rsp)
leaq 0x47(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x57c0
movq 0x20(%rsp), %rdx
leaq 0x5cbd1(%rip), %rsi     # 0x6ab94
leaq 0x48(%rsp), %rdi
callq 0x6880
jmp 0xdfcf
leaq 0x47(%rsp), %rdi
callq 0x54d0
movl $0x0, 0x30(%rsp)
movl $0x0, 0x2c(%rsp)
movq 0x18(%rsp), %rdi
movslq 0x2c(%rsp), %rax
movq %rax, 0x10(%rsp)
callq 0x5310
movq %rax, %rcx
movq 0x10(%rsp), %rax
cmpq %rcx, %rax
jae 0xe170
movq 0x68(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x30, %eax
jl 0xe08d
movq 0x68(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x39, %eax
jg 0xe08d
movq 0x68(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movsbl (%rax,%rcx), %esi
leaq 0x48(%rsp), %rdi
callq 0x52b0
jmp 0xe04e
jmp 0xe15e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x38(%rsp)
movl %eax, 0x34(%rsp)
leaq 0x47(%rsp), %rdi
callq 0x54d0
jmp 0xe18b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x38(%rsp)
movl %eax, 0x34(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x58b8
jmp 0xe18b
movq 0x68(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x4d, %eax
je 0xe112
movq 0x68(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x49, %eax
je 0xe112
movq 0x68(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x44, %eax
je 0xe112
movq 0x68(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x4e, %eax
je 0xe112
movq 0x68(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x53, %eax
je 0xe112
movq 0x68(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x48, %eax
je 0xe112
movq 0x68(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x50, %eax
jne 0xe15c
movq 0x68(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x4d, %eax
je 0xe138
movq 0x68(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x44, %eax
jne 0xe152
leaq 0x48(%rsp), %rdi
callq 0x51d0
movq %rax, %rdi
callq 0x56a0
addl 0x30(%rsp), %eax
movl %eax, 0x30(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x55b0
jmp 0xe15e
jmp 0xe160
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0xdfe9
movl 0x30(%rsp), %eax
movl %eax, 0xc(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x58b8
movl 0xc(%rsp), %eax
addq $0x78, %rsp
retq
movq 0x38(%rsp), %rdi
callq 0x57b0
nopw %cs:(%rax,%rax)