// File: /workspace/github_cpp_makefile_star2_O2/medvedevgroup[P]varmatch/src/wholegenome.cpp
// Function: WholeGenome::CheckPathEqualProperty(SequencePath&, int)
int WholeGenome::CheckPathEqualProperty(SequencePath & sp, int match_mode)
{

    if(match_mode == 0){
        //bool equal_sequences = false;
        // same ref position, same donor length, same donor sequence, keep
        if(sp.donor_sequences[0].length() == sp.donor_sequences[2].length() &&
           sp.donor_sequences[1].length() == sp.donor_sequences[3].length()){
            if(sp.donor_sequences[0] == sp.donor_sequences[2] && sp.donor_sequences[1] == sp.donor_sequences[3]){
                sp.same_donor_len = true;
                sp.current_equal_donor_pos[0] = sp.donor_sequences[0].length()-1;
                sp.current_equal_donor_pos[1] = sp.donor_sequences[1].length()-1;
                return 0;
            }else{
                //dout << "delete this path at pos: " << sp.current_genome_pos << " for not equal donor sequence";
                //PrintPath(sp);
                return -1;
            }
        }else{
            sp.same_donor_len = false;
            int min_donor_identical_len[2];
            for(int i = 0; i < 2; i++){
                // compare each strain
                min_donor_identical_len[i] = min(sp.donor_sequences[0+i].length(), sp.donor_sequences[2+i].length());
                for(int k = sp.current_equal_donor_pos[i]+1; k < min_donor_identical_len[i]; k++){
                    if(sp.donor_sequences[0+i][k] != sp.donor_sequences[2+i][k]){
                        return -1;
                    }
                }
                sp.current_equal_donor_pos[i] = min_donor_identical_len[i]-1;
            }
            return 0;
        }
    }else{
        if(sp.donor_sequences[0].length() == sp.donor_sequences[2].length()){
            if(sp.donor_sequences[0] == sp.donor_sequences[2]){
                sp.same_donor_len = true;
                sp.current_equal_donor_pos[0] = sp.donor_sequences[0].length()-1;
                //sp.current_equal_donor_pos[1] = sp.donor_sequences[1].length()-1;
                return 0;
            }else{
                //dout << "delete this path at pos: " << sp.current_genome_pos << " for not equal donor sequence";
                //PrintPath(sp);
                return -1;
            }
        }else{
            sp.same_donor_len = false;
            int min_donor_identical_len[2];
            //for(int i = 0; i < 2; i++)
            int i = 0;
            {
                // compare each strain
                min_donor_identical_len[i] = min(sp.donor_sequences[0+i].length(), sp.donor_sequences[2+i].length());
                for(int k = sp.current_equal_donor_pos[i]+1; k < min_donor_identical_len[i]; k++){
                    if(sp.donor_sequences[0+i][k] != sp.donor_sequences[2+i][k]){
                        return -1;
                    }
                }
                sp.current_equal_donor_pos[i] = min_donor_identical_len[i]-1;
            }
            return 0;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
leaq 0xd0(%rsi), %rdi
addq $0x110, %rsi            # imm = 0x110
movq 0xd8(%rbx), %rax
movq 0x118(%rbx), %rcx
testl %edx, %edx
je 0x10d63
cmpq %rcx, %rax
jne 0x10dd3
callq 0x93ce
testb %al, %al
je 0x10e9b
movb $0x1, 0x15d(%rbx)
movl 0xd8(%rbx), %eax
decl %eax
movl %eax, 0x150(%rbx)
jmp 0x10e97
cmpq %rcx, %rax
jne 0x10e1b
movq 0xf8(%rbx), %rax
cmpq 0x138(%rbx), %rax
jne 0x10e1b
callq 0x93ce
pushq $-0x1
popq %rbp
testb %al, %al
je 0x10e9e
leaq 0xf0(%rbx), %rdi
leaq 0x130(%rbx), %rsi
callq 0x93ce
testb %al, %al
je 0x10e9e
movb $0x1, 0x15d(%rbx)
movl 0xd8(%rbx), %eax
movl 0xf8(%rbx), %ecx
decl %eax
movl %eax, 0x150(%rbx)
decl %ecx
movl %ecx, 0x154(%rbx)
jmp 0x10e97
cmovaq %rcx, %rax
movb $0x0, 0x15d(%rbx)
movslq 0x150(%rbx), %rdx
movq 0xd0(%rbx), %rcx
movq 0x110(%rbx), %rsi
movslq %eax, %rdi
incq %rdx
pushq $-0x1
popq %rbp
cmpq %rdi, %rdx
jge 0x10e8f
movb (%rcx,%rdx), %r8b
leaq 0x1(%rdx), %r9
cmpb (%rsi,%rdx), %r8b
movq %r9, %rdx
je 0x10dfc
jmp 0x10e9e
movb $0x0, 0x15d(%rbx)
xorl %eax, %eax
cmpq $0x2, %rax
je 0x10e85
movq %rax, %rsi
shlq $0x5, %rsi
leaq (%rdi,%rsi), %rdx
addq $0x40, %rdx
movq -0x38(%rdx), %rcx
movq 0x8(%rdx), %r8
cmpq %rcx, %r8
cmovbq %r8, %rcx
addq %rdi, %rsi
movslq 0x150(%rbx,%rax,4), %r9
movslq %ecx, %r8
incq %r9
cmpq %r8, %r9
jge 0x10e77
movq (%rsi), %r10
movb (%r10,%r9), %r10b
movq (%rdx), %r11
leaq 0x1(%r9), %r14
cmpb (%r11,%r9), %r10b
movq %r14, %r9
je 0x10e59
jmp 0x10e85
decl %ecx
movl %ecx, 0x150(%rbx,%rax,4)
incq %rax
jmp 0x10e24
xorl %ebp, %ebp
cmpq $0x2, %rax
sbbl %ebp, %ebp
jmp 0x10e9e
decl %eax
movl %eax, 0x150(%rbx)
xorl %ebp, %ebp
jmp 0x10e9e
pushq $-0x1
popq %rbp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
nop