// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: integer_align_extention(ma_ug_t*, all_ul_t*, long, ul_str_t*, long, ul_str_t*, long, unsigned long*, unsigned long*, integer_aln_t*, long, long*, long*)
void integer_align_extention(ma_ug_t *ug, all_ul_t *ul_idx, int64_t qid, ul_str_t *q_str, int64_t tid, ul_str_t *t_str, int64_t is_rev,
uint64_t *q_cov_buf, uint64_t *t_cov_buf, integer_aln_t *aln_pair, int64_t is_backward, int64_t *r_q_end, int64_t *r_t_end)
{
    int64_t qk, tk, qoff, toff, qlen, tlen, ext, q_end, t_end; uc_block_t *q_b, *t_b;
    qk = (uint32_t)(aln_pair->tn_rev_qk); tk = ((is_rev == 0)? (aln_pair->tk):(t_str->cn - aln_pair->tk - 1));
    q_b = &(ul_idx->a[qid].bb.a[q_str->a[qk]>>32]); t_b = &(ul_idx->a[tid].bb.a[t_str->a[tk]>>32]);
    qlen = ul_idx->a[qid].rlen; tlen = ul_idx->a[tid].rlen;

    if(is_backward) {
        qoff = q_b->qs; toff = (is_rev?(tlen-t_b->qe):(t_b->qs));
    } else {
        qoff = qlen - q_b->qe; toff = (is_rev?(t_b->qs):(tlen-t_b->qe));
    }

    if (qoff <= toff) ext = qoff;
    else ext = toff;
    
    if(is_backward) {
        q_end = estimate_ul_len(ug, &(ul_idx->a[qid]), q_str, qk, -ext, q_cov_buf);
        t_end = estimate_ul_len(ug, &(ul_idx->a[tid]), t_str, tk, ((is_rev)?(ext):(-ext)), t_cov_buf);
    } else {
        q_end = estimate_ul_len(ug, &(ul_idx->a[qid]), q_str, qk, ext, q_cov_buf);
        t_end = estimate_ul_len(ug, &(ul_idx->a[tid]), t_str, tk, ((is_rev)?(-ext):(ext)), t_cov_buf);
    }

    (*r_q_end) = q_end; (*r_t_end) = t_end;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r9, %rbx
movq %rsi, %r14
movq 0x60(%rsp), %r11
movq 0x58(%rsp), %rsi
movq 0x40(%rsp), %rbp
movl 0x10(%rsi), %eax
testq %rbp, %rbp
je 0x1f5436
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
andl 0x18(%rbx), %r9d
movl (%rsi), %esi
notl %esi
addl %r9d, %esi
jmp 0x1f5438
movl (%rsi), %esi
movl %esi, %r15d
movq 0x48(%r14), %r10
imulq $0x58, %rdx, %rdx
leaq (%r10,%rdx), %rsi
movq 0x10(%rcx), %r9
movl 0x4(%r9,%rax,8), %r9d
leaq (%r9,%r9,8), %r9
shlq $0x2, %r9
addq 0x30(%r10,%rdx), %r9
imulq $0x58, %r8, %r13
movq 0x10(%rbx), %rdx
movq %r15, (%rsp)
movl 0x4(%rdx,%r15,8), %edx
leaq (%rdx,%rdx,8), %r8
shlq $0x2, %r8
addq 0x30(%r10,%r13), %r8
movl 0x18(%r10,%r13), %r15d
testq %r11, %r11
je 0x1f5497
movl 0x4(%r9), %edx
testq %rbp, %rbp
je 0x1f54a6
movl 0x8(%r8), %r8d
subq %r8, %r15
jmp 0x1f54aa
movl 0x18(%rsi), %edx
movl 0x8(%r9), %r9d
subq %r9, %rdx
testq %rbp, %rbp
je 0x1f548e
movl 0x4(%r8), %r15d
movq 0x48(%rsp), %r9
cmpq %r15, %rdx
cmovlq %rdx, %r15
testq %r11, %r11
je 0x1f54f5
movq %r15, %rbp
negq %rbp
movq %rcx, %rdx
movq %rax, %rcx
movq %rbp, %r8
movq %rdi, %r12
callq 0x1f520c
addq 0x48(%r14), %r13
movq %rax, %r14
cmpq $0x0, 0x40(%rsp)
cmovneq %r15, %rbp
movq %r12, %rdi
movq %r13, %rsi
movq %rbx, %rdx
movq (%rsp), %rcx
movq %rbp, %r8
jmp 0x1f552a
movq %rcx, %rdx
movq %rax, %rcx
movq %r15, %r8
movq %rdi, %r12
callq 0x1f520c
movq %r14, %rcx
movq %rax, %r14
addq 0x48(%rcx), %r13
movq %r15, %r8
negq %r8
testq %rbp, %rbp
cmoveq %r15, %r8
movq %r12, %rdi
movq %r13, %rsi
movq %rbx, %rdx
movq (%rsp), %rcx
movq 0x50(%rsp), %r9
callq 0x1f520c
movq 0x68(%rsp), %rcx
movq %r14, (%rcx)
movq 0x70(%rsp), %rcx
movq %rax, (%rcx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq