// File: /workspace/github_cpp_makefile_star2_O3/readmapping[P]alfalfa/src/mapper.cpp
// Function: dpWindow(long, long, bool, bool, int, paired_opt const&, long&, long&, bool&)
bool dpWindow(long mateRefB, long mateRefE, bool mateIsFirst, bool mateIsFw, 
        int Plength, const paired_opt& options, long & refB, long & refE, 
        bool& otherFW){
    //FIND VALUE OF OTHER ALNS BEGIN, ORIENTATION and IF ALN IS BEFORE OR AFTER THIS ONE
    long refBmate = mateIsFw ? mateRefB : mateRefE;
    bool rightWindow;
    if(options.orientation == PAIR_FF){
        rightWindow = mateIsFirst ? mateIsFw : !mateIsFw;
        otherFW = mateIsFw;
    }
    else if(options.orientation == PAIR_FR){
        rightWindow = mateIsFw;
        otherFW = !mateIsFw;
    }
    else{
        rightWindow = !mateIsFw;
        otherFW = !mateIsFw;
    }
    //FIND BASIC WINDOW VALUES
    if(rightWindow){
        refB = refBmate + options.minInsert;
        refE = refBmate + options.maxInsert;
    }
    else{
        refB = refBmate - options.maxInsert;
        refE = refBmate - options.minInsert;
    }
    if(otherFW)
        refE += Plength;
    else
        refB -= Plength;
    //ADJUST TO OVERLAP AND DOVETAIL
    if(!options.overlap){
        if(rightWindow)
            refB = max(refB, mateRefE);
        else
            refE = min(refE, mateRefB);
    }
    if(!options.dovetail){
        if(rightWindow)
            refB = max(refB, mateRefB);
        else
            refE = min(refE, mateRefE);
    }
    //RETURN IF WINDOW IS LARGE ENOUGH
    return refE > refB;
}

// Assembly:
pushq %rbp
pushq %rbx
movq 0x28(%rsp), %rbx
movq 0x20(%rsp), %r10
movq 0x18(%rsp), %rax
testl %ecx, %ecx
movq %rsi, %r11
cmovneq %rdi, %r11
movl 0x18(%r9), %ebp
testl %ebp, %ebp
je 0x25ed9
cmpl $0x2, %ebp
jne 0x25ef8
movb %cl, (%rbx)
cmpb %cl, %dl
je 0x25f1c
movslq 0x4(%r9), %rdx
movq %r11, %rbx
subq %rdx, %rbx
movq %rbx, (%rax)
movslq (%r9), %rdx
subq %rdx, %r11
movq %r11, (%r10)
xorl %edx, %edx
jmp 0x25f31
movl %ecx, %edx
xorb $0x1, %dl
movb %dl, (%rbx)
testb %cl, %cl
je 0x25f3d
movslq (%r9), %rcx
addq %rdi, %rcx
movq %rcx, (%rax)
movslq 0x4(%r9), %rcx
addq %rdi, %rcx
movb $0x1, %dl
jmp 0x25f17
xorb $0x1, %cl
movb %cl, (%rbx)
jne 0x25f57
movslq 0x4(%r9), %rcx
movq %rdi, %rdx
subq %rcx, %rdx
movq %rdx, (%rax)
movslq (%r9), %rdx
movq %rdi, %rcx
subq %rdx, %rcx
xorl %edx, %edx
movq %rcx, (%r10)
jmp 0x25f35
movslq (%r9), %rdx
addq %r11, %rdx
movq %rdx, (%rax)
movslq 0x4(%r9), %rdx
addq %rdx, %r11
movq %r11, (%r10)
movb $0x1, %dl
testb %cl, %cl
jne 0x25f69
movslq %r8d, %rcx
subq %rcx, (%rax)
jmp 0x25f72
movslq 0x4(%r9), %rcx
movq %rsi, %rdx
subq %rcx, %rdx
movq %rdx, (%rax)
movslq (%r9), %rcx
movq %rsi, %r11
subq %rcx, %r11
xorl %edx, %edx
jmp 0x25f69
movslq (%r9), %rcx
addq %rsi, %rcx
movq %rcx, (%rax)
movslq 0x4(%r9), %r11
addq %rsi, %r11
movb $0x1, %dl
movslq %r8d, %rcx
addq %r11, %rcx
movq %rcx, (%r10)
cmpb $0x0, 0xc(%r9)
je 0x25f89
cmpb $0x0, 0xa(%r9)
jne 0x25fd0
testb %dl, %dl
je 0x25fc3
movq (%rax), %rsi
jmp 0x25fa1
testb %dl, %dl
je 0x25fad
movq (%rax), %rcx
cmpq %rsi, %rcx
cmovgq %rcx, %rsi
movq %rsi, (%rax)
cmpb $0x0, 0xa(%r9)
jne 0x25fd0
cmpq %rdi, %rsi
cmovgq %rsi, %rdi
movq %rdi, (%rax)
jmp 0x25fd0
movq (%r10), %rcx
cmpq %rdi, %rcx
cmovlq %rcx, %rdi
movq %rdi, (%r10)
cmpb $0x0, 0xa(%r9)
je 0x25fc6
jmp 0x25fd0
movq (%r10), %rdi
cmpq %rsi, %rdi
cmovlq %rdi, %rsi
movq %rsi, (%r10)
movq (%r10), %rcx
cmpq (%rax), %rcx
setg %al
popq %rbx
popq %rbp
retq