// File: /workspace/github_cpp_makefile_star2_O3/readmapping[P]alfalfa/src/performanceUtils.cpp
// Function: calculatedDPScore(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&, std::vector<long, std::allocator<long>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
int calculatedDPScore(const string& S, vector<string> & refdescr, vector<long> & startpos, const string& queryLine){
    //read boundaries and sequence from SAM line
    int tabPos = 0;
    char delimeter = '\t';
    //qname
    nextField(queryLine, delimeter, tabPos);
    //flag
    nextField(queryLine, delimeter, tabPos);
    //rname
    string rname = nextField(queryLine, delimeter, tabPos);
    long chromStart = 0;
    size_t index = 0;
    while(index < refdescr.size() && refdescr[index].compare(rname)!=0)
        index++;
    if(index < refdescr.size()){
        chromStart = startpos[index];
    }
    else{
        cerr << "query found in sequence " << rname << ". But this sequence is not found in reference string" << endl;
        cerr << queryLine << endl;
        cerr << "length of line: " << queryLine.length() << endl;
        exit(1);
    }
    //pos
    long refStart = atoi(nextField(queryLine, delimeter, tabPos).c_str()) -1;//-1 because SAM is 1-based
    refStart += chromStart;
    //mapq
    nextField(queryLine, delimeter, tabPos).c_str();
    //skip CIGAR
    string cigar = nextField(queryLine, delimeter, tabPos);
    //rnext
    nextField(queryLine, delimeter, tabPos);
    //pnext
    nextField(queryLine, delimeter, tabPos);
    //tlen
    nextField(queryLine, delimeter, tabPos);
    //seq
    string P = nextField(queryLine, delimeter, tabPos);
    for(size_t i = 0; i < P.length(); i++){
        P[i] = std::tolower(P[i]);
    }
    int cigarPos = 0;
    long refEnd = refStart;
    long qStart = 0;
    int editDist = 0;
    while(cigarPos < (int)cigar.length()){
        int beginPos = cigarPos;
        while(cigar[cigarPos] >= 48 && cigar[cigarPos] <= 57)//integer
                cigarPos++;
        //now cigar[cigarPos] is character
        long partsize = atoi(cigar.substr(beginPos,cigarPos-beginPos).c_str());
        if(cigar[cigarPos] == 'D' || cigar[cigarPos] == 'X' || cigar[cigarPos] == 'I'){
            editDist += partsize;
            qStart += partsize;
            refEnd += partsize;
        }
        else if(cigar[cigarPos] == 'S' || cigar[cigarPos] == 'H'){
            qStart += partsize;
        }
        else if(cigar[cigarPos] == 'M'){
            
            for(int i= 0; i < partsize; i++){
                if(P[qStart+i]!=S[refEnd+i])
                    editDist++;
            }
            qStart += partsize;
            refEnd += partsize;
        }
        cigarPos++;
    }
    return editDist;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rcx, %r14
movq %rdx, 0x8(%rsp)
movq %rsi, %r12
movq %rdi, 0x50(%rsp)
movq %rcx, %rdi
movl $0x9, %esi
xorl %edx, %edx
callq 0x7410
movslq %eax, %r13
leaq 0x118(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %r13, %rcx
callq 0x7310
incl %r13d
movq (%rbp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0x35053
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x72f0
movslq %r13d, %rbp
movq %r14, %rdi
movl $0x9, %esi
movq %rbp, %rdx
callq 0x7410
movq %rax, %r13
subl %ebp, %eax
movslq %eax, %rcx
leaq 0xf8(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x7310
incl %r13d
movq (%rbx), %rdi
leaq 0x108(%rsp), %rax
cmpq %rax, %rdi
je 0x350a7
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x72f0
movslq %r13d, %rbx
movq %r14, %rdi
movl $0x9, %esi
movq %rbx, %rdx
callq 0x7410
movq %rax, %r13
subl %ebx, %eax
movslq %eax, %rcx
leaq 0x58(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x7310
movq (%r12), %rax
movq 0x8(%r12), %rdi
cmpq %rax, %rdi
je 0x3511d
xorl %r15d, %r15d
leaq 0x58(%rsp), %rbp
movq %rax, %rdi
xorl %ebx, %ebx
addq %r15, %rdi
movq %rbp, %rsi
callq 0x7050
movq (%r12), %rdi
movq 0x8(%r12), %rcx
testl %eax, %eax
je 0x35122
incq %rbx
movq %rcx, %rax
subq %rdi, %rax
sarq $0x5, %rax
addq $0x20, %r15
cmpq %rax, %rbx
jb 0x350ed
jmp 0x35122
xorl %ebx, %ebx
movq %rdi, %rcx
subq %rdi, %rcx
sarq $0x5, %rcx
cmpq %rcx, %rbx
jae 0x354cc
incl %r13d
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq (%rax,%rbx,8), %rax
movq %rax, 0x8(%rsp)
movslq %r13d, %rbx
movq %r14, %rdi
movl $0x9, %esi
movq %rbx, %rdx
callq 0x7410
movq %rax, %r15
subl %ebx, %eax
movslq %eax, %rcx
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x7310
incl %r15d
leaq 0x20(%rsp), %rbx
movq -0x10(%rbx), %r12
movq %r12, %rdi
callq 0x7520
movl %eax, %ebp
cmpq %rbx, %r12
je 0x3519c
movq 0x20(%rsp), %rsi
incq %rsi
movq %r12, %rdi
callq 0x72f0
movslq %r15d, %rbx
movq %r14, %rdi
movl $0x9, %esi
movq %rbx, %rdx
callq 0x7410
movq %rax, %r15
subl %ebx, %eax
movslq %eax, %rcx
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x7310
incl %r15d
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x351e6
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x72f0
movslq %r15d, %rbx
movq %r14, %rdi
movl $0x9, %esi
movq %rbx, %rdx
callq 0x7410
movq %rax, %r15
subl %ebx, %eax
movslq %eax, %rcx
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x7310
incl %r15d
movslq %r15d, %rbx
movq %r14, %rdi
movl $0x9, %esi
movq %rbx, %rdx
callq 0x7410
movq %rax, %r15
subl %ebx, %eax
movslq %eax, %rcx
leaq 0xd8(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x7310
incl %r15d
leaq 0xe8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x35266
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x72f0
movslq %r15d, %rbx
movq %r14, %rdi
movl $0x9, %esi
movq %rbx, %rdx
callq 0x7410
movq %rax, %r15
subl %ebx, %eax
movslq %eax, %rcx
leaq 0xb8(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x7310
incl %r15d
leaq 0xc8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x352b8
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x72f0
movslq %r15d, %rbx
movq %r14, %rdi
movl $0x9, %esi
movq %rbx, %rdx
callq 0x7410
movq %rax, %r15
subl %ebx, %eax
movslq %eax, %rcx
leaq 0x98(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x7310
incl %r15d
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3530a
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x72f0
movslq %r15d, %rbx
movq %r14, %rdi
movl $0x9, %esi
movq %rbx, %rdx
callq 0x7410
subl %ebx, %eax
movslq %eax, %rcx
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x7310
cmpq $0x0, 0x38(%rsp)
je 0x35359
xorl %ebx, %ebx
movq 0x30(%rsp), %r14
movsbl (%r14,%rbx), %edi
callq 0x7480
movb %al, (%r14,%rbx)
incq %rbx
cmpq 0x38(%rsp), %rbx
jb 0x3533c
cmpl $0x0, 0x18(%rsp)
jle 0x35462
decl %ebp
movslq %ebp, %rax
addq %rax, 0x8(%rsp)
xorl %r14d, %r14d
leaq 0x10(%rsp), %rax
movq (%rax), %rax
leaq 0x10628(%rip), %rbx     # 0x459a8
xorl %r12d, %r12d
xorl %r15d, %r15d
movslq %r15d, %rdx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq %rdx, %r15
movb (%rax,%r15), %sil
addb $-0x30, %sil
incq %r15
incl %ecx
cmpb $0xa, %sil
jb 0x35391
movslq %ecx, %rcx
leaq 0x78(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x7310
movq 0x78(%rsp), %r13
movq %r13, %rdi
callq 0x7520
movl %eax, %ebp
leaq 0x88(%rsp), %rax
cmpq %rax, %r13
je 0x353e5
movq 0x88(%rsp), %rsi
incq %rsi
movq %r13, %rdi
callq 0x72f0
movslq %ebp, %rcx
movq 0x10(%rsp), %rax
movzbl -0x1(%rax,%r15), %edx
leal -0x44(%rdx), %esi
cmpl $0x9, %esi
ja 0x3543b
movslq (%rbx,%rsi,4), %rdx
addq %rbx, %rdx
jmpq *%rdx
testl %ebp, %ebp
jle 0x35448
movq 0x30(%rsp), %rdx
addq %r12, %rdx
movq 0x50(%rsp), %rsi
movq (%rsi), %rsi
addq 0x8(%rsp), %rsi
xorl %edi, %edi
movb (%rdx,%rdi), %r8b
xorl %r9d, %r9d
cmpb (%rsi,%rdi), %r8b
setne %r9b
addl %r9d, %r14d
incq %rdi
cmpq %rdi, %rcx
jne 0x3541f
jmp 0x35448
cmpl $0x53, %edx
je 0x35452
cmpl $0x58, %edx
jne 0x35455
addl %ebp, %r14d
addq %rcx, %r12
addq %rcx, 0x8(%rsp)
jmp 0x35455
addq %rcx, %r12
cmpl 0x18(%rsp), %r15d
jl 0x35386
jmp 0x35465
xorl %r14d, %r14d
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x35480
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x72f0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x3549c
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x72f0
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x354b7
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x72f0
movl %r14d, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1eb15(%rip), %rdi     # 0x53fe8
leaq 0x10811(%rip), %rsi     # 0x45ceb
movl $0x18, %edx
callq 0x7340
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq 0x1eaf3(%rip), %rdi     # 0x53fe8
callq 0x7340
movq %rax, %rbx
leaq 0x10800(%rip), %rsi     # 0x45d04
movl $0x34, %edx
movq %rax, %rdi
callq 0x7340
movq %rbx, %rdi
callq 0x7150
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x1eac1(%rip), %rdi     # 0x53fe8
callq 0x7340
movq %rax, %rdi
callq 0x7150
movq 0x1eaad(%rip), %rdi     # 0x53fe8
leaq 0x107f7(%rip), %rsi     # 0x45d39
movl $0x10, %edx
callq 0x7340
movq 0x8(%r14), %rsi
movq 0x1ea91(%rip), %rdi     # 0x53fe8
callq 0x71c0
movq %rax, %rdi
callq 0x7150
movl $0x1, %edi
callq 0x73b0
jmp 0x3557d
jmp 0x35578
jmp 0x3557d
jmp 0x3557d
jmp 0x3557d
movq %rax, %rbx
jmp 0x355a0
movq %rax, %rbx
jmp 0x355bc
movq %rax, %rbx
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x355a0
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x72f0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x355bc
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x72f0
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x355d7
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x72f0
movq %rbx, %rdi
callq 0x7600