// File: /workspace/github_cpp_makefile_star2_O2/readmapping[P]alfalfa/src/performanceUtils.cpp
// Function: readRecord(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, samRecord_t&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
bool readRecord(string & line, samRecord_t & record, string tag){
    int tabPos = 0;
    char delimeter = '\t';
    //qname
    record.qname = nextField(line, delimeter, tabPos);
    if(record.qname.length() > 2 && record.qname[record.qname.length()-2]=='/')
        record.qname.erase(record.qname.length()-2);
    //flag
    record.flag = bitset<11>((ulong) atoi(nextField(line, delimeter, tabPos).c_str()));
    //rname
    record.rname = nextField(line, delimeter, tabPos);
    //pos
    record.pos = atoi(nextField(line, delimeter, tabPos).c_str());
    //mapq
    record.mapq = atoi(nextField(line, delimeter, tabPos).c_str());
    //skip CIGAR
    string cigar = nextField(line, delimeter, tabPos);
    int cigarPos = 0;
    while(cigar[cigarPos] >= 48 && cigar[cigarPos] <= 57)//integer
        cigarPos++;
    //now cigar[cigarPos] is character
    if(cigar[cigarPos] == 'S' || cigar[cigarPos] == 'H'){
        record.pos -= atoi(cigar.substr(0,cigarPos).c_str());
    }
    //rnext
    record.rnext = nextField(line, delimeter, tabPos);
    //pnext
    record.pnext = atoi(nextField(line, delimeter, tabPos).c_str());
    //edit distance NM tag
    //skip fields to make sure 
    tabPos = line.find(delimeter,tabPos)+1;
    tabPos = line.find(delimeter,tabPos)+1;
    tabPos = line.find(delimeter,tabPos)+1;
    //now passed qual
    string editTag = tag+":i:";
    int NMpos = line.find(editTag,tabPos);
    if(NMpos == -1 && !record.flag.test(2))
            record.edit = -1;
    else if(NMpos>=tabPos){
        tabPos = line.find(delimeter,NMpos);
        if(tabPos == -1)
            tabPos = line.length();
        record.edit = atoi(line.substr(NMpos+5,tabPos-NMpos-5).c_str());
    }
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
leaq 0xc(%rsp), %rcx
andl $0x0, (%rcx)
leaq 0x30(%rsp), %r12
pushq $0x9
popq %rdx
movq %r12, %rdi
movq %r14, %rsi
callq 0x2a2b8
movq %rbx, %rdi
movq %r12, %rsi
callq 0x73a0
movq %r12, %rdi
callq 0x76a8
movq 0x8(%rbx), %rsi
cmpq $0x3, %rsi
jb 0x2a3ee
movq (%rbx), %rax
cmpb $0x2f, -0x2(%rax,%rsi)
jne 0x2a3ee
addq $-0x2, %rsi
pushq $-0x1
popq %rdx
movq %rbx, %rdi
callq 0x70c0
leaq 0x30(%rsp), %r12
pushq $0x9
popq %rbp
leaq 0xc(%rsp), %r13
movq %r12, %rdi
movq %r14, %rsi
movl %ebp, %edx
movq %r13, %rcx
callq 0x2a2b8
movq (%r12), %rdi
callq 0x7520
andl $0x7ff, %eax            # imm = 0x7FF
leaq 0x20(%rbx), %rcx
movq %rcx, 0x50(%rsp)
movq %rax, 0x20(%rbx)
movq %r12, %rdi
callq 0x76a8
leaq 0x30(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movl %ebp, %edx
movq %r13, %rcx
callq 0x2a2b8
leaq 0x28(%rbx), %rdi
movq %r12, %rsi
callq 0x73a0
movq %r12, %rdi
callq 0x76a8
leaq 0x30(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movl %ebp, %edx
movq %r13, %rcx
callq 0x2a2b8
movq (%r12), %rdi
callq 0x7520
cltq
movq %rax, 0x48(%rbx)
movq %r12, %rdi
callq 0x76a8
leaq 0x30(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movl %ebp, %edx
movq %r13, %rcx
callq 0x2a2b8
movq (%r12), %rdi
callq 0x7520
movl %eax, 0x50(%rbx)
movq %r12, %rdi
callq 0x76a8
leaq 0x30(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movl %ebp, %edx
movq %r13, %rcx
callq 0x2a2b8
pushq $-0x1
popq %rcx
movq (%r12), %rdx
movzbl 0x1(%rdx,%rcx), %eax
cmpb $0x30, %al
jl 0x2a50f
incq %rcx
cmpb $0x3a, %al
jb 0x2a4c8
cmpl $0x53, %eax
je 0x2a4e2
cmpl $0x48, %eax
jne 0x2a50f
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
xorl %edx, %edx
callq 0x72f0
leaq 0x10(%rsp), %r12
movq (%r12), %rdi
callq 0x7520
cltq
subq %rax, 0x48(%rbx)
movq %r12, %rdi
callq 0x76a8
leaq 0x10(%rsp), %rdi
pushq $0x9
popq %rdx
leaq 0xc(%rsp), %rcx
movq %r14, %rsi
callq 0x2a2b8
leaq 0x58(%rbx), %rdi
leaq 0x10(%rsp), %r12
movq %r12, %rsi
callq 0x73a0
movq %r12, %rdi
callq 0x76a8
leaq 0x10(%rsp), %rdi
pushq $0x9
popq %rdx
leaq 0xc(%rsp), %rcx
movq %r14, %rsi
callq 0x2a2b8
leaq 0x10(%rsp), %r12
movq (%r12), %rdi
callq 0x7520
cltq
movq %rax, 0x78(%rbx)
movq %r12, %rdi
callq 0x76a8
movslq 0xc(%rsp), %rdx
pushq $0x9
popq %rbp
movq %r14, %rdi
movl %ebp, %esi
callq 0x7410
incl %eax
movslq %eax, %rdx
movq %r14, %rdi
movl %ebp, %esi
callq 0x7410
incl %eax
movslq %eax, %rdx
movq %r14, %rdi
movl %ebp, %esi
callq 0x7410
movq %rax, %r13
leaq 0x7ef0(%rip), %rdx      # 0x32498
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x11081
incl %r13d
movslq %r13d, %rdx
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x7690
movq %rax, %r15
cmpl $-0x1, %r15d
jne 0x2a5e2
pushq $0x2
popq %rsi
movq 0x50(%rsp), %rdi
callq 0xa11c
testb %al, %al
je 0x2a638
cmpl %r15d, %r13d
jg 0x2a63f
movslq %r15d, %rdx
pushq $0x9
popq %rsi
movq %r14, %rdi
callq 0x7410
cmpl $-0x1, %eax
jne 0x2a5fe
movl 0x8(%r14), %eax
leal 0x5(%r15), %ecx
movslq %ecx, %rdx
subl %r15d, %eax
addl $-0x5, %eax
movslq %eax, %rcx
leaq 0x58(%rsp), %rdi
movq %r14, %rsi
callq 0x72f0
leaq 0x58(%rsp), %r14
movq (%r14), %rdi
callq 0x7520
movl %eax, 0x80(%rbx)
movq %r14, %rdi
callq 0x76a8
jmp 0x2a63f
orl $-0x1, 0x80(%rbx)
leaq 0x10(%rsp), %rdi
callq 0x76a8
leaq 0x30(%rsp), %rdi
callq 0x76a8
movb $0x1, %al
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2a67b
jmp 0x2a668
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x76a8
jmp 0x2a67e
jmp 0x2a67b
jmp 0x2a67b
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x76a8
movq %rbx, %rdi
callq 0x75e0