// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Correct.cpp
// Function: verify_single_window(long long, long long, long long, long long, int, int, int, char*, char*, All_reads*)
int verify_single_window(long long x_start, long long x_end, 
long long overlap_x_s, long long overlap_y_s, int x_id,
int y_id, int x_strand, char* x_buffer, char* y_buffer,
All_reads* R_INF)
{
    char* x_string = NULL;
    char* y_string = NULL;
    int extra_begin, extra_end, x_len, threshold;
    long long y_start;
    long long Window_Len, o_len;
    unsigned int error;

    

    x_len = x_end - x_start + 1;
    threshold = x_len * asm_opt.max_ov_diff_ec;
    /****************************may have bugs********************************/
    threshold = Adjust_Threshold(threshold, x_len);
    /****************************may have bugs********************************/
        
    y_start = (x_start - overlap_x_s) + overlap_y_s;
    
    Window_Len = x_len + (threshold << 1);

    if(!determine_overlap_region(threshold, y_start, y_id, Window_Len, Get_READ_LENGTH((*R_INF), y_id),
    &extra_begin, &extra_end, &y_start, &o_len))
    {
        return 0;
    }

    ///use unusual direction here
    /**
    fill_subregion(y_buffer, y_start, o_len, y_strand, R_INF, y_id, extra_begin, extra_end);
    ///x is always forward strand
    recover_UC_Read_sub_region(x_buffer, x_start, x_len, 0, R_INF, x_id);
    **/
   ///use unusual direction here, here y is always forward strand
    fill_subregion(y_buffer, y_start, o_len, 0, R_INF, y_id, extra_begin, extra_end);
    recover_UC_Read_sub_region(x_buffer, x_start, x_len, x_strand, R_INF, x_id);


    x_string = x_buffer;
    y_string = y_buffer;

    Reserve_Banded_BPM(y_string, Window_Len, x_string, x_len, threshold, &error);

    if (error!=(unsigned int)-1)
    {
        return 1;
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, 0x4(%rsp)
movq %rdi, %r14
subl %r14d, %esi
leal 0x1(%rsi), %ebx
cvtsi2sd %ebx, %xmm0
leaq 0x238183(%rip), %rax    # 0x253758
mulsd 0xc0(%rax), %xmm0
movq 0x78(%rsp), %r12
cvttsd2si %xmm0, %eax
testl %eax, %eax
pushq $0x1
popq %r15
cmovnel %eax, %r15d
cmpl $0x4, %ebx
cmovll %eax, %r15d
movq %rdi, %rax
subq %rdx, %rax
addq %rcx, %rax
leaq 0x18(%rsp), %rdx
movq %rax, (%rdx)
leal (%rsi,%r15,2), %r13d
incl %r13d
movslq %r13d, %rcx
movslq %r9d, %rbp
movq 0x18(%r12), %rsi
movq (%rsi,%rbp,8), %r8
subq $0x8, %rsp
leaq 0x18(%rsp), %r10
leaq 0x10(%rsp), %r11
leaq 0x14(%rsp), %r9
movl %r15d, %edi
movq %rax, %rsi
pushq %r10
pushq %rdx
pushq %r11
callq 0x1b53a
addq $0x20, %rsp
testl %eax, %eax
je 0x1b6be
movq 0x70(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %rdx
movl 0xc(%rsp), %eax
movl 0x8(%rsp), %r10d
xorl %ecx, %ecx
movq %r12, %r8
movq %rbp, %r9
pushq %r10
pushq %rax
callq 0x1b475
popq %rax
popq %rcx
movslq %ebx, %rdx
movslq 0x4(%rsp), %r9
movl 0x60(%rsp), %eax
movzbl %al, %ecx
movq 0x68(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
movq %r12, %r8
callq 0x6c9e
movzwl %r15w, %r8d
leaq 0x24(%rsp), %r14
movq 0x70(%rsp), %rdi
movl %r13d, %esi
movq %rbp, %rdx
movl %ebx, %ecx
movq %r14, %r9
callq 0x516e4
xorl %eax, %eax
cmpl $-0x1, (%r14)
setne %al
jmp 0x1b6c0
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq