// File: chhylp123[P]hifiasm/Correct.cpp
// Function: verify_ul_sub_window(ul_idx_t const*, Correct_dumy*, UC_Read*, long long, long long, long long, long long, unsigned long, unsigned long, int, int, unsigned int*, int*, int*, int*)
inline int verify_ul_sub_window(const ul_idx_t *uref, Correct_dumy* dumy, UC_Read* g_read, 
long long x_beg, long long xLen, long long y_beg, long long yLen, uint64_t y_id, 
uint64_t y_pos_strand, int threshold, int alignment_strand,
unsigned int* get_error, int* get_y_end, int* get_x_end, int* get_aligned_xLen)
{
    (*get_aligned_xLen) = 0;
    (*get_y_end) = -1;
    (*get_x_end) = -1;
    (*get_error) = (unsigned int)-1;

    int extra_begin, extra_end, r_x_end, r_y_end, aligned_xLen;
    long long o_len;
    unsigned int r_error;
    if(!determine_overlap_region(threshold, y_beg, y_id, yLen, 
    uref->ug->u.a[y_id].len, &extra_begin, &extra_end, &y_beg, &o_len))
    {
        return 0;
    }

    fill_subregion_ul(dumy->overlap_region, y_beg, o_len, y_pos_strand, uref, 
    y_id, extra_begin, extra_end);

    // if(y_id == 6) {
    //     fprintf(stderr, "-[M::%s::aln_dir->%d] qs->%lld, ts->%lld, thres->%d, aux_beg->%d, aux_end->%d, t_pri_l->%lld\n", 
    //     __func__, alignment_strand, x_beg, y_beg, threshold, extra_begin, extra_end, o_len);
    // }

    char* x_string = g_read->seq + x_beg;
    char* y_string = dumy->overlap_region;

    aligned_xLen = 0;

    alignment_extension(y_string, yLen, x_string, xLen, threshold, 
                    alignment_strand, &r_error, &r_y_end, &r_x_end, &aligned_xLen);
    
    (*get_error) = r_error;
    (*get_y_end) = r_y_end;
    (*get_x_end) = r_x_end;
    (*get_aligned_xLen) = aligned_xLen;

    if(aligned_xLen == 0)
    {
        return 0;
    }
    else
    {
        return 1;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x98, %rsp
movq 0x50(%rbp), %rax
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movl 0x30(%rbp), %eax
movl 0x28(%rbp), %eax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movq %r8, -0x38(%rbp)
movq %r9, -0x40(%rbp)
movq 0x50(%rbp), %rax
movl $0x0, (%rax)
movq 0x40(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq 0x48(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq 0x38(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movl 0x28(%rbp), %edi
movq -0x40(%rbp), %rsi
movq 0x18(%rbp), %rdx
movq 0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
imulq $0x28, 0x18(%rbp), %r8
addq %r8, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %r8d
leaq -0x44(%rbp), %r9
leaq -0x48(%rbp), %r11
leaq -0x40(%rbp), %r10
leaq -0x60(%rbp), %rax
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x32290
cmpl $0x0, %eax
jne 0xc5260
movl $0x0, -0xc(%rbp)
jmp 0xc533c
movq -0x20(%rbp), %rdi
addq $0x50, %rdi
movq -0x40(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq 0x20(%rbp), %rax
movb %al, %cl
movq -0x18(%rbp), %r8
movq 0x18(%rbp), %r9
movl -0x44(%rbp), %r10d
movl -0x48(%rbp), %eax
movzbl %cl, %ecx
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x321f0
movq -0x28(%rbp), %rax
movq (%rax), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x20(%rbp), %rax
addq $0x50, %rax
movq %rax, -0x78(%rbp)
movl $0x0, -0x54(%rbp)
movq -0x78(%rbp), %rdi
movq 0x10(%rbp), %rax
movl %eax, %esi
movq -0x70(%rbp), %rdx
movq -0x38(%rbp), %rax
movl %eax, %ecx
movl 0x28(%rbp), %eax
movw %ax, %r8w
movl 0x30(%rbp), %r9d
leaq -0x64(%rbp), %rbx
leaq -0x50(%rbp), %r11
leaq -0x4c(%rbp), %r10
leaq -0x54(%rbp), %rax
movzwl %r8w, %r8d
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0xc5350
movl -0x64(%rbp), %ecx
movq 0x38(%rbp), %rax
movl %ecx, (%rax)
movl -0x50(%rbp), %ecx
movq 0x40(%rbp), %rax
movl %ecx, (%rax)
movl -0x4c(%rbp), %ecx
movq 0x48(%rbp), %rax
movl %ecx, (%rax)
movl -0x54(%rbp), %ecx
movq 0x50(%rbp), %rax
movl %ecx, (%rax)
cmpl $0x0, -0x54(%rbp)
jne 0xc5335
movl $0x0, -0xc(%rbp)
jmp 0xc533c
movl $0x1, -0xc(%rbp)
movl -0xc(%rbp), %eax
addq $0x98, %rsp
popq %rbx
popq %rbp
retq
nopl (%rax)