// File: /workspace/github_cpp_makefile_star2_O3/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 $0x18, %rsp
movq %rdi, %rbp
subl %ebp, %esi
leal 0x1(%rsi), %ebx
cvtsi2sd %ebx, %xmm0
leaq 0x24dda8(%rip), %rax    # 0x295758
mulsd 0xc0(%rax), %xmm0
cvttsd2si %xmm0, %eax
testl %eax, %eax
movl $0x1, %r15d
cmovnel %eax, %r15d
movq 0x68(%rsp), %r10
cmpl $0x4, %ebx
cmovll %eax, %r15d
movq %rdi, %r14
subq %rdx, %r14
addq %rcx, %r14
movslq %r9d, %r9
movq 0x18(%r10), %rax
movq (%rax,%r9,8), %r13
sets %dl
movq %r13, %rcx
subq %r14, %rcx
setle %dil
xorl %eax, %eax
orb %dl, %dil
jne 0x47aeb
leal (%r15,%r15), %edx
leal (%rsi,%r15,2), %esi
incl %esi
movslq %esi, %r12
movslq %edx, %rdx
addq %rdx, %rcx
addq $0x1f, %rcx
cmpq %r12, %rcx
jl 0x47aeb
movq 0x60(%rsp), %rdx
movslq %r15d, %rax
subq %rax, %r14
subq %r14, %r13
cmpq %r12, %r13
cmovgeq %r12, %r13
movl %r12d, %eax
subl %r13d, %eax
movl %eax, 0x4(%rsp)
movl %r14d, %eax
negl %eax
xorl %esi, %esi
testq %r14, %r14
cmovgq %r14, %rsi
cltq
sarq $0x3f, %r14
movl %eax, %ecx
andl %r14d, %ecx
subq %rcx, %r13
andq %rax, %r14
leaq (%rdx,%r14), %rdi
movq %rdi, 0x8(%rsp)
movq %r13, %rdx
xorl %ecx, %ecx
movl %r8d, (%rsp)
movq %r10, %r8
callq 0x32ef8
movq 0x60(%rsp), %rdi
movl $0x4e, %esi
movq %r14, %rdx
callq 0x20e0
addq 0x8(%rsp), %r13
movslq 0x4(%rsp), %rdx
movq %r13, %rdi
movl $0x4e, %esi
callq 0x20e0
movslq %ebx, %rdx
movslq (%rsp), %r9
movl 0x50(%rsp), %eax
movzbl %al, %ecx
movq 0x58(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
movq 0x68(%rsp), %r8
callq 0x32ef8
movzwl %r15w, %r8d
leaq 0x14(%rsp), %r14
movq 0x60(%rsp), %rdi
movl %r12d, %esi
movq %r13, %rdx
movl %ebx, %ecx
movq %r14, %r9
callq 0x84e99
xorl %eax, %eax
cmpl $-0x1, (%r14)
setne %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq