// File: CK7[P]abawaca/src/ReadMapping.cpp
// Function: Bio::ReadMapping::determine_snps(Bio::DNAString const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned long)
void ReadMapping::determine_snps(const DNAString& dna_str, const string& quality_str, string CIGAR_indels, string CIGAR_mismatches, size_t ref_pos)
{
	if(CIGAR_mismatches.size() == 0)
		return;

	// This regexp was taken from the SAM manual
	// /^MD:Z:([0-9]+)(([ACGTN]|\^[ACGTN]+)[0-9]+)*$/)
	string::const_iterator p = CIGAR_mismatches.begin();
	if((*p!='M') || (*(p+1)!='D') || (*(p+2)!=':') || (*(p+3)!='Z') || (*(p+4)!=':')) {
		throw Illegal_mapping(CIGAR_mismatches, "Illegal SNPs description, expected MD:Z: at the beginning of CIGAR_mismatches format but found something different", __PRETTY_FUNCTION__);
	}
	p += 5;

	// Read the offset to the first SNP
	size_t	read_pos = 0, ref_deleted = 0;
	while((*p>='0') && (*p<='9')) {
		read_pos *= 10;
		read_pos += (*(p++)-'0');
	}
	// Set the offset to 0 
	read_pos--;
	// Keep on reading the next snps until we reach the end
	while(p != CIGAR_mismatches.end()) {
		// First we expect the ref's char
		if((*p!='^') && ((*p<'A') || (*p>'Z')))
			throw Illegal_mapping(CIGAR_mismatches, string("Illegal SNPs description (2), expected CIGAR_mismatches format but found something different"), __PRETTY_FUNCTION__);

		if(*p=='^') {
			p++;
			while(((*p<'0') || (*p>'9')) && (p != CIGAR_mismatches.end())) {
				ref_deleted++;
				m_snps.push_back(SNP(SNP::DELETION, ref_pos+read_pos+ref_deleted, read_pos, *p, '-', 40));
				p++;
			}
		}
		else {
			read_pos++;
			m_snps.push_back(SNP(SNP::MISMATCH, ref_pos+read_pos+ref_deleted, read_pos, *p, dna_str.get(read_pos), quality_str.at(read_pos)));
			p++;
		}

		// There must be at least one more number
		if((*p < '0') || (*p > '9'))
			throw Illegal_mapping(CIGAR_mismatches, "Illegal SNPs description, expeected CIGAR_mismatches format but found something different", __PRETTY_FUNCTION__);
		unsigned int o = 0;
		while((*p>='0') && (*p<='9')) {
			o *= 10;
			o += (*(p++)-'0');
		}
		read_pos += o;
	}

	// Now we have to go through the insertion/deletion CIGAR string and correct mismatches accordingly
	// Examples: 6M1D9M1I132M, 31M1I106M	
	p = CIGAR_indels.begin();
	// Make sure that the end of the string is legal (so we don't have to check it all the time in the loop below)
	char ch = *(CIGAR_indels.rbegin());
	if((ch!='I') && (ch!='D') && (ch!='M')) {
		throw Illegal_mapping(CIGAR_indels, string("Illegal CIGAR-indels description (3)"), __PRETTY_FUNCTION__);
	}

	int read_pos2 = 0;
	size_t ref_pos2 = ref_pos;
	while(p!=CIGAR_indels.end()) {
		size_t o = 0;
		while((*p >= '0') && (*p <= '9')) {
			o *= 10;
			o += (*(p++)-'0');
		}
		if(o == 0) {
			throw Illegal_mapping(CIGAR_indels, string("Illegal CIGAR-indels description (4)"), __PRETTY_FUNCTION__);
		}
		vector<SNP>::iterator ps;
		size_t pos;
		switch (*(p++)) {
			case 'M':
				read_pos2 += o;
				ref_pos2 += o;
				break;
			case 'D':
				// Nothig to do here - this case was already taken care of in CIGAR_mismatches
				ref_pos2 += o;
				break;
			case 'I':
				for(ps=m_snps.begin(); ps!=m_snps.end(); ps++) {
					if(ps->read_pos >= read_pos2) {
						ps->read_pos += o;
					}
				}
				read_pos += o;

				for(ps=m_snps.begin(); (ps!=m_snps.end()) && (ps->read_pos < read_pos2); ps++)
					;
				// At this point we don't provide any information about the insetion except that it exists
				m_snps.insert(ps, SNP(SNP::INSERTION, ref_pos2-1, read_pos2-1, '-', '-', '-'));
				read_pos2 += o;

				break;
			default:
				throw Illegal_mapping(CIGAR_indels, string("Unexpected CIGAR-indels operation found"), __PRETTY_FUNCTION__);
		}
	}

	// Sanity check
	if(((read_pos+1) != dna_str.size()) || (read_pos2 != dna_str.size()))
		throw Illegal_mapping(CIGAR_indels+string(", ")+CIGAR_mismatches, "snps and offsets do not sum to expected read length", __PRETTY_FUNCTION__);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x540, %rsp            # imm = 0x540
movq %r8, -0x428(%rbp)
movq %rdi, %rax
movq -0x428(%rbp), %rdi
movq %rcx, -0x420(%rbp)
movq %rdi, -0x418(%rbp)
movq %rax, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %rdi, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x410(%rbp)
callq 0x4210
cmpq $0x0, %rax
jne 0x4c5d
jmp 0x5e51
movq -0x418(%rbp), %rdi
callq 0x4270
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x66c0
leaq -0x38(%rbp), %rdi
callq 0x6700
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x4d, %ecx
movb %al, -0x429(%rbp)
jne 0x4d46
leaq -0x38(%rbp), %rdi
movl $0x1, %esi
callq 0x6720
movq %rax, -0x48(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x6700
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x44, %ecx
movb %al, -0x429(%rbp)
jne 0x4d46
leaq -0x38(%rbp), %rdi
movl $0x2, %esi
callq 0x6720
movq %rax, -0x50(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x6700
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x3a, %ecx
movb %al, -0x429(%rbp)
jne 0x4d46
leaq -0x38(%rbp), %rdi
movl $0x3, %esi
callq 0x6720
movq %rax, -0x58(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x6700
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x5a, %ecx
movb %al, -0x429(%rbp)
jne 0x4d46
leaq -0x38(%rbp), %rdi
movl $0x4, %esi
callq 0x6720
movq %rax, -0x60(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x6700
movsbl (%rax), %eax
cmpl $0x3a, %eax
setne %al
movb %al, -0x429(%rbp)
movb -0x429(%rbp), %al
testb $0x1, %al
jne 0x4d55
jmp 0x4e6b
movb $0x1, -0xb2(%rbp)
movl $0x28, %edi
callq 0x4170
movq -0x418(%rbp), %rsi
movq %rax, -0x438(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x4140
jmp 0x4d7f
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x440(%rbp)
callq 0x45d0
movq -0x440(%rbp), %rdx
leaq 0x1d26c(%rip), %rsi     # 0x2200c
leaq -0xb0(%rbp), %rdi
callq 0x4470
jmp 0x4dae
movq -0x438(%rbp), %rdi
leaq 0x1d2c3(%rip), %rcx     # 0x2207f
leaq -0x80(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
callq 0x6760
jmp 0x4dce
movq -0x438(%rbp), %rdi
movb $0x0, -0xb2(%rbp)
leaq 0x2ca5d(%rip), %rsi     # 0x31840
leaq 0x1ea6(%rip), %rdx      # 0x6c90
callq 0x4590
jmp 0x5e66
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x4e4f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x4e3a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x41c0
leaq -0xb1(%rbp), %rdi
callq 0x4370
leaq -0x80(%rbp), %rdi
callq 0x41c0
testb $0x1, -0xb2(%rbp)
jne 0x4e5a
jmp 0x4e66
movq -0x438(%rbp), %rdi
callq 0x4220
jmp 0x5e5a
leaq -0x38(%rbp), %rdi
movl $0x5, %esi
callq 0x6cd0
movq $0x0, -0xc0(%rbp)
movq $0x0, -0xc8(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x6700
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x30, %ecx
movb %al, -0x441(%rbp)
jl 0x4ec0
leaq -0x38(%rbp), %rdi
callq 0x6700
movsbl (%rax), %eax
cmpl $0x39, %eax
setle %al
movb %al, -0x441(%rbp)
movb -0x441(%rbp), %al
testb $0x1, %al
jne 0x4ecc
jmp 0x4f14
imulq $0xa, -0xc0(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x6cf0
movq %rax, -0xd0(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x6700
movsbl (%rax), %eax
subl $0x30, %eax
cltq
addq -0xc0(%rbp), %rax
movq %rax, -0xc0(%rbp)
jmp 0x4e8f
movq -0xc0(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0xc0(%rbp)
movq -0x418(%rbp), %rdi
callq 0x41a0
movq %rax, -0xd8(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x6d30
testb $0x1, %al
jne 0x4f52
jmp 0x54b5
leaq -0x38(%rbp), %rdi
callq 0x6700
movsbl (%rax), %eax
cmpl $0x5e, %eax
je 0x50ac
leaq -0x38(%rbp), %rdi
callq 0x6700
movsbl (%rax), %eax
cmpl $0x41, %eax
jl 0x4f8d
leaq -0x38(%rbp), %rdi
callq 0x6700
movsbl (%rax), %eax
cmpl $0x5a, %eax
jle 0x50ac
movb $0x1, -0x11a(%rbp)
movl $0x28, %edi
callq 0x4170
movq -0x418(%rbp), %rsi
movq %rax, -0x450(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x4140
jmp 0x4fba
leaq -0x119(%rbp), %rdi
movq %rdi, -0x458(%rbp)
callq 0x45d0
movq -0x458(%rbp), %rdx
leaq 0x1d105(%rip), %rsi     # 0x220e0
leaq -0x118(%rbp), %rdi
callq 0x4470
jmp 0x4fe9
movq -0x450(%rbp), %rdi
leaq 0x1d088(%rip), %rcx     # 0x2207f
leaq -0xf8(%rbp), %rsi
leaq -0x118(%rbp), %rdx
callq 0x6760
jmp 0x500c
movq -0x450(%rbp), %rdi
movb $0x0, -0x11a(%rbp)
leaq 0x2c81f(%rip), %rsi     # 0x31840
leaq 0x1c68(%rip), %rdx      # 0x6c90
callq 0x4590
jmp 0x5e66
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x5090
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x5078
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x41c0
leaq -0x119(%rbp), %rdi
callq 0x4370
leaq -0xf8(%rbp), %rdi
callq 0x41c0
testb $0x1, -0x11a(%rbp)
jne 0x509b
jmp 0x50a7
movq -0x450(%rbp), %rdi
callq 0x4220
jmp 0x5e5a
leaq -0x38(%rbp), %rdi
callq 0x6700
movsbl (%rax), %eax
cmpl $0x5e, %eax
jne 0x51eb
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x6cf0
movq %rax, -0x128(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x6700
movsbl (%rax), %eax
cmpl $0x30, %eax
jl 0x50fd
leaq -0x38(%rbp), %rdi
callq 0x6700
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x39, %ecx
movb %al, -0x459(%rbp)
jle 0x5126
movq -0x418(%rbp), %rdi
callq 0x41a0
movq %rax, -0x130(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x6d30
movb %al, -0x459(%rbp)
movb -0x459(%rbp), %al
testb $0x1, %al
jne 0x5135
jmp 0x51e6
movq -0x410(%rbp), %rax
movq -0xc8(%rbp), %rcx
addq $0x1, %rcx
movq %rcx, -0xc8(%rbp)
addq $0xd0, %rax
movq %rax, -0x468(%rbp)
movq -0x30(%rbp), %rax
addq -0xc0(%rbp), %rax
addq -0xc8(%rbp), %rax
movq %rax, -0x478(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0x470(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x6700
movq -0x478(%rbp), %rdx
movq -0x470(%rbp), %rcx
leaq -0x158(%rbp), %rdi
movl $0x2, %esi
movl $0x2d, %r9d
movsbl (%rax), %r8d
movq $0x28, (%rsp)
callq 0x6da0
movq -0x468(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x6d70
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x6cf0
movq %rax, -0x160(%rbp)
jmp 0x50d3
jmp 0x52d1
movq -0x410(%rbp), %rax
movq -0xc0(%rbp), %rcx
addq $0x1, %rcx
movq %rcx, -0xc0(%rbp)
addq $0xd0, %rax
movq %rax, -0x480(%rbp)
movq -0x30(%rbp), %rax
addq -0xc0(%rbp), %rax
addq -0xc8(%rbp), %rax
movq %rax, -0x498(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0x490(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x6700
movb (%rax), %al
movb %al, -0x482(%rbp)
movq -0x10(%rbp), %rdi
movq -0xc0(%rbp), %rsi
callq 0x6e20
movb %al, -0x481(%rbp)
movq -0x18(%rbp), %rdi
movq -0xc0(%rbp), %rsi
callq 0x43e0
movq -0x498(%rbp), %rdx
movq -0x490(%rbp), %rcx
movb -0x482(%rbp), %r8b
movb -0x481(%rbp), %r9b
movsbq (%rax), %rax
leaq -0x188(%rbp), %rdi
movl $0x4, %esi
movsbl %r8b, %r8d
movsbl %r9b, %r9d
movq %rax, (%rsp)
callq 0x6da0
movq -0x480(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x6d70
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x6cf0
movq %rax, -0x190(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x6700
movsbl (%rax), %eax
cmpl $0x30, %eax
jl 0x52f7
leaq -0x38(%rbp), %rdi
callq 0x6700
movsbl (%rax), %eax
cmpl $0x39, %eax
jle 0x5416
movb $0x1, -0x1d2(%rbp)
movl $0x28, %edi
callq 0x4170
movq -0x418(%rbp), %rsi
movq %rax, -0x4a0(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x4140
jmp 0x5324
leaq -0x1d1(%rbp), %rdi
movq %rdi, -0x4a8(%rbp)
callq 0x45d0
movq -0x4a8(%rbp), %rdx
leaq 0x1cdf8(%rip), %rsi     # 0x2213d
leaq -0x1d0(%rbp), %rdi
callq 0x4470
jmp 0x5353
movq -0x4a0(%rbp), %rdi
leaq 0x1cd1e(%rip), %rcx     # 0x2207f
leaq -0x1b0(%rbp), %rsi
leaq -0x1d0(%rbp), %rdx
callq 0x6760
jmp 0x5376
movq -0x4a0(%rbp), %rdi
movb $0x0, -0x1d2(%rbp)
leaq 0x2c4b5(%rip), %rsi     # 0x31840
leaq 0x18fe(%rip), %rdx      # 0x6c90
callq 0x4590
jmp 0x5e66
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x53fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x53e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x41c0
leaq -0x1d1(%rbp), %rdi
callq 0x4370
leaq -0x1b0(%rbp), %rdi
callq 0x41c0
testb $0x1, -0x1d2(%rbp)
jne 0x5405
jmp 0x5411
movq -0x4a0(%rbp), %rdi
callq 0x4220
jmp 0x5e5a
movl $0x0, -0x1d8(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x6700
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x30, %ecx
movb %al, -0x4a9(%rbp)
jl 0x5451
leaq -0x38(%rbp), %rdi
callq 0x6700
movsbl (%rax), %eax
cmpl $0x39, %eax
setle %al
movb %al, -0x4a9(%rbp)
movb -0x4a9(%rbp), %al
testb $0x1, %al
jne 0x545d
jmp 0x549c
imull $0xa, -0x1d8(%rbp), %eax
movl %eax, -0x1d8(%rbp)
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x6cf0
movq %rax, -0x1e0(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x6700
movsbl (%rax), %eax
subl $0x30, %eax
addl -0x1d8(%rbp), %eax
movl %eax, -0x1d8(%rbp)
jmp 0x5420
movl -0x1d8(%rbp), %eax
addq -0xc0(%rbp), %rax
movq %rax, -0xc0(%rbp)
jmp 0x4f26
movq -0x420(%rbp), %rdi
callq 0x4270
movq %rax, -0x1f0(%rbp)
leaq -0x1e8(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
callq 0x66c0
movq -0x420(%rbp), %rsi
movq -0x1e8(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq -0x200(%rbp), %rdi
callq 0x45b0
leaq -0x200(%rbp), %rdi
callq 0x6e50
movb (%rax), %al
movb %al, -0x1f1(%rbp)
movsbl -0x1f1(%rbp), %eax
cmpl $0x49, %eax
je 0x565c
movsbl -0x1f1(%rbp), %eax
cmpl $0x44, %eax
je 0x565c
movsbl -0x1f1(%rbp), %eax
cmpl $0x4d, %eax
je 0x565c
movb $0x1, -0x242(%rbp)
movl $0x28, %edi
callq 0x4170
movq -0x420(%rbp), %rsi
movq %rax, -0x4b8(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x4140
jmp 0x556a
leaq -0x241(%rbp), %rdi
movq %rdi, -0x4c0(%rbp)
callq 0x45d0
movq -0x4c0(%rbp), %rdx
leaq 0x1cc0c(%rip), %rsi     # 0x22197
leaq -0x240(%rbp), %rdi
callq 0x4470
jmp 0x5599
movq -0x4b8(%rbp), %rdi
leaq 0x1cad8(%rip), %rcx     # 0x2207f
leaq -0x220(%rbp), %rsi
leaq -0x240(%rbp), %rdx
callq 0x6760
jmp 0x55bc
movq -0x4b8(%rbp), %rdi
movb $0x0, -0x242(%rbp)
leaq 0x2c26f(%rip), %rsi     # 0x31840
leaq 0x16b8(%rip), %rdx      # 0x6c90
callq 0x4590
jmp 0x5e66
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x5640
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x5628
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x240(%rbp), %rdi
callq 0x41c0
leaq -0x241(%rbp), %rdi
callq 0x4370
leaq -0x220(%rbp), %rdi
callq 0x41c0
testb $0x1, -0x242(%rbp)
jne 0x564b
jmp 0x5657
movq -0x4b8(%rbp), %rdi
callq 0x4220
jmp 0x5e5a
movl $0x0, -0x248(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x250(%rbp)
movq -0x420(%rbp), %rdi
callq 0x41a0
movq %rax, -0x258(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x6d30
testb $0x1, %al
jne 0x569d
jmp 0x5c40
movq $0x0, -0x260(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x6700
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x30, %ecx
movb %al, -0x4c1(%rbp)
jl 0x56d9
leaq -0x38(%rbp), %rdi
callq 0x6700
movsbl (%rax), %eax
cmpl $0x39, %eax
setle %al
movb %al, -0x4c1(%rbp)
movb -0x4c1(%rbp), %al
testb $0x1, %al
jne 0x56e5
jmp 0x572d
imulq $0xa, -0x260(%rbp), %rax
movq %rax, -0x260(%rbp)
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x6cf0
movq %rax, -0x268(%rbp)
leaq -0x268(%rbp), %rdi
callq 0x6700
movsbl (%rax), %eax
subl $0x30, %eax
cltq
addq -0x260(%rbp), %rax
movq %rax, -0x260(%rbp)
jmp 0x56a8
cmpq $0x0, -0x260(%rbp)
jne 0x585a
movb $0x1, -0x2aa(%rbp)
movl $0x28, %edi
callq 0x4170
movq -0x420(%rbp), %rsi
movq %rax, -0x4d0(%rbp)
leaq -0x288(%rbp), %rdi
callq 0x4140
jmp 0x5768
leaq -0x2a9(%rbp), %rdi
movq %rdi, -0x4d8(%rbp)
callq 0x45d0
movq -0x4d8(%rbp), %rdx
leaq 0x1ca33(%rip), %rsi     # 0x221bc
leaq -0x2a8(%rbp), %rdi
callq 0x4470
jmp 0x5797
movq -0x4d0(%rbp), %rdi
leaq 0x1c8da(%rip), %rcx     # 0x2207f
leaq -0x288(%rbp), %rsi
leaq -0x2a8(%rbp), %rdx
callq 0x6760
jmp 0x57ba
movq -0x4d0(%rbp), %rdi
movb $0x0, -0x2aa(%rbp)
leaq 0x2c071(%rip), %rsi     # 0x31840
leaq 0x14ba(%rip), %rdx      # 0x6c90
callq 0x4590
jmp 0x5e66
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x583e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x5826
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x2a8(%rbp), %rdi
callq 0x41c0
leaq -0x2a9(%rbp), %rdi
callq 0x4370
leaq -0x288(%rbp), %rdi
callq 0x41c0
testb $0x1, -0x2aa(%rbp)
jne 0x5849
jmp 0x5855
movq -0x4d0(%rbp), %rdi
callq 0x4220
jmp 0x5e5a
leaq -0x2b8(%rbp), %rdi
callq 0x6e80
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x6cf0
movq %rax, -0x2c8(%rbp)
leaq -0x2c8(%rbp), %rdi
callq 0x6700
movsbl (%rax), %eax
movl %eax, -0x4dc(%rbp)
subl $0x44, %eax
je 0x58e3
jmp 0x5894
movl -0x4dc(%rbp), %eax
subl $0x49, %eax
je 0x58fd
jmp 0x58a1
movl -0x4dc(%rbp), %eax
subl $0x4d, %eax
jne 0x5b1c
jmp 0x58b2
movq -0x260(%rbp), %rcx
movslq -0x248(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x248(%rbp)
movq -0x260(%rbp), %rax
addq -0x250(%rbp), %rax
movq %rax, -0x250(%rbp)
jmp 0x5c3b
movq -0x260(%rbp), %rax
addq -0x250(%rbp), %rax
movq %rax, -0x250(%rbp)
jmp 0x5c3b
movq -0x410(%rbp), %rdi
addq $0xd0, %rdi
callq 0x6ea0
movq %rax, -0x2d0(%rbp)
movq -0x2d0(%rbp), %rax
movq %rax, -0x2b8(%rbp)
movq -0x410(%rbp), %rdi
addq $0xd0, %rdi
callq 0x6f10
movq %rax, -0x2d8(%rbp)
leaq -0x2b8(%rbp), %rdi
leaq -0x2d8(%rbp), %rsi
callq 0x6ed0
testb $0x1, %al
jne 0x5958
jmp 0x59b9
leaq -0x2b8(%rbp), %rdi
callq 0x6f40
movq 0x10(%rax), %rax
movslq -0x248(%rbp), %rcx
cmpq %rcx, %rax
jb 0x599d
movq -0x260(%rbp), %rax
movq %rax, -0x4e8(%rbp)
leaq -0x2b8(%rbp), %rdi
callq 0x6f40
movq -0x4e8(%rbp), %rcx
addq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
jmp 0x599f
leaq -0x2b8(%rbp), %rdi
xorl %esi, %esi
callq 0x6f60
movq %rax, -0x2e0(%rbp)
jmp 0x5925
movq -0x410(%rbp), %rdi
movq -0x260(%rbp), %rax
addq -0xc0(%rbp), %rax
movq %rax, -0xc0(%rbp)
addq $0xd0, %rdi
callq 0x6ea0
movq %rax, -0x2e8(%rbp)
movq -0x2e8(%rbp), %rax
movq %rax, -0x2b8(%rbp)
movq -0x410(%rbp), %rdi
addq $0xd0, %rdi
callq 0x6f10
movq %rax, -0x2f0(%rbp)
leaq -0x2b8(%rbp), %rdi
leaq -0x2f0(%rbp), %rsi
callq 0x6ed0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x4e9(%rbp)
jne 0x5a34
jmp 0x5a57
leaq -0x2b8(%rbp), %rdi
callq 0x6f40
movq 0x10(%rax), %rax
movslq -0x248(%rbp), %rcx
cmpq %rcx, %rax
setb %al
movb %al, -0x4e9(%rbp)
movb -0x4e9(%rbp), %al
testb $0x1, %al
jne 0x5a63
jmp 0x5a7f
jmp 0x5a65
leaq -0x2b8(%rbp), %rdi
xorl %esi, %esi
callq 0x6f60
movq %rax, -0x2f8(%rbp)
jmp 0x59f6
movq -0x410(%rbp), %rax
addq $0xd0, %rax
movq %rax, -0x4f8(%rbp)
leaq -0x300(%rbp), %rdi
leaq -0x2b8(%rbp), %rsi
callq 0x6fe0
movq -0x250(%rbp), %rdx
subq $0x1, %rdx
movl -0x248(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq -0x328(%rbp), %rdi
movl $0x1, %esi
movl $0x2d, %r9d
movl %r9d, %r8d
movq $0x2d, (%rsp)
callq 0x6da0
movq -0x4f8(%rbp), %rdi
movq -0x300(%rbp), %rsi
leaq -0x328(%rbp), %rdx
callq 0x6fa0
movq %rax, -0x330(%rbp)
movq -0x260(%rbp), %rcx
movslq -0x248(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x248(%rbp)
jmp 0x5c3b
movb $0x1, -0x372(%rbp)
movl $0x28, %edi
callq 0x4170
movq -0x420(%rbp), %rsi
movq %rax, -0x500(%rbp)
leaq -0x350(%rbp), %rdi
callq 0x4140
jmp 0x5b49
leaq -0x371(%rbp), %rdi
movq %rdi, -0x508(%rbp)
callq 0x45d0
movq -0x508(%rbp), %rdx
leaq 0x1c677(%rip), %rsi     # 0x221e1
leaq -0x370(%rbp), %rdi
callq 0x4470
jmp 0x5b78
movq -0x500(%rbp), %rdi
leaq 0x1c4f9(%rip), %rcx     # 0x2207f
leaq -0x350(%rbp), %rsi
leaq -0x370(%rbp), %rdx
callq 0x6760
jmp 0x5b9b
movq -0x500(%rbp), %rdi
movb $0x0, -0x372(%rbp)
leaq 0x2bc90(%rip), %rsi     # 0x31840
leaq 0x10d9(%rip), %rdx      # 0x6c90
callq 0x4590
jmp 0x5e66
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x5c1f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x5c07
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x370(%rbp), %rdi
callq 0x41c0
leaq -0x371(%rbp), %rdi
callq 0x4370
leaq -0x350(%rbp), %rdi
callq 0x41c0
testb $0x1, -0x372(%rbp)
jne 0x5c2a
jmp 0x5c36
movq -0x500(%rbp), %rdi
callq 0x4220
jmp 0x5e5a
jmp 0x5671
movq -0xc0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x510(%rbp)
movq -0x10(%rbp), %rdi
callq 0x7020
movq %rax, %rcx
movq -0x510(%rbp), %rax
cmpq %rcx, %rax
jne 0x5c94
movslq -0x248(%rbp), %rax
movq %rax, -0x518(%rbp)
movq -0x10(%rbp), %rdi
callq 0x7020
movq %rax, %rcx
movq -0x518(%rbp), %rax
cmpq %rcx, %rax
je 0x5e51
movb $0x1, -0x402(%rbp)
movl $0x28, %edi
callq 0x4170
movq %rax, -0x528(%rbp)
leaq -0x3d9(%rbp), %rdi
movq %rdi, -0x520(%rbp)
callq 0x45d0
movq -0x520(%rbp), %rdx
leaq 0x1c53c(%rip), %rsi     # 0x22209
leaq -0x3d8(%rbp), %rdi
callq 0x4470
jmp 0x5cdb
movq -0x420(%rbp), %rsi
leaq -0x3b8(%rbp), %rdi
leaq -0x3d8(%rbp), %rdx
callq 0x7090
jmp 0x5cf7
movq -0x418(%rbp), %rdx
leaq -0x398(%rbp), %rdi
leaq -0x3b8(%rbp), %rsi
callq 0x7040
jmp 0x5d13
leaq -0x401(%rbp), %rdi
movq %rdi, -0x530(%rbp)
callq 0x45d0
movq -0x530(%rbp), %rdx
leaq 0x1c4d8(%rip), %rsi     # 0x2220c
leaq -0x400(%rbp), %rdi
callq 0x4470
jmp 0x5d42
movq -0x528(%rbp), %rdi
leaq 0x1c32f(%rip), %rcx     # 0x2207f
leaq -0x398(%rbp), %rsi
leaq -0x400(%rbp), %rdx
callq 0x6760
jmp 0x5d65
movq -0x528(%rbp), %rdi
movb $0x0, -0x402(%rbp)
leaq 0x2bac6(%rip), %rsi     # 0x31840
leaq 0xf0f(%rip), %rdx       # 0x6c90
callq 0x4590
jmp 0x5e66
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x5e2c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x5e20
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x5e14
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x5dfc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x400(%rbp), %rdi
callq 0x41c0
leaq -0x401(%rbp), %rdi
callq 0x4370
leaq -0x398(%rbp), %rdi
callq 0x41c0
leaq -0x3b8(%rbp), %rdi
callq 0x41c0
leaq -0x3d8(%rbp), %rdi
callq 0x41c0
leaq -0x3d9(%rbp), %rdi
callq 0x4370
testb $0x1, -0x402(%rbp)
jne 0x5e43
jmp 0x5e4f
movq -0x528(%rbp), %rdi
callq 0x4220
jmp 0x5e5a
addq $0x540, %rsp            # imm = 0x540
popq %rbp
retq
movq -0x88(%rbp), %rdi
callq 0x45c0
nopw %cs:(%rax,%rax)