// File: 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
movq %rsp, %rbp
subq $0xf0, %rsp
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq 0x28(%rbp), %rax
movq 0x10(%rax), %rax
movl %eax, %eax
movq %rax, -0x38(%rbp)
cmpq $0x0, 0x10(%rbp)
jne 0x32bd12
movq 0x28(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x8c(%rbp)
jmp 0x32bd2d
movq -0x30(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq 0x28(%rbp), %rcx
subl (%rcx), %eax
subl $0x1, %eax
movl %eax, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
movl %eax, %eax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
imulq $0x58, -0x18(%rbp), %rcx
addq %rcx, %rax
movq 0x30(%rax), %rax
movq -0x20(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x38(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
imulq $0x58, -0x28(%rbp), %rcx
addq %rcx, %rax
movq 0x30(%rax), %rax
movq -0x30(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x40(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
imulq $0x58, -0x18(%rbp), %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
imulq $0x58, -0x28(%rbp), %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movq %rax, -0x60(%rbp)
cmpq $0x0, 0x30(%rbp)
je 0x32be21
movq -0x80(%rbp), %rax
movl 0x4(%rax), %eax
movq %rax, -0x48(%rbp)
cmpq $0x0, 0x10(%rbp)
je 0x32be03
movq -0x60(%rbp), %rax
movq -0x88(%rbp), %rcx
movl 0x8(%rcx), %ecx
subq %rcx, %rax
movq %rax, -0x98(%rbp)
jmp 0x32be14
movq -0x88(%rbp), %rax
movl 0x4(%rax), %eax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x32be70
movq -0x58(%rbp), %rax
movq -0x80(%rbp), %rcx
movl 0x8(%rcx), %ecx
subq %rcx, %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, 0x10(%rbp)
je 0x32be4d
movq -0x88(%rbp), %rax
movl 0x4(%rax), %eax
movq %rax, -0xa0(%rbp)
jmp 0x32be65
movq -0x60(%rbp), %rax
movq -0x88(%rbp), %rcx
movl 0x8(%rcx), %ecx
subq %rcx, %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
jg 0x32be84
movq -0x48(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x32be8c
movq -0x50(%rbp), %rax
movq %rax, -0x68(%rbp)
cmpq $0x0, 0x30(%rbp)
je 0x32bf57
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rsi
imulq $0x58, -0x18(%rbp), %rax
addq %rax, %rsi
movq -0x20(%rbp), %rdx
movq -0x38(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r8d
subq -0x68(%rbp), %r8
movq 0x18(%rbp), %r9
callq 0x32b4e0
movq %rax, -0x70(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
imulq $0x58, -0x28(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0xb8(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0xa8(%rbp)
cmpq $0x0, 0x10(%rbp)
je 0x32bf15
movq -0x68(%rbp), %rax
movq %rax, -0xc8(%rbp)
jmp 0x32bf22
xorl %eax, %eax
subq -0x68(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xa8(%rbp), %rcx
movq -0xb0(%rbp), %rdx
movq -0xb8(%rbp), %rsi
movq -0xc0(%rbp), %rdi
movq -0xc8(%rbp), %r8
movq 0x20(%rbp), %r9
callq 0x32b4e0
movq %rax, -0x78(%rbp)
jmp 0x32c00d
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rsi
imulq $0x58, -0x18(%rbp), %rax
addq %rax, %rsi
movq -0x20(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x68(%rbp), %r8
movq 0x18(%rbp), %r9
callq 0x32b4e0
movq %rax, -0x70(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
imulq $0x58, -0x28(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0xe0(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0xd0(%rbp)
cmpq $0x0, 0x10(%rbp)
je 0x32bfd2
xorl %eax, %eax
subq -0x68(%rbp), %rax
movq %rax, -0xf0(%rbp)
jmp 0x32bfdd
movq -0x68(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0xd0(%rbp), %rcx
movq -0xd8(%rbp), %rdx
movq -0xe0(%rbp), %rsi
movq -0xe8(%rbp), %rdi
movq -0xf0(%rbp), %r8
movq 0x20(%rbp), %r9
callq 0x32b4e0
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rcx
movq 0x38(%rbp), %rax
movq %rcx, (%rax)
movq -0x78(%rbp), %rcx
movq 0x40(%rbp), %rax
movq %rcx, (%rax)
addq $0xf0, %rsp
popq %rbp
retq
nopl (%rax)