// File: 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
movq %rsp, %rbp
subq $0x90, %rsp
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movl 0x10(%rbp), %eax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movl %r9d, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x18(%rbp), %rax
subq -0x10(%rbp), %rax
addq $0x1, %rax
movl %eax, -0x4c(%rbp)
cvtsi2sdl -0x4c(%rbp), %xmm0
leaq 0x3923eb(%rip), %rax    # 0x3c47f8
mulsd 0xc0(%rax), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x50(%rbp)
cmpl $0x0, -0x50(%rbp)
jne 0x32432
cmpl $0x4, -0x4c(%rbp)
jl 0x32432
movl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x32438
movl -0x50(%rbp), %eax
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %eax
movl %eax, -0x50(%rbp)
movq -0x10(%rbp), %rax
subq -0x20(%rbp), %rax
addq -0x28(%rbp), %rax
movq %rax, -0x58(%rbp)
movl -0x4c(%rbp), %eax
movl -0x50(%rbp), %ecx
shll %ecx
addl %ecx, %eax
cltq
movq %rax, -0x60(%rbp)
movl -0x50(%rbp), %edi
movq -0x58(%rbp), %rsi
movslq -0x30(%rbp), %rdx
movq -0x60(%rbp), %rcx
movq 0x28(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x30(%rbp), %r8
movq (%rax,%r8,8), %r8
leaq -0x44(%rbp), %r9
leaq -0x48(%rbp), %r11
leaq -0x58(%rbp), %r10
leaq -0x68(%rbp), %rax
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x32290
cmpl $0x0, %eax
jne 0x324b1
movl $0x0, -0x4(%rbp)
jmp 0x32541
movq 0x20(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq 0x28(%rbp), %r8
movslq -0x30(%rbp), %r9
movl -0x44(%rbp), %r10d
movl -0x48(%rbp), %eax
xorl %ecx, %ecx
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x32160
movq 0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
movslq -0x4c(%rbp), %rdx
movl 0x10(%rbp), %eax
movq 0x28(%rbp), %r8
movslq -0x2c(%rbp), %r9
movzbl %al, %ecx
callq 0x9a30
movq 0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq 0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movq -0x60(%rbp), %rax
movl %eax, %esi
movq -0x38(%rbp), %rdx
movl -0x4c(%rbp), %ecx
movl -0x50(%rbp), %eax
leaq -0x6c(%rbp), %r9
movzwl %ax, %r8d
callq 0x9c2b0
cmpl $-0x1, -0x6c(%rbp)
je 0x3253a
movl $0x1, -0x4(%rbp)
jmp 0x32541
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)