// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Correct.cpp
// Function: gen_clip_win_err(overlap_region*, long, long, long, long, double, long, ul_idx_t const*, char*, UC_Read*, bit_extz_t*)
void gen_clip_win_err(overlap_region *o, int64_t qs, int64_t qe, int64_t ts, int64_t te, double e_rate, 
int64_t estz_err, const ul_idx_t *uref, char* qstr, UC_Read *tu, bit_extz_t *exz)
{
    int64_t ql = qe - qs, tl = te - ts, id = o->y_id, rev = o->y_pos_strand;
    exz->ts = qs; exz->te = qe-1; exz->ps = ts; exz->pe = te-1; 
    exz->cigar.n = 0; exz->thre = exz->err = INT32_MAX; 
    if((!ql) && (!tl)) {
        exz->err = 0; return;
    }
    if((!ql) && (tl)) {
        exz->err = tl; return;
    }
    if((ql) && (!tl)) {
        exz->err = ql; return;
    }
    if(estz_err < 0) estz_err = -1;
    if(hc_aln_exz_simi_adv(id, rev, uref, NULL, NULL, qstr, tu, qs, qe, ts, te, 
                            qs, qe, ts, te, 0, exz, ql, e_rate, MAX_CNS_L, MAX_CNS_E, FORCE_CNS_L, estz_err, NULL, 1)) {
        return;
    } else {
        exz->ts = qs; exz->te = qe-1; exz->ps = ts; exz->pe = te-1; 
        exz->cigar.n = 0; exz->thre = INT32_MAX;
        exz->err = gen_err_unaligned(ql, tl); 
        return;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rcx, %rbx
movq %rsi, %r14
movq %rdi, %rax
movq 0xe8(%rsp), %r15
movl 0x10(%rdi), %edi
movl 0x1c(%rax), %esi
movl %r14d, 0x1c(%r15)
leal -0x1(%rdx), %ebp
movl %ebp, 0x20(%r15)
movl %ebx, 0x10(%r15)
leal -0x1(%r8), %r13d
movl %r13d, 0x14(%r15)
movq $0x0, 0xa8(%r15)
movabsq $0x7fffffff7fffffff, %rax # imm = 0x7FFFFFFF7FFFFFFF
movq %rax, 0x28(%r15)
movq %rdx, %rax
xorq %r14, %rax
movq %r8, %rcx
xorq %rbx, %rcx
xorl %r12d, %r12d
orq %rax, %rcx
je 0x7f934
movq %r8, %r12
subq %rbx, %r12
sete %al
cmpq %r14, %rdx
setne %cl
orb %al, %cl
je 0x7f934
movq %rdx, %r10
subq %r14, %r10
sete %al
cmpq %rbx, %r8
setne %cl
orb %al, %cl
je 0x7f8f4
movq %r10, 0x90(%rsp)
movq 0xe0(%rsp), %r10
movq 0xd8(%rsp), %rax
movq 0xd0(%rsp), %rcx
testq %r9, %r9
movq $-0x1, %r11
cmovnsq %r9, %r11
xorl %r9d, %r9d
movq %r9, 0x80(%rsp)
movq %r15, 0x50(%rsp)
movq %r9, 0x48(%rsp)
movq %r8, 0x40(%rsp)
movq %rbx, 0x38(%rsp)
movq %rdx, 0x30(%rsp)
movq %r14, 0x28(%rsp)
movq %r8, 0x20(%rsp)
movq %rbx, 0x18(%rsp)
movq %rdx, 0x10(%rsp)
movq %r14, 0x8(%rsp)
movq %r10, (%rsp)
movq %r11, 0x78(%rsp)
movq $0x1, 0x88(%rsp)
movq $0x100, 0x70(%rsp)      # imm = 0x100
movq $0x3ff, 0x68(%rsp)      # imm = 0x3FF
movq $0xc00, 0x60(%rsp)      # imm = 0xC00
movq %rcx, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %rax, %r9
callq 0x7db99
testq %rax, %rax
jne 0x7f938
movl %r14d, 0x1c(%r15)
movl %ebp, 0x20(%r15)
movl %ebx, 0x10(%r15)
movl %r13d, 0x14(%r15)
movq $0x0, 0xa8(%r15)
movl $0x7fffffff, 0x28(%r15) # imm = 0x7FFFFFFF
movq 0x90(%rsp), %rax
cmpq $0x200, %rax            # imm = 0x200
jg 0x7f8f9
cmpq %r12, %rax
cmovgq %rax, %r12
cvtsi2sd %r12, %xmm0
jmp 0x7f92f
movl %r10d, %r12d
jmp 0x7f934
cmpq %r12, %rax
cmovlq %rax, %r12
cvtsi2sd %r12, %xmm1
cvtsi2sd %rax, %xmm2
mulsd 0x1a5c36(%rip), %xmm2   # 0x225548
addsd 0x1a5956(%rip), %xmm2   # 0x225270
movapd %xmm2, %xmm0
cmplesd %xmm1, %xmm0
andpd %xmm0, %xmm1
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
cvttsd2si %xmm0, %r12d
movl %r12d, 0x2c(%r15)
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq