// File: /workspace/github_cpp_makefile_star2_O3/medvedevgroup[P]varmatch/src/wholegenome.cpp
// Function: WholeGenome::AppendChangedSp(SequencePath&, std::vector<DiploidVariant, std::allocator<DiploidVariant>>&, std::__cxx11::list<SequencePath, std::allocator<SequencePath>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int, int, int, int, int)
bool WholeGenome::AppendChangedSp(SequencePath& sp,
                         vector<DiploidVariant> & variant_list,
                         list<SequencePath> & sequence_path_list,
                         const string & reference_sequence,
                         int score_unit,
                         int match_mode,
                         int score_scheme,
                         int variant_index,
                         int c)
{
    int pos = sp.current_genome_pos+1;

    SequencePath path = sp;

    if(c == NOT_USE){
        path.choice_vector[variant_index] = c;
        sequence_path_list.push_back(path);
        return true;
    }

    pair<int, int> var_choice[2];
    int x = 0;
    int var_index = variant_index;
    DiploidVariant var = variant_list[var_index];
    if(var.flag) x = 1;
    string ref = var.ref;
    string alts[2];

    if(c == -1){
        alts[0] = ref;
        alts[1] = var.alts[0];
    }else if(c == -2){
        alts[0] = ref;
        alts[1] = var.alts[1];
    }else if(c >= 0){
        // c == 0 or 1
        alts[0] = var.alts[c];
        alts[1] = alts[0];

        if(var.multi_alts && !var.zero_one_var){
            // choose 1 or 0
            alts[1] = var.alts[1- c];
        }else{
            // c is 0, choose 0 or -1
            if(var.heterozygous) alts[1] = ref;
        }
    }else{
        dout << "Unrecognized choice" << endl;
    }
    path.score += CalculateScore(var,
                                 c,
                                 score_unit,
                                 match_mode,
                                 score_scheme);
    ToUpper(ref);
    ToUpper(alts[0]);
    ToUpper(alts[1]);
    for(int y = 0; y < 2; y++){
        // iterate two alts
        string alt = alts[y];
        if(alt == ref) continue;
        vector<string> alt_vector;
        GenerateAltVector(ref, alt, alt_vector);

        int k = 0;
        for(; k < ref.length()-1; k++){

            if(alt_vector[k].size() != 1 || ref[k] != alt_vector[k][0]){
                path.string_sequences[x*2+y][pos+k] = alt_vector[k];
            }
            // else changes nothing

        }
        // hence k == ref.length()-1, the last position
        assert(k == ref.length()-1);
        string alt_part = alt_vector[k];
        if(alt_part.length() > 0){
            if(alt_part.length() > 1){
                if(alt_part[0] == ref[k]){
                    if(path.string_sequences[x*2+y][pos+k] == "."){
                        path.string_sequences[x*2+y][pos+k] = alt_part;
                    }else{
                        path.string_sequences[x*2+y][pos+k] += alt_part.substr(1, alt_part.size() - 1);
                    }
                }else{
                    path.string_sequences[x*2+y][pos+k] = alt_part;
                }
            }else{
                if(ref[k] != alt_vector[k][0]){
                    path.string_sequences[x*2+y][pos+k] = alt_part;
                }
            }
        }else{
            path.string_sequences[x*2+y][pos+k] = "";
        }
    }

    // choice made
    path.choice_vector[variant_index] = c;
    //dout << "after decision at variant " << variant_index << endl;
    //PrintPath(path);
    sequence_path_list.push_back(path);
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x318, %rsp            # imm = 0x318
movl %r9d, %ebx
movq %rcx, %r12
movq %rdx, %r15
movq %rdi, %r14
movslq 0x360(%rsp), %r13
movl 0xc8(%rsi), %eax
movl %eax, 0xc(%rsp)
leaq 0x198(%rsp), %rdi
callq 0x28ef6
cmpl $-0x9, 0x368(%rsp)
jne 0x18336
leaq 0x198(%rsp), %rsi
movq 0x168(%rsi), %rax
movl $0xfffffff7, (%rax,%r13,4) # imm = 0xFFFFFFF7
movq %r12, %rdi
callq 0x2e160
movq %rax, %rdi
movq %r12, %rsi
callq 0x5070
incq 0x10(%r12)
jmp 0x18976
movq %r12, 0x78(%rsp)
movq (%r15), %r15
imulq $0x58, %r13, %r12
movl (%r15,%r12), %eax
leaq 0xe0(%rsp), %rdi
movl %eax, -0x8(%rdi)
leaq 0xf0(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x8(%r15,%r12), %rsi
movq 0x10(%r15,%r12), %rdx
addq %rsi, %rdx
callq 0x1123c
movq %r13, 0x170(%rsp)
addq %r12, %r15
leaq 0x100(%rsp), %rdi
leaq 0x28(%r15), %rsi
callq 0x28582
movups 0x40(%r15), %xmm0
movups %xmm0, 0x118(%rsp)
movq 0x50(%r15), %rax
movq %rax, 0x128(%rsp)
movb 0x124(%rsp), %bpl
leaq 0x28(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0xe0(%rsp), %rsi
movq 0xe8(%rsp), %rdx
addq %rsi, %rdx
leaq 0x18(%rsp), %r12
movq %r12, %rdi
callq 0x1123c
movl 0x368(%rsp), %edx
movl 0x350(%rsp), %r15d
incl 0xc(%rsp)
movl $0x10, %eax
leaq (%rsp,%rax), %rcx
addq $0x130, %rcx            # imm = 0x130
movq %rcx, -0x10(%rcx)
movq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
addq $0x20, %rax
cmpq $0x50, %rax
jne 0x183ed
cmpl $-0x2, %edx
je 0x1843b
cmpl $-0x1, %edx
jne 0x18a15
leaq 0x130(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x51c0
movq 0x100(%rsp), %r12
jmp 0x18459
leaq 0x130(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x51c0
movq 0x100(%rsp), %r12
addq $0x20, %r12
leaq 0x150(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x51c0
leaq 0xd8(%rsp), %rsi
movq %r14, %rdi
movl 0x368(%rsp), %edx
movl %ebx, %ecx
movl %r15d, %r8d
movl 0x358(%rsp), %r9d
callq 0x174b2
addl %eax, 0x2f0(%rsp)
movq 0x20(%rsp), %rbx
testq %rbx, %rbx
je 0x184bf
movq 0x18(%rsp), %r14
xorl %r15d, %r15d
movsbl (%r14,%r15), %edi
callq 0x5610
movb %al, (%r14,%r15)
incq %r15
cmpq %r15, %rbx
jne 0x184a9
movq 0x138(%rsp), %rbx
testq %rbx, %rbx
je 0x184ed
movq 0x130(%rsp), %r14
xorl %r15d, %r15d
movsbl (%r14,%r15), %edi
callq 0x5610
movb %al, (%r14,%r15)
incq %r15
cmpq %r15, %rbx
jne 0x184d7
movq 0x158(%rsp), %rbx
testq %rbx, %rbx
je 0x1851b
movq 0x150(%rsp), %r14
xorl %r15d, %r15d
movsbl (%r14,%r15), %edi
callq 0x5610
movb %al, (%r14,%r15)
incq %r15
cmpq %r15, %rbx
jne 0x18505
leaq 0x68(%rsp), %rbx
movslq 0xc(%rsp), %r13
movzbl %bpl, %eax
addl %eax, %eax
movq %rax, 0x10(%rsp)
shlq $0x5, %r13
leaq 0x130(%rsp), %rax
movb $0x1, %r12b
xorl %r14d, %r14d
movq %rbx, 0x58(%rsp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x58(%rsp), %rdi
callq 0x1123c
movq 0x60(%rsp), %rdx
movq 0x20(%rsp), %rbx
cmpq %rbx, %rdx
jne 0x18591
movq 0x58(%rsp), %r15
testq %rdx, %rdx
je 0x18884
movq 0x18(%rsp), %rbp
movq %r15, %rdi
movq %rbp, %rsi
callq 0x5350
testl %eax, %eax
jne 0x18596
jmp 0x18884
movq 0x18(%rsp), %rbp
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
movq $0x0, 0x90(%rsp)
leaq 0xa8(%rsp), %rax
movq %rax, 0x98(%rsp)
addq %rbp, %rbx
leaq 0x98(%rsp), %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x1123c
leaq 0x188(%rsp), %r15
movq %r15, 0x178(%rsp)
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
addq %rsi, %rdx
leaq 0x178(%rsp), %rbx
movq %rbx, %rdi
callq 0x1123c
leaq 0x98(%rsp), %rsi
movq %rbx, %rdx
leaq 0x80(%rsp), %rcx
callq 0x13eb2
movq 0x178(%rsp), %rdi
cmpq %r15, %rdi
je 0x18635
movq 0x188(%rsp), %rsi
incq %rsi
callq 0x5340
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x1865a
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x5340
movq 0x20(%rsp), %rax
cmpq $0x1, %rax
jne 0x1866c
xorl %r15d, %r15d
xorl %ebx, %ebx
jmp 0x186d9
movq %r14, %rcx
orq 0x10(%rsp), %rcx
leaq (%rcx,%rcx,2), %rcx
leaq 0x1a0(%rsp), %rdx
leaq (%rdx,%rcx,8), %rbx
xorl %ebp, %ebp
xorl %r15d, %r15d
movq 0x80(%rsp), %rcx
leaq (%rcx,%rbp), %rsi
cmpq $0x1, 0x8(%rcx,%rbp)
jne 0x186ad
movq 0x18(%rsp), %rcx
movb (%rcx,%r15), %cl
movq (%rsi), %rdx
cmpb (%rdx), %cl
je 0x186c0
movq (%rbx), %rdi
addq %r13, %rdi
addq %rbp, %rdi
callq 0x51c0
movq 0x20(%rsp), %rax
incq %r15
leaq -0x1(%rax), %rcx
addq $0x20, %rbp
cmpq %r15, %rcx
ja 0x18689
jne 0x18adf
movl %r15d, %ebx
movq 0x80(%rsp), %rax
movq %r15, %rbp
shlq $0x5, %rbp
leaq 0x48(%rsp), %rcx
movq %rcx, 0x38(%rsp)
movq (%rax,%rbp), %rsi
movq 0x8(%rax,%rbp), %rdx
addq %rsi, %rdx
leaq 0x38(%rsp), %rdi
callq 0x1123c
movq 0x40(%rsp), %rax
testq %rax, %rax
je 0x18756
cmpq $0x1, %rax
jne 0x18795
movq 0x18(%rsp), %rax
movb (%rax,%r15), %al
movq 0x80(%rsp), %rcx
movq (%rcx,%rbp), %rcx
cmpb (%rcx), %al
je 0x18856
orq 0x10(%rsp), %r14
leaq (%r14,%r14,2), %rax
leaq 0x1a0(%rsp), %rcx
leaq (%rcx,%rax,8), %r14
addl 0xc(%rsp), %ebx
movslq %ebx, %rbp
jmp 0x18842
orq 0x10(%rsp), %r14
leaq (%r14,%r14,2), %rax
addl 0xc(%rsp), %ebx
movslq %ebx, %rcx
leaq 0x1a0(%rsp), %rdx
movq (%rdx,%rax,8), %rax
shlq $0x5, %rcx
leaq (%rax,%rcx), %rdi
movq 0x8(%rax,%rcx), %rdx
xorl %esi, %esi
leaq 0x18e6a(%rip), %rcx     # 0x315f2
xorl %r8d, %r8d
callq 0x54b0
jmp 0x18856
movq 0x38(%rsp), %rax
movb (%rax), %cl
movq 0x18(%rsp), %rdx
orq 0x10(%rsp), %r14
leaq (%r14,%r14,2), %rax
addl 0xc(%rsp), %ebx
movslq %ebx, %rbp
movq %rbp, %rbx
shlq $0x5, %rbx
leaq 0x1a0(%rsp), %rsi
movq (%rsi,%rax,8), %rdi
addq %rbx, %rdi
cmpb (%rdx,%r15), %cl
jne 0x1884c
leaq (%rsi,%rax,8), %r14
leaq 0x192ae(%rip), %rsi     # 0x31a86
callq 0x50e0
testl %eax, %eax
je 0x18842
movq 0x40(%rsp), %rcx
decq %rcx
movl $0x1, %edx
leaq 0xb8(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x5360
addq (%r14), %rbx
movq 0xb8(%rsp), %rsi
movq 0xc0(%rsp), %rdx
movq %rbx, %rdi
callq 0x50f0
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x18856
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x18856
shlq $0x5, %rbp
addq (%r14), %rbp
movq %rbp, %rdi
leaq 0x38(%rsp), %rsi
callq 0x51c0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x18872
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x5340
leaq 0x80(%rsp), %rdi
callq 0xe71c
movq 0x58(%rsp), %r15
leaq 0x68(%rsp), %rbx
cmpq %rbx, %r15
je 0x1889e
movq 0x68(%rsp), %rsi
incq %rsi
movq %r15, %rdi
callq 0x5340
movl $0x1, %r14d
leaq 0x150(%rsp), %rax
testb $0x1, %r12b
movl $0x0, %r12d
movq 0x170(%rsp), %rcx
jne 0x18542
leaq 0x198(%rsp), %rsi
movq 0x168(%rsi), %rax
movl 0x368(%rsp), %edx
movl %edx, (%rax,%rcx,4)
movq 0x78(%rsp), %rdi
callq 0x2e160
movq %rax, %rdi
movq 0x78(%rsp), %rbx
movq %rbx, %rsi
callq 0x5070
incq 0x10(%rbx)
movq $-0x40, %rbx
leaq 0x160(%rsp), %r14
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0x1891e
movq (%r14), %rsi
incq %rsi
callq 0x5340
addq $-0x20, %r14
addq $0x20, %rbx
jne 0x1890a
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x18944
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5340
leaq 0x100(%rsp), %rdi
callq 0xe71c
movq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0x18976
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x5340
movq 0x300(%rsp), %rdi
testq %rdi, %rdi
je 0x18993
movq 0x310(%rsp), %rsi
subq %rdi, %rsi
callq 0x5340
movl $0x140, %ebx            # imm = 0x140
leaq (%rsp,%rbx), %rax
addq $0x198, %rax            # imm = 0x198
movq -0x10(%rax), %rdi
cmpq %rdi, %rax
je 0x189b6
movq (%rax), %rsi
incq %rsi
callq 0x5340
addq $-0x20, %rbx
cmpq $0xc0, %rbx
jne 0x18998
movl $0x98, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x198, %rdi            # imm = 0x198
callq 0x2a10c
addq $-0x30, %rbx
cmpq $0x38, %rbx
jne 0x189c8
movl $0x50, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x198, %rdi            # imm = 0x198
callq 0xe71c
addq $-0x18, %rbx
cmpq $-0x10, %rbx
jne 0x189e7
movb $0x1, %al
addq $0x318, %rsp            # imm = 0x318
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %edx, %edx
js 0x18a73
movl %edx, %esi
shlq $0x5, %rsi
addq 0x100(%rsp), %rsi
leaq 0x130(%rsp), %rdi
callq 0x51c0
leaq 0x150(%rsp), %r13
leaq 0x130(%rsp), %rsi
movq %r13, %rdi
callq 0x51c0
cmpb $0x1, 0x119(%rsp)
jne 0x18a60
cmpb $0x0, 0x11a(%rsp)
je 0x18abf
cmpb $0x1, 0x118(%rsp)
je 0x18461
jmp 0x1846c
movq 0x24556(%rip), %r12     # 0x3cfd0
leaq 0x18bac(%rip), %rsi     # 0x3162d
movl $0x13, %edx
movq %r12, %rdi
callq 0x53a0
movq (%r12), %rax
addq -0x18(%rax), %r12
movq %r12, %rdi
movl $0xa, %esi
callq 0x5310
movsbl %al, %esi
movq 0x24523(%rip), %rdi     # 0x3cfd0
callq 0x5040
movq %rax, %rdi
callq 0x5240
jmp 0x1846c
movl $0x1, %eax
subl 0x368(%rsp), %eax
movslq %eax, %r12
shlq $0x5, %r12
addq 0x100(%rsp), %r12
jmp 0x18461
leaq 0x18b5b(%rip), %rdi     # 0x31641
leaq 0x18b68(%rip), %rsi     # 0x31655
leaq 0x18b71(%rip), %rcx     # 0x31665
movl $0x562, %edx            # imm = 0x562
callq 0x5230
movq %rax, %rbx
jmp 0x18c52
movq %rax, %rbx
movq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0x18c5f
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x18c5f
jmp 0x18b39
movq %rax, %rbx
jmp 0x18c5f
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x18b72
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x18b72
jmp 0x18b6f
jmp 0x18bd8
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x18be0
movq 0x48(%rsp), %rsi
jmp 0x18bce
jmp 0x18bdd
jmp 0x18bdd
movq %rax, %rbx
jmp 0x18bb1
movq %rax, %rbx
movq 0x178(%rsp), %rdi
cmpq %r15, %rdi
je 0x18bb1
movq 0x188(%rsp), %rsi
incq %rsi
callq 0x5340
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x18be0
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x18be0
movq %rax, %rbx
jmp 0x18c09
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0xe71c
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x18c09
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x5340
movq $-0x40, %r14
leaq 0x160(%rsp), %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x18c2c
movq (%r15), %rsi
incq %rsi
callq 0x5340
addq $-0x20, %r15
addq $0x20, %r14
jne 0x18c18
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x18c52
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5340
leaq 0xd8(%rsp), %rdi
callq 0x286da
leaq 0x198(%rsp), %rdi
callq 0x290d4
movq %rbx, %rdi
callq 0x55c0