// File: /workspace/github_cpp_makefile_star2_O2/medvedevgroup[P]varmatch/src/wholegenome.cpp
// Function: WholeGenome::AppendChangedSpNoGenotype(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::AppendChangedSpNoGenotype(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 == 0 || c == 1){
        // c == 0 or 1
        alts[0] = var.alts[c];
    }else{
        dout << "Unrecognized choice" << endl;
    }
    path.score += CalculateScore(var,
                                 c,
                                 score_unit,
                                 match_mode,
                                 score_scheme);
    ToUpper(ref);
    ToUpper(alts[0]);
    int y = 0;

    string alt = alts[y];
    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 $0x308, %rsp            # imm = 0x308
movl %r9d, %r15d
movq %rcx, %r13
movq %rdx, %r12
movq %rdi, %r14
movslq 0x350(%rsp), %rbp
movl 0xc8(%rsi), %ebx
leaq 0x188(%rsp), %rdi
callq 0x1a3e8
cmpl $-0x9, 0x358(%rsp)
jne 0x127cf
leaq 0x188(%rsp), %rsi
movq 0x168(%rsi), %rax
movl $0xfffffff7, (%rax,%rbp,4) # imm = 0xFFFFFFF7
movq %r13, %rdi
callq 0x1a5a4
jmp 0x12af6
imulq $0x58, %rbp, %rsi
addq (%r12), %rsi
leaq 0x130(%rsp), %rdi
callq 0x1a174
movq %r13, 0x48(%rsp)
leaq 0x138(%rsp), %rsi
movb 0x44(%rsi), %al
movb %al, 0xf(%rsp)
leaq 0x28(%rsp), %rdi
callq 0x53f0
movl 0x348(%rsp), %r12d
movl 0x340(%rsp), %r13d
incl %ebx
pushq $0x10
popq %rax
leaq (%rsp,%rax), %rcx
addq $0xf0, %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
addq $0x20, %rax
cmpq $0x50, %rax
jne 0x12817
movl 0x358(%rsp), %eax
cmpl $0x1, %eax
ja 0x12861
movl %eax, %esi
shlq $0x5, %rsi
addq 0x158(%rsp), %rsi
leaq 0xf0(%rsp), %rdi
callq 0x51d0
jmp 0x1287c
movq 0x1d758(%rip), %rdi     # 0x2ffc0
leaq 0xfd76(%rip), %rsi      # 0x225e5
callq 0x52f0
movq %rax, %rdi
callq 0x5190
leaq 0x130(%rsp), %rsi
movq %r14, %rdi
movl 0x358(%rsp), %edx
movl %r15d, %ecx
movl %r13d, %r8d
movl %r12d, %r9d
callq 0x1106a
addl %eax, 0x2e0(%rsp)
leaq 0x28(%rsp), %rsi
movq %r14, %rdi
callq 0x19ac2
leaq 0xf0(%rsp), %rsi
movq %r14, %rdi
callq 0x19ac2
leaq 0xd0(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x53f0
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
leaq 0xb0(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x53f0
leaq 0x90(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x53f0
leaq 0xb0(%rsp), %rsi
leaq 0x90(%rsp), %rdx
leaq 0x10(%rsp), %rcx
movq %r14, %rdi
callq 0xed80
leaq 0x90(%rsp), %rdi
callq 0x55e8
leaq 0xb0(%rsp), %rdi
callq 0x55e8
cmpb $0x0, 0xf(%rsp)
pushq $0x38
popq %rax
pushq $0x8
popq %r15
cmovneq %rax, %r15
movslq %ebx, %r13
shlq $0x5, %r13
xorl %r14d, %r14d
xorl %r12d, %r12d
movq 0x30(%rsp), %rax
decq %rax
cmpq %r12, %rax
jbe 0x129a8
movq 0x10(%rsp), %rax
leaq (%rax,%r14), %rsi
cmpq $0x1, 0x8(%rax,%r14)
jne 0x1298c
movq 0x28(%rsp), %rax
movb (%rax,%r12), %al
movq (%rsi), %rcx
cmpb (%rcx), %al
je 0x1299f
movq 0x188(%rsp,%r15), %rdi
addq %r13, %rdi
addq %r14, %rdi
callq 0x51d0
incq %r12
addq $0x20, %r14
jmp 0x1295e
jne 0x12b5c
movq 0x10(%rsp), %rsi
addq %r14, %rsi
leaq 0x50(%rsp), %rdi
callq 0x53f0
movq 0x48(%rsp), %r13
movq 0x58(%rsp), %rax
testq %rax, %rax
je 0x129ff
cmpq $0x1, %rax
jne 0x12a27
movq 0x28(%rsp), %rax
movb (%rax,%r12), %al
movq 0x10(%rsp), %rcx
movq (%rcx,%r14), %rcx
cmpb (%rcx), %al
movl 0x358(%rsp), %r14d
je 0x12a86
addl %r12d, %ebx
movslq %ebx, %rbx
jmp 0x12a65
addl %r12d, %ebx
movslq %ebx, %rdi
shlq $0x5, %rdi
addq 0x188(%rsp,%r15), %rdi
leaq 0xfb92(%rip), %rsi      # 0x225aa
callq 0x55b0
movl 0x358(%rsp), %r14d
jmp 0x12a86
movq 0x50(%rsp), %rax
movb (%rax), %al
movq 0x28(%rsp), %rcx
addl %r12d, %ebx
movslq %ebx, %rbx
movq %rbx, %r14
shlq $0x5, %r14
movq 0x188(%rsp,%r15), %rdi
addq %r14, %rdi
cmpb (%rcx,%r12), %al
jne 0x12a74
leaq 0xffe6(%rip), %rsi      # 0x22a3e
callq 0xa912
testb %al, %al
je 0x12b17
shlq $0x5, %rbx
addq 0x188(%rsp,%r15), %rbx
movq %rbx, %rdi
movl 0x358(%rsp), %r14d
leaq 0x50(%rsp), %rsi
callq 0x51d0
leaq 0x188(%rsp), %rsi
movq 0x168(%rsi), %rax
movl %r14d, (%rax,%rbp,4)
movq %r13, %rdi
callq 0x1a5a4
leaq 0x50(%rsp), %rdi
callq 0x55e8
leaq 0x10(%rsp), %rdi
callq 0xadcc
leaq 0xd0(%rsp), %rdi
callq 0x55e8
pushq $0x20
popq %rbx
leaq (%rsp,%rbx), %rdi
addq $0xf0, %rdi
callq 0x55e8
addq $-0x20, %rbx
cmpq $-0x20, %rbx
jne 0x12ac5
leaq 0x28(%rsp), %rdi
callq 0x55e8
leaq 0x130(%rsp), %rdi
callq 0x19c16
leaq 0x188(%rsp), %rdi
callq 0x1a5b0
movb $0x1, %al
addq $0x308, %rsp            # imm = 0x308
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x50(%rsp), %rsi
movq 0x8(%rsi), %rcx
decq %rcx
leaq 0x70(%rsp), %rdi
pushq $0x1
popq %rdx
callq 0x5320
addq 0x188(%rsp,%r15), %r14
leaq 0x70(%rsp), %rsi
movq %r14, %rdi
callq 0x55c0
leaq 0x70(%rsp), %rdi
callq 0x55e8
movl 0x358(%rsp), %r14d
jmp 0x12a86
leaq 0xfa96(%rip), %rdi      # 0x225f9
leaq 0xfaa3(%rip), %rsi      # 0x2260d
leaq 0xfb37(%rip), %rcx      # 0x226a8
movl $0x725, %edx            # imm = 0x725
callq 0x5230
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x55e8
jmp 0x12bc0
jmp 0x12bbd
jmp 0x12bd1
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x55e8
jmp 0x12ba3
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
jmp 0x12bc5
jmp 0x12bd1
jmp 0x12bcc
movq %rax, %rbx
jmp 0x12c13
jmp 0x12bb8
movq %rax, %rbx
jmp 0x12c20
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x55e8
jmp 0x12bd4
movq %rax, %rbx
jmp 0x12beb
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xadcc
leaq 0xd0(%rsp), %rdi
callq 0x55e8
pushq $0x20
popq %r14
leaq (%rsp,%r14), %rdi
addq $0xf0, %rdi
callq 0x55e8
addq $-0x20, %r14
cmpq $-0x20, %r14
jne 0x12bef
leaq 0x28(%rsp), %rdi
callq 0x55e8
leaq 0x130(%rsp), %rdi
callq 0x19c16
leaq 0x188(%rsp), %rdi
callq 0x1a5b0
movq %rbx, %rdi
callq 0x5540
nop