// File: 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
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x30(%rbp)
movq %rsi, -0x38(%rbp)
movq %rdx, -0x40(%rbp)
movq %rcx, -0x48(%rbp)
movq %r8, -0x50(%rbp)
movsd %xmm0, -0x58(%rbp)
movq %r9, -0x60(%rbp)
movq -0x40(%rbp), %rax
subq -0x38(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x50(%rbp), %rax
subq -0x48(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x30(%rbp), %rax
movl 0x10(%rax), %eax
movq %rax, -0x78(%rbp)
movq -0x30(%rbp), %rax
movl 0x1c(%rax), %eax
movq %rax, -0x80(%rbp)
movq -0x38(%rbp), %rax
movl %eax, %ecx
movq 0x28(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x40(%rbp), %rax
subq $0x1, %rax
movl %eax, %ecx
movq 0x28(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x48(%rbp), %rax
movl %eax, %ecx
movq 0x28(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x50(%rbp), %rax
subq $0x1, %rax
movl %eax, %ecx
movq 0x28(%rbp), %rax
movl %ecx, 0x14(%rax)
movq 0x28(%rbp), %rax
movq $0x0, 0xa8(%rax)
movq 0x28(%rbp), %rax
movl $0x7fffffff, 0x2c(%rax) # imm = 0x7FFFFFFF
movq 0x28(%rbp), %rax
movl $0x7fffffff, 0x28(%rax) # imm = 0x7FFFFFFF
cmpq $0x0, -0x68(%rbp)
jne 0x9184e
cmpq $0x0, -0x70(%rbp)
jne 0x9184e
movq 0x28(%rbp), %rax
movl $0x0, 0x2c(%rax)
jmp 0x91b17
cmpq $0x0, -0x68(%rbp)
jne 0x9186e
cmpq $0x0, -0x70(%rbp)
je 0x9186e
movq -0x70(%rbp), %rax
movl %eax, %ecx
movq 0x28(%rbp), %rax
movl %ecx, 0x2c(%rax)
jmp 0x91b17
cmpq $0x0, -0x68(%rbp)
je 0x9188e
cmpq $0x0, -0x70(%rbp)
jne 0x9188e
movq -0x68(%rbp), %rax
movl %eax, %ecx
movq 0x28(%rbp), %rax
movl %ecx, 0x2c(%rax)
jmp 0x91b17
cmpq $0x0, -0x60(%rbp)
jge 0x9189d
movq $-0x1, -0x60(%rbp)
movq -0x78(%rbp), %rdi
movq -0x80(%rbp), %rsi
movq 0x10(%rbp), %rdx
movq 0x18(%rbp), %r9
movq 0x20(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, -0xa0(%rbp)
movq -0x40(%rbp), %rcx
movq %rcx, -0x98(%rbp)
movq -0x48(%rbp), %rcx
movq %rcx, -0x90(%rbp)
movq -0x50(%rbp), %r13
movq -0x38(%rbp), %r12
movq -0x40(%rbp), %r15
movq -0x48(%rbp), %r14
movq -0x50(%rbp), %rbx
movq 0x28(%rbp), %r11
movq -0x68(%rbp), %r10
movsd -0x58(%rbp), %xmm0
movq -0x60(%rbp), %rcx
movq %rcx, -0x88(%rbp)
xorl %ecx, %ecx
movl %ecx, %r8d
movq %r8, %rcx
movq %rax, (%rsp)
movq -0xa0(%rbp), %rax
movq %rax, 0x8(%rsp)
movq -0x98(%rbp), %rax
movq %rax, 0x10(%rsp)
movq -0x90(%rbp), %rax
movq %rax, 0x18(%rsp)
movq -0x88(%rbp), %rax
movq %r13, 0x20(%rsp)
movq %r12, 0x28(%rsp)
movq %r15, 0x30(%rsp)
movq %r14, 0x38(%rsp)
movq %rbx, 0x40(%rsp)
movq $0x0, 0x48(%rsp)
movq %r11, 0x50(%rsp)
movq %r10, 0x58(%rsp)
movq $0xc00, 0x60(%rsp)      # imm = 0xC00
movq $0x3ff, 0x68(%rsp)      # imm = 0x3FF
movq $0x100, 0x70(%rsp)      # imm = 0x100
movq %rax, 0x78(%rsp)
movq $0x0, 0x80(%rsp)
movq $0x1, 0x88(%rsp)
callq 0x8e630
cmpq $0x0, %rax
je 0x919a9
jmp 0x91b17
movq -0x38(%rbp), %rax
movl %eax, %ecx
movq 0x28(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x40(%rbp), %rax
subq $0x1, %rax
movl %eax, %ecx
movq 0x28(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x48(%rbp), %rax
movl %eax, %ecx
movq 0x28(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x50(%rbp), %rax
subq $0x1, %rax
movl %eax, %ecx
movq 0x28(%rbp), %rax
movl %ecx, 0x14(%rax)
movq 0x28(%rbp), %rax
movq $0x0, 0xa8(%rax)
movq 0x28(%rbp), %rax
movl $0x7fffffff, 0x28(%rax) # imm = 0x7FFFFFFF
cmpq $0x200, -0x68(%rbp)     # imm = 0x200
jg 0x91a44
movq -0x68(%rbp), %rax
cmpq -0x70(%rbp), %rax
jl 0x91a20
movq -0x68(%rbp), %rax
movq %rax, -0xa8(%rbp)
jmp 0x91a2b
movq -0x70(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0xb0(%rbp)
jmp 0x91b04
movq -0x68(%rbp), %rax
cmpq -0x70(%rbp), %rax
jg 0x91a5b
movq -0x68(%rbp), %rax
movq %rax, -0xb8(%rbp)
jmp 0x91a66
movq -0x70(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
cvtsi2sd %rax, %xmm0
cvtsi2sdq -0x68(%rbp), %xmm1
movsd 0x2f0838(%rip), %xmm2   # 0x3822b8
mulsd %xmm2, %xmm1
movsd 0x2f0574(%rip), %xmm2   # 0x382000
addsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jb 0x91ace
movq -0x68(%rbp), %rax
cmpq -0x70(%rbp), %rax
jg 0x91aad
movq -0x68(%rbp), %rax
movq %rax, -0xc0(%rbp)
jmp 0x91ab8
movq -0x70(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0xc8(%rbp)
jmp 0x91af4
cvtsi2sdq -0x68(%rbp), %xmm0
movsd 0x2f07dc(%rip), %xmm1   # 0x3822b8
mulsd %xmm1, %xmm0
movsd 0x2f0518(%rip), %xmm1   # 0x382000
addsd %xmm1, %xmm0
movsd %xmm0, -0xc8(%rbp)
movsd -0xc8(%rbp), %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd -0xb0(%rbp), %xmm0
cvttsd2si %xmm0, %ecx
movq 0x28(%rbp), %rax
movl %ecx, 0x2c(%rax)
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)