// File: /workspace/github_cpp_makefile_star2_O2/CK7[P]abawaca/src/ReadMapping.cpp
// Function: Bio::ReadMapping::ReadMapping(char const*)
ReadMapping::ReadMapping(const char* SAM_line)
{
        // HWI-ST330_0096:2:2:5723:2221#TTAGGC/2        16      NODE_107_length_1448229_cov_184.575043  816000  255     85M     *       0       0       
        // AAGAANAAGCAACAAAAGGTAATTTGACAGTTGCAGGTCATGATTTAATGAACATAAAAAATAAAGAAGTTCCTTATTTACGTCG
        // A<6BB#3917.-8?4CDD?:D86DCD6;EC=BCDA,D=D:C>A+CCAA;0B>+B7ECEE?BEEFECDCCD7>1:;EE8DCEF8CF        XA:i:0  MD:Z:5A46A32    NM:i:2

        // HWI-ST330_0096:2:2:8826:2326#TTAGGC/2        4       *       0       0       *       *       0       0
        // TTTTACAGGCACTAATGCACACAGAAAAGGTTTCCAGGCAATTTTCAATGCTTGCTATAAAGCATAAATACTTAATAAAGAATTATTTTCCTTCAGATTA
        // HHHHHHHHHHEHHHHHHHHHHHHHHHHHHHDGHFFEFFDGGHFHEFBFBEHHEBHGHHHHHBEHG?FGGEHBG7HGBFH?DC?FBAB?=AFEBBFA+9DG XM:i:0

	string CIGAR_indels, CIGAR_mismatches;
	vector<string>	fs;

	split('\t', SAM_line, fs);

	QNAME = fs[0];
	FLAG = atoi(fs[1].c_str());
	RNAME = fs[2];
	POS = atoi(fs[3].c_str())-1;
	CIGAR_indels = fs[5];
	if(!strcmp(fs[6].c_str(), "=")) {
		m_same_ref = true;
		RNEXT = RNAME;
	}
	else {
		m_same_ref = false;
		RNEXT = fs[6];
	}
	PNEXT = atoi(fs[7].c_str())-1;
	TLEN = atoi(fs[8].c_str());
	SEQ = Bio::DNAString(fs[9]);
	QUAL = fs[10];

	// Look for the mismatch CIGAR string 
	for(int i=11; i<fs.size(); i++) {
		size_t pos_mdz = fs[i].find("MD:Z:");
		if(pos_mdz != string::npos) {
			size_t e = fs[i].find(" ", pos_mdz);
			if(e==string::npos) {
				CIGAR_mismatches = fs[i].substr(pos_mdz);
			}
			else {
				CIGAR_mismatches = fs[i].substr(pos_mdz, (e-pos_mdz+1));
			}
			break;
		}
	}	

	this->determine_snps(SEQ, QUAL, CIGAR_indels, CIGAR_mismatches, POS); 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rdi, %r14
leaq 0xf77c(%rip), %rax      # 0x148b8
movq %rax, (%rdi)
leaq 0x18(%rdi), %rax
movq %rax, 0x8(%rdi)
andq $0x0, 0x10(%rdi)
xorl %eax, %eax
movb %al, 0x18(%rdi)
leaq 0x40(%rdi), %rcx
movq %rcx, 0x30(%rdi)
andq $0x0, 0x38(%rdi)
movb %al, 0x40(%rdi)
leaq 0x68(%rdi), %rcx
movq %rcx, 0x58(%rdi)
andq $0x0, 0x60(%rdi)
leaq 0x8(%rdi), %rbx
movb %al, 0x68(%rdi)
leaq 0x98(%rdi), %rcx
movq %rcx, 0x88(%rdi)
andq $0x0, 0x90(%rdi)
leaq 0x30(%rdi), %r12
leaq 0x58(%rdi), %r13
movb %al, 0x98(%rdi)
leaq 0xb8(%rdi), %rcx
movq %rcx, 0xa8(%rdi)
andq $0x0, 0xb0(%rdi)
leaq 0x88(%rdi), %r15
movb %al, 0xb8(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0xd0(%rdi)
andq $0x0, 0xe0(%rdi)
leaq -0xb8(%rbp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
leaq 0xa8(%rdi), %rdx
movq %rdx, -0x48(%rbp)
movb %al, (%rcx)
leaq -0x98(%rbp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movb %al, (%rcx)
movaps %xmm0, -0x40(%rbp)
andq $0x0, -0x30(%rbp)
leaq -0x128(%rbp), %rdi
leaq -0x88(%rbp), %rdx
movq %r12, -0x60(%rbp)
movq %r13, -0x58(%rbp)
movq %rbx, -0x68(%rbp)
movq %r15, -0x50(%rbp)
callq 0x40f0
pushq $0x9
popq %rdi
leaq -0x128(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0xcbbe
leaq -0x128(%rbp), %rdi
callq 0x4130
movq -0x40(%rbp), %rsi
movq %rbx, %rdi
callq 0x4170
movq -0x40(%rbp), %r15
movq 0x20(%r15), %rdi
callq 0x4420
cltq
movq %rax, 0x28(%r14)
addq $0x40, %r15
movq %r12, %rdi
movq %r15, %rsi
callq 0x4170
movq -0x40(%rbp), %r15
movq 0x60(%r15), %rdi
callq 0x4420
decl %eax
cltq
movq %rax, 0x50(%r14)
addq $0xa0, %r15
leaq -0xc8(%rbp), %rdi
movq %r15, %rsi
callq 0x4170
movq -0x40(%rbp), %rsi
movq 0xc0(%rsi), %rax
cmpb $0x3d, (%rax)
jne 0x52bb
cmpb $0x0, 0x1(%rax)
je 0x53c6
addq $0xc0, %rsi
xorl %eax, %eax
movb %al, 0xc8(%r14)
movq %r13, %rdi
callq 0x4170
movq -0x40(%rbp), %r15
movq 0xe0(%r15), %rdi
callq 0x4420
decl %eax
cltq
movq %rax, 0x78(%r14)
movq 0x100(%r15), %rdi
callq 0x4420
movl %eax, 0x80(%r14)
addq $0x120, %r15            # imm = 0x120
leaq -0x88(%rbp), %rdi
movq %r15, %rsi
callq 0xd1d0
leaq -0x88(%rbp), %r15
movq -0x50(%rbp), %rdi
movq %r15, %rsi
callq 0x4340
movq %r15, %rdi
callq 0x4130
movl $0x140, %r12d           # imm = 0x140
movq -0x40(%rbp), %rsi
addq %r12, %rsi
movq -0x48(%rbp), %rdi
callq 0x4170
pushq $0xa
popq %rbx
leaq 0x8cb5(%rip), %r13      # 0xe004
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
incq %rbx
cmpq %rbx, %rcx
jbe 0x5407
leaq (%rax,%r12), %rdi
addq $0x20, %rdi
addq $0x20, %r12
movq %r13, %rsi
xorl %edx, %edx
callq 0x4560
cmpq $-0x1, %rax
je 0x534f
movq %rax, %r15
movq -0x40(%rbp), %rdi
addq %r12, %rdi
leaq 0x8e71(%rip), %rsi      # 0xe208
movq %rax, %rdx
callq 0x4560
cmpq $-0x1, %rax
je 0x53d0
addq -0x40(%rbp), %r12
subq %r15, %rax
incq %rax
leaq -0x88(%rbp), %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x4290
jmp 0x53e9
movb $0x1, %al
movq %r12, %rsi
jmp 0x52c4
addq -0x40(%rbp), %r12
leaq -0x88(%rbp), %rdi
pushq $-0x1
popq %rcx
movq %r12, %rsi
movq %r15, %rdx
callq 0x4290
leaq -0xa8(%rbp), %rdi
leaq -0x88(%rbp), %r15
movq %r15, %rsi
callq 0x4340
movq %r15, %rdi
callq 0x4130
leaq -0x108(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x43a0
leaq -0xe8(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x43a0
movq 0x50(%r14), %r9
leaq -0x108(%rbp), %rcx
leaq -0xe8(%rbp), %r8
movq %r14, %rdi
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0x495c
leaq -0xe8(%rbp), %rdi
callq 0x4130
leaq -0x108(%rbp), %rdi
callq 0x4130
leaq -0x40(%rbp), %rdi
callq 0x5538
leaq -0xa8(%rbp), %rdi
callq 0x4130
leaq -0xc8(%rbp), %rdi
callq 0x4130
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x54d0
jmp 0x54d0
movq %rax, %rbx
leaq -0xe8(%rbp), %rdi
callq 0x4130
jmp 0x54b2
movq %rax, %rbx
leaq -0x108(%rbp), %rdi
jmp 0x54c7
jmp 0x54d0
movq %rax, %rbx
leaq -0x128(%rbp), %rdi
callq 0x4130
jmp 0x54d3
jmp 0x54d0
movq %rax, %rbx
addq $0xd0, %r14
leaq -0x40(%rbp), %rdi
callq 0x5538
leaq -0xa8(%rbp), %rdi
callq 0x4130
leaq -0xc8(%rbp), %rdi
callq 0x4130
movq %r14, %rdi
callq 0x59d2
movq -0x48(%rbp), %rdi
callq 0x4130
movq -0x50(%rbp), %rdi
callq 0x4130
movq -0x58(%rbp), %rdi
callq 0x4130
movq -0x60(%rbp), %rdi
callq 0x4130
movq -0x68(%rbp), %rdi
callq 0x4130
movq %rbx, %rdi
callq 0x44b0