// File: millanek[P]evo/process_vcf_sequenom.cpp
// Function: writeSequenomOutput(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>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::basic_ofstream<char, std::char_traits<char>>*&)
void writeSequenomOutput(const std::string& regionSeq, const std::string& refSeq, const std::string& loc, std::ofstream*& sequenomFile) {
    
    char refBase = refSeq[100];
    char altBase = regionSeq[100];
    switch (altBase)
    {
        case 'K': altBase = (refBase == 'G') ? 'T' : 'G'; break;
        case 'M': altBase = (refBase == 'A') ? 'C' : 'A'; break;
        case 'R': altBase = (refBase == 'A') ? 'G' : 'A'; break;
        case 'S': altBase = (refBase == 'C') ? 'G' : 'C'; break;
        case 'W': altBase = (refBase == 'A') ? 'T' : 'A'; break;
        case 'Y': altBase = (refBase == 'C') ? 'T' : 'C'; break;
        default: altBase = 'X'; refBase = 'X'; break;
    }
    
    bool bPrimerCanBeDesigned = true;
    bool bRightAllDNA = checkAllDNA(regionSeq.substr(101,28));
    bool bLeftAllDNA = checkAllDNA(regionSeq.substr(72,28));
    if (bRightAllDNA == false && bLeftAllDNA == false) {
        bPrimerCanBeDesigned = false;
    }
    
    if (bPrimerCanBeDesigned)
        *sequenomFile << loc << "\t" << regionSeq.substr(0,100) << "[" << refBase << "/" << altBase << "]" << regionSeq.substr(101, string::npos) << std::endl;
    else
        *sequenomFile << loc << "\t" << "Primer problem 28bp" << std::endl;
    
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movl $0x64, %esi
movq %rsi, -0xd0(%rbp)
callq 0xa670
movq -0xd0(%rbp), %rsi
movb (%rax), %al
movb %al, -0x21(%rbp)
movq -0x8(%rbp), %rdi
callq 0xa670
movb (%rax), %al
movb %al, -0x22(%rbp)
movsbl -0x22(%rbp), %eax
addl $-0x4b, %eax
movl %eax, %ecx
movq %rcx, -0xc8(%rbp)
subl $0xe, %eax
ja 0xc1f53
movq -0xc8(%rbp), %rax
leaq 0x8071f(%rip), %rcx     # 0x142540
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsbl -0x21(%rbp), %ecx
movb $0x54, %al
movb $0x47, %dl
movb %dl, -0xd2(%rbp)
cmpl $0x47, %ecx
movb %al, -0xd1(%rbp)
je 0xc1e4f
movb -0xd2(%rbp), %al
movb %al, -0xd1(%rbp)
movb -0xd1(%rbp), %al
movb %al, -0x22(%rbp)
jmp 0xc1f5b
movsbl -0x21(%rbp), %ecx
movb $0x43, %al
movb $0x41, %dl
movb %dl, -0xd4(%rbp)
cmpl $0x41, %ecx
movb %al, -0xd3(%rbp)
je 0xc1e82
movb -0xd4(%rbp), %al
movb %al, -0xd3(%rbp)
movb -0xd3(%rbp), %al
movb %al, -0x22(%rbp)
jmp 0xc1f5b
movsbl -0x21(%rbp), %ecx
movb $0x47, %al
movb $0x41, %dl
movb %dl, -0xd6(%rbp)
cmpl $0x41, %ecx
movb %al, -0xd5(%rbp)
je 0xc1eb5
movb -0xd6(%rbp), %al
movb %al, -0xd5(%rbp)
movb -0xd5(%rbp), %al
movb %al, -0x22(%rbp)
jmp 0xc1f5b
movsbl -0x21(%rbp), %ecx
movb $0x47, %al
movb $0x43, %dl
movb %dl, -0xd8(%rbp)
cmpl $0x43, %ecx
movb %al, -0xd7(%rbp)
je 0xc1ee8
movb -0xd8(%rbp), %al
movb %al, -0xd7(%rbp)
movb -0xd7(%rbp), %al
movb %al, -0x22(%rbp)
jmp 0xc1f5b
movsbl -0x21(%rbp), %ecx
movb $0x54, %al
movb $0x41, %dl
movb %dl, -0xda(%rbp)
cmpl $0x41, %ecx
movb %al, -0xd9(%rbp)
je 0xc1f18
movb -0xda(%rbp), %al
movb %al, -0xd9(%rbp)
movb -0xd9(%rbp), %al
movb %al, -0x22(%rbp)
jmp 0xc1f5b
movsbl -0x21(%rbp), %ecx
movb $0x54, %al
movb $0x43, %dl
movb %dl, -0xdc(%rbp)
cmpl $0x43, %ecx
movb %al, -0xdb(%rbp)
je 0xc1f48
movb -0xdc(%rbp), %al
movb %al, -0xdb(%rbp)
movb -0xdb(%rbp), %al
movb %al, -0x22(%rbp)
jmp 0xc1f5b
movb $0x58, -0x22(%rbp)
movb $0x58, -0x21(%rbp)
movb $0x1, -0x23(%rbp)
movq -0x8(%rbp), %rsi
leaq -0x48(%rbp), %rdi
movl $0x65, %edx
movl $0x1c, %ecx
callq 0xa5f0
leaq -0x48(%rbp), %rdi
callq 0xc21e0
movb %al, -0xde(%rbp)
leaq -0x48(%rbp), %rdi
callq 0xac88
movb -0xde(%rbp), %al
andb $0x1, %al
movb %al, -0x24(%rbp)
movq -0x8(%rbp), %rsi
leaq -0x70(%rbp), %rdi
movl $0x48, %edx
movl $0x1c, %ecx
callq 0xa5f0
leaq -0x70(%rbp), %rdi
callq 0xc21e0
movb %al, -0xdd(%rbp)
leaq -0x70(%rbp), %rdi
callq 0xac88
movb -0xdd(%rbp), %al
andb $0x1, %al
movb %al, -0x49(%rbp)
movb -0x24(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0xc1ff1
movb -0x49(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0xc1ff1
movb $0x0, -0x23(%rbp)
testb $0x1, -0x23(%rbp)
je 0xc218c
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0xa520
movq %rax, %rdi
leaq 0x73ec9(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0xf8(%rbp)
movq -0x8(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
leaq -0x90(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
movl $0x64, %ecx
callq 0xa5f0
movq -0xf8(%rbp), %rdi
movq -0xf0(%rbp), %rsi
callq 0xa520
movq %rax, -0xe8(%rbp)
jmp 0xc205d
movq -0xe8(%rbp), %rdi
leaq 0x7b717(%rip), %rsi     # 0x13d782
callq 0xa5c0
movq %rax, -0x100(%rbp)
jmp 0xc2079
movq -0x100(%rbp), %rdi
movsbl -0x21(%rbp), %esi
callq 0xa6d0
movq %rax, -0x108(%rbp)
jmp 0xc2092
movq -0x108(%rbp), %rdi
leaq 0x7c8a6(%rip), %rsi     # 0x13e946
callq 0xa5c0
movq %rax, -0x110(%rbp)
jmp 0xc20ae
movq -0x110(%rbp), %rdi
movsbl -0x22(%rbp), %esi
callq 0xa6d0
movq %rax, -0x118(%rbp)
jmp 0xc20c7
movq -0x118(%rbp), %rdi
leaq 0x88d11(%rip), %rsi     # 0x14ade6
callq 0xa5c0
movq %rax, -0x120(%rbp)
jmp 0xc20e3
movq -0x8(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
movl $0x65, %edx
movq $-0x1, %rcx
callq 0xa5f0
jmp 0xc2101
movq -0x120(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0xa520
movq %rax, -0x128(%rbp)
jmp 0xc211d
movq -0x128(%rbp), %rdi
movq 0xd6e5d(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xc2132
leaq -0xc0(%rbp), %rdi
callq 0xac88
leaq -0x90(%rbp), %rdi
callq 0xac88
jmp 0xc21c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0xc217e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0xac88
leaq -0x90(%rbp), %rdi
callq 0xac88
jmp 0xc21d2
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0xa520
movq %rax, %rdi
leaq 0x73d38(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, %rdi
leaq 0x80436(%rip), %rsi     # 0x1425eb
callq 0xa5c0
movq %rax, %rdi
movq 0xd6dc4(%rip), %rsi     # 0x198f88
callq 0xa610
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
movq -0x98(%rbp), %rdi
callq 0xab50
nop