// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Correct.cpp
// Function: cal_exact_simi_exz(ul_idx_t const*, hpc_t*, All_reads*, bit_extz_t*, char*, UC_Read*, long, long, long, long, long*, long*, long, long, int, int, long, overlap_region*)
int64_t cal_exact_simi_exz(const ul_idx_t *uref, hpc_t *hpc_g, All_reads *rref, 
bit_extz_t *exz, char* qstr, UC_Read *tu, int64_t qs, int64_t qe, int64_t ts, int64_t te, 
int64_t *pts, int64_t *pte, int64_t q_tot_l, int64_t t_tot_l, int32_t rev, int32_t id, 
int64_t mode, overlap_region *z)
{
    clear_align(*exz); exz->thre = 0; exz->cigar.n = 0;
    int64_t ql, tl; char *q_string, *t_string; ql = qe - qs;

    if(mode == 3 && z) {//semi
        ts = (qs - z->x_pos_s) + z->y_pos_s; ts += y_start_offset(qs, &(z->f_cigar));
        te = ts + ql; 
    } else if(mode == 1) {///forward extension
        te = ts + ql; 
    } else if(mode == 2) {///backward extension
        ts = te - ql; 
    }
    if(ts < 0) ts = 0;
    if(ts > t_tot_l) ts = t_tot_l;
    if(te > t_tot_l) te = t_tot_l;
    ql = qe - qs; tl = te - ts; 
    if(ql != tl) return 0;

    q_string = qstr + qs; 
    t_string = retrieve_str_seq_exz(tu, ts, tl, (*pts), (*pte)-(*pts), rev, uref, hpc_g, rref, id);
    (*pts) = ts; (*pte) = te;

    if(memcmp(q_string, t_string, ql)) return 0;
    exz->err = 0; push_trace(&(exz->cigar), 0, ql);
    exz->pl = tl; exz->ps = 0; exz->pe = tl-1;
    exz->tl = ql; exz->ts = 0; exz->te = ql-1;
    
    exz->ps += ts; exz->pe += ts;
    exz->ts += qs; exz->te += qs;
    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, %r10
movq %rcx, %rbx
movq %rdx, 0x38(%rsp)
movq %rdi, 0x40(%rsp)
movq 0xd8(%rsp), %r13
movq 0xd0(%rsp), %rax
movq 0x80(%rsp), %r14
movq 0x88(%rsp), %r15
movabsq $0x7fffffff00000000, %rcx # imm = 0x7FFFFFFF00000000
movq %rcx, 0x28(%rbx)
movq $0x0, 0xa8(%rbx)
subq %r14, %r15
cmpq $0x3, %rax
setne %cl
testq %r13, %r13
sete %dl
orb %cl, %dl
jne 0x65494
movq %rsi, 0x18(%rsp)
movq %r10, 0x20(%rsp)
movq %r8, 0x10(%rsp)
movl 0x4(%r13), %eax
movq %rax, 0x28(%rsp)
movl 0x14(%r13), %eax
movq %rax, 0x30(%rsp)
leaq 0x38(%r13), %rbp
movl 0x40(%r13), %esi
decl %esi
movq %rbp, %rdi
callq 0x3d110
cltq
movl 0x40(%r13), %r12d
cmpq %r14, %rax
jne 0x654c0
movq %r14, %rcx
movq %r15, %r14
jmp 0x65518
movq 0x98(%rsp), %rcx
cmpq $0x2, %rax
je 0x654f7
movq 0x90(%rsp), %r12
cmpq $0x1, %rax
movq %r15, %r14
jne 0x6554f
leaq (%r14,%r12), %rcx
jmp 0x6554f
testl %r12d, %r12d
je 0x657f4
movq %r15, %r14
xorl %r12d, %r12d
movq %rbp, %rdi
movl %r12d, %esi
callq 0x3d110
movq 0x80(%rsp), %rcx
cltq
cmpq %rcx, %rax
jg 0x65502
incq %r12
movl 0x40(%r13), %eax
cmpq %rax, %r12
jb 0x654cf
jmp 0x6550f
movq %rcx, %r12
movq %r15, %r14
subq %r15, %r12
jmp 0x6554f
testq %r12, %r12
je 0x657f4
movl 0x40(%r13), %eax
cmpq %rax, %r12
je 0x657f4
movq %rcx, %rax
subq 0x28(%rsp), %rax
movq 0x30(%rsp), %r15
addq %rax, %r15
decl %r12d
movq %rbp, %rdi
movl %r12d, %esi
callq 0x3d11b
movslq %eax, %r12
addq %r15, %r12
leaq (%r12,%r14), %rcx
movq 0x10(%rsp), %r8
movq 0x20(%rsp), %r10
movq 0x18(%rsp), %rsi
xorl %eax, %eax
testq %r12, %r12
cmovleq %rax, %r12
movq 0xb8(%rsp), %r15
cmpq %r15, %r12
cmovgeq %r15, %r12
cmpq %r15, %rcx
cmovlq %rcx, %r15
movq %r15, %rcx
subq %r12, %rcx
cmpq %rcx, %r14
jne 0x657e5
movl 0xc0(%rsp), %r11d
movq 0xa8(%rsp), %rdx
movq 0xa0(%rsp), %rdi
addq 0x80(%rsp), %r8
movslq 0xc8(%rsp), %rbp
testq %rsi, %rsi
je 0x655d5
movq (%rsi), %rax
movq 0x10(%rax), %rax
leaq (,%rbp,4), %rcx
addq %rbp, %rcx
movq 0x20(%rax,%rcx,8), %rsi
testb %r11b, %r11b
je 0x65636
leaq (%rax,%rcx,8), %rax
movl (%rax), %eax
shrl %eax
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
jmp 0x65638
movq (%rdi), %r13
movq (%rdx), %rcx
movq %r14, 0x8(%r10)
movq (%r10), %rsi
cmpq %r14, 0x10(%r10)
movq %r8, 0x10(%rsp)
jge 0x6561e
movq %rsi, %rdi
movq %r14, %rsi
movq %r10, 0x20(%rsp)
movq %rcx, 0x18(%rsp)
callq 0x2370
movq 0x18(%rsp), %rcx
movl 0xc0(%rsp), %r11d
movq 0x20(%rsp), %r10
movq %rax, %rsi
movq %rax, (%r10)
movq %r14, 0x10(%r10)
cmpq %r13, %r12
jne 0x65640
subq %r13, %rcx
movq %r14, %r9
subq %rcx, %r9
jle 0x656a7
addq %rcx, %rsi
addq %r12, %rcx
jmp 0x65646
xorl %eax, %eax
addq %r12, %rax
addq %rax, %rsi
jmp 0x656bc
movq %r12, %rcx
movq %r14, %r9
movq %r10, %r13
movq 0x40(%rsp), %rax
testq %rax, %rax
je 0x65681
movq (%rax), %rax
leaq (,%rbp,4), %rdx
addq %rbp, %rdx
shlq $0x3, %rdx
addq 0x10(%rax), %rdx
movq $0x0, (%rsp)
movq %rcx, %r8
movzbl %r11b, %ecx
xorl %edi, %edi
callq 0x36049
jmp 0x656a3
movq 0x38(%rsp), %r8
testq %r8, %r8
je 0x656a3
movq %rcx, %rax
movzbl %r11b, %ecx
movq %rsi, %rdi
movq %rax, %rsi
movq %r9, %rdx
movq %rbp, %r9
callq 0x32ef8
movq (%r13), %rsi
movq 0x10(%rsp), %r8
movq 0xa8(%rsp), %rdx
movq 0xa0(%rsp), %rdi
movq %r12, (%rdi)
movq %r15, (%rdx)
movq %r8, %rdi
movq %r14, %rdx
callq 0x21a0
testl %eax, %eax
je 0x656d8
xorl %eax, %eax
jmp 0x657e5
movl $0x0, 0x2c(%rbx)
movl %r14d, %ebp
cmpl $0x3fff, %r14d          # imm = 0x3FFF
jb 0x65758
movq 0xa8(%rbx), %rcx
movq 0xb8(%rbx), %rax
movl $0x2, %r15d
movl %r14d, %ebp
cmpq 0xb0(%rbx), %rcx
jne 0x65736
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
cmoveq %r15, %rsi
movq %rsi, 0xb0(%rbx)
addq %rsi, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0xb8(%rbx)
movq 0xa8(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0xa8(%rbx)
movw $0x3fff, (%rax,%rcx,2)  # imm = 0x3FFF
addl $0xffffc001, %ebp       # imm = 0xFFFFC001
movq %rdx, %rcx
cmpl $0x3ffe, %ebp           # imm = 0x3FFE
ja 0x65702
testl %ebp, %ebp
je 0x657b8
movq 0xa8(%rbx), %rcx
cmpq 0xb0(%rbx), %rcx
jne 0x657a2
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
movl $0x2, %esi
cmovneq %rax, %rsi
movq %rsi, 0xb0(%rbx)
movq 0xb8(%rbx), %rdi
addq %rsi, %rsi
callq 0x2370
movq %rax, 0xb8(%rbx)
movq 0xa8(%rbx), %rcx
jmp 0x657a9
movq 0xb8(%rbx), %rax
leaq 0x1(%rcx), %rdx
movq %rdx, 0xa8(%rbx)
movw %bp, (%rax,%rcx,2)
movl %r14d, 0x18(%rbx)
movl %r14d, 0x24(%rbx)
movl %r12d, 0x10(%rbx)
leal (%r14,%r12), %eax
decl %eax
movl %eax, 0x14(%rbx)
movq 0x80(%rsp), %rax
movl %eax, 0x1c(%rbx)
addl %r14d, %eax
decl %eax
movl %eax, 0x20(%rbx)
movl $0x1, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x6084