// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Correct.cpp
// Function: get_rid_backward_cigar_err_back(rtrace_iter*, ul_ov_t*, kv_rtrace_t*, rtrace_t*, ul_idx_t const*, char*, UC_Read*, overlap_region_alloc*, overlap_region*, bit_extz_t*, double, long)
int64_t get_rid_backward_cigar_err_back(rtrace_iter *it, ul_ov_t *aln, kv_rtrace_t *trace, rtrace_t *tc,
const ul_idx_t *uref, char* qstr, UC_Read *tu, overlap_region_alloc *ol, overlap_region *o, 
bit_extz_t *exz, double e_rate, int64_t qs)
{
    if(qs == aln->qe) return 0;
    if(!tc) tc = &(trace->a[aln->qn]);
    if(!o) o = &(ol->list[tc->oid]);

	if(it->k == INT32_MAX) {
		it->k = tc->c_weid;
		it->q[1] = aln->qe; 
		it->t[1] = aln->te;
		it->werr = it->cerr = 0; 
		it->qoff = aln->qe;
		it->toff = aln->te;
		it->coff = INT32_MAX; 
		clear_align(*exz); 
		exz->ps = exz->pe = exz->ts = exz->te = INT32_MAX;
	}
	window_list *wa = o->w_list.a; int64_t qwl, twl, sub_err; bit_extz_t aux; 
    assert(qs <= it->qoff);

	for (; it->k >= tc->c_wsid; it->k--) {
		it->q[0] = wa[it->k].x_end+1; 
		it->t[0] = wa[it->k].y_end+1;
        // if(qs == 166327) {
        //     fprintf(stderr, "-0-[M::%s::k->%ld] qoff::%ld, toff::%ld, coff::%ld, inner_q::[%ld, %ld), inner_t::[%ld, %ld), werr::%ld, qs::%ld\n", 
        //         __func__, it->k, it->qoff, it->toff, it->coff, it->q[0], it->q[1], it->t[0], it->t[1], it->werr, qs);
        // }
        
		if(it->qoff > it->q[0]) {///[it->qoff, ql) has been calculated
			if(it->q[0] <= it->q[1] && it->t[0] <= it->t[1]) {
				if((exz->ps != it->t[0]) || (exz->pe != it->t[1]) || (exz->ts != it->q[0]) || (exz->te == it->q[1])) {
					///calculate on-the-fly
                    gen_clip_win_err(o, it->q[0], it->q[1], it->t[0], it->t[1], e_rate, it->k==tc->c_weid?tc->sfx_e:-1, uref, qstr, tu, exz);
				}
                // fprintf(stderr, "-1-[M::%s::k->%ld] qoff::%ld, toff::%ld, coff::%ld, inner_q::[%ld, %ld), inner_t::[%ld, %ld), werr::%ld, qs::%ld\n", 
                // __func__, it->k, it->qoff, it->toff, it->coff, it->q[0], it->q[1], it->t[0], it->t[1], it->werr, qs);
				if(qs >= it->q[0] && qs < it->q[1]) {
					///phrase cigar
                    sub_err = extract_sub_werr(exz, 0, exz->cigar.n, exz->ps, exz->pe+1, exz->ts, exz->te+1, 
                            exz->ps, exz->pe+1, exz->ts, exz->te+1, qs, it);
                    if(qs == it->q[0]) {
                        it->werr += sub_err; sub_err = 0;
                        it->qoff = it->q[0]; it->toff = it->t[0]; 
                    }
					return it->werr+sub_err;
				} 
                it->qoff = it->q[0]; 
                it->toff = it->t[0]; 
                it->werr += exz->err;
			}
		} 
        if(qs == it->qoff) return it->werr;

		it->cq[0] = it->q[0] = wa[it->k].x_start; it->cq[1] = it->q[1] = wa[it->k].x_end+1; 
		it->ct[0] = it->t[0] = wa[it->k].y_start; it->ct[1] = it->t[1] = wa[it->k].y_end+1; 
		it->ci[0] = 0; it->ci[1] = wa[it->k].clen; qwl = it->q[1] - it->q[0]; twl = it->t[1] - it->t[0];
		if(is_ualn_win(wa[it->k])) {
			if(it->qoff > it->q[0]) {
                // fprintf(stderr, "-2-[M::%s::k->%ld] qoff::%ld, toff::%ld, coff::%ld, inner_q::[%ld, %ld), inner_t::[%ld, %ld), werr::%ld, qs::%ld\n", 
                // __func__, it->k, it->qoff, it->toff, it->coff, it->q[0], it->q[1], it->t[0], it->t[1], it->werr, qs);
				if(qs /**>=**/> it->q[0] && qs < it->q[1]) {
					sub_err = ((((double)(it->q[1]-qs))/((double)(it->q[1]-it->q[0])))*
                                                                    (gen_err_unaligned(qwl, twl))); 
                    // if(qs == it->q[0]) {
                    //     it->werr += sub_err; sub_err = 0;
                    //     it->qoff = it->q[0]; it->toff = it->t[0]; 
                    // }
					return it->werr+sub_err;
				}
				it->qoff = it->q[0]; 
                it->toff = it->t[0]; 
                it->werr += gen_err_unaligned(qwl, twl); 
			}
		} else {
			set_bit_extz_t(aux, (*o), it->k); 
			if(it->k == tc->c_wsid) {
				it->cq[0] = tc->c_qs; it->ct[0] = tc->c_ts; it->ci[0] = tc->c_wsii;
				it->q[0] = MAX((int32_t)aln->qs, tc->c_qs);
				it->t[0] = MAX((int32_t)aln->ts, tc->c_ts);
			}
			if(it->k == tc->c_weid) {
				it->cq[1] = tc->c_qe; it->ct[1] = tc->c_te; it->ci[1] = tc->c_weii;
				it->q[1] = MIN((int32_t)aln->qe, tc->c_qe);
				it->t[1] = MIN((int32_t)aln->te, tc->c_te);
			}
            // fprintf(stderr, "-3-[M::%s::k->%ld] qoff::%ld, toff::%ld, coff::%ld, inner_q::[%ld, %ld), inner_t::[%ld, %ld), werr::%ld, qs::%ld\n", 
            //     __func__, it->k, it->qoff, it->toff, it->coff, it->q[0], it->q[1], it->t[0], it->t[1], it->werr, qs);
			if(it->qoff > it->q[0]) {
				if(qs /**>=**/> it->q[0] && qs < it->q[1]) {
					sub_err = extract_sub_werr(&aux, it->ci[0], it->ci[1], it->ct[0], it->ct[1], 
                        it->cq[0], it->cq[1], it->t[0], it->t[1], it->q[0], it->q[1], qs, it);
                    // if(qs == it->q[0]) {
                    //     it->werr += sub_err; sub_err = 0;
                    //     it->qoff = it->q[0]; it->toff = it->t[0]; 
                    // }
					return it->werr + sub_err; 
				}
                it->werr += extract_sub_werr(&aux, it->ci[0], it->ci[1], it->ct[0], it->ct[1], 
                        it->cq[0], it->cq[1], it->t[0], it->t[1], it->q[0], it->q[1], it->q[0], it);
				it->qoff = it->q[0]; 
                it->toff = it->t[0]; 
			}
		}

        // if(qs == 166327) {
        //     fprintf(stderr, "-1-[M::%s::k->%ld] qoff::%ld, toff::%ld, coff::%ld, inner_q::[%ld, %ld), inner_t::[%ld, %ld), werr::%ld, qs::%ld\n", 
        //         __func__, it->k, it->qoff, it->toff, it->coff, it->q[0], it->q[1], it->t[0], it->t[1], it->werr, qs);
        // }
		it->q[1] = it->q[0]; it->t[1] = it->t[0];
        if((qs == it->qoff))  {
            if(it->k > tc->c_wsid) {
                it->q[0] = wa[it->k-1].x_end+1; 
		        it->t[0] = wa[it->k-1].y_end+1;
            } else {
                it->q[0] = aln->qs; 
                it->t[0] = aln->ts;
            }

            // if(qs == 166327) {
            //     fprintf(stderr, "-2-[M::%s::k->%ld] qoff::%ld, toff::%ld, coff::%ld, inner_q::[%ld, %ld), inner_t::[%ld, %ld), werr::%ld, qs::%ld\n", 
            //         __func__, it->k, it->qoff, it->toff, it->coff, it->q[0], it->q[1], it->t[0], it->t[1], it->werr, qs);
            //     fprintf(stderr, "-2-[M::%s::k->%ld] pre_inner_q::[%d, %d), pre_inner_t::[%d, %d)\n", 
            //         __func__, it->k, wa[it->k-1].x_start, wa[it->k-1].x_end+1, wa[it->k-1].y_start, wa[it->k-1].y_end+1);
            // }
            ///otherwise there should be an indel at t
            if(it->q[0] == it->q[1] && it->t[0] < it->t[1]) {
                it->werr += it->t[1] - it->t[0]; continue;
            } else {
                return it->werr;
            }
        }
    }

	it->q[0] = aln->qs; it->t[0] = aln->ts;
	if(it->qoff > it->q[0]) {
		if(it->q[0] <= it->q[1] && it->t[0] <= it->t[1]) {
			if((exz->ps != it->t[0]) || (exz->pe != it->t[1]) || (exz->ts != it->q[0]) || (exz->te == it->q[1])) {
				///calculate on-the-fly
                gen_clip_win_err(o, it->q[0], it->q[1], it->t[0], it->t[1], e_rate, tc->pfx_e, uref, qstr, tu, exz);
            }
            // fprintf(stderr, "-4-[M::%s::k->%ld] qoff::%ld, toff::%ld, coff::%ld, inner_q::[%ld, %ld), inner_t::[%ld, %ld), werr::%ld, qs::%ld\n", 
            //     __func__, it->k, it->qoff, it->toff, it->coff, it->q[0], it->q[1], it->t[0], it->t[1], it->werr, qs);
			if(qs >= it->q[0] && qs < it->q[1]) {
				///phrase cigar
                sub_err = extract_sub_werr(exz, 0, exz->cigar.n, exz->ps, exz->pe+1, exz->ts, exz->te+1, 
                            exz->ps, exz->pe+1, exz->ts, exz->te+1, qs, it);
                if(qs == it->q[0]) {
                    it->werr += sub_err; sub_err = 0;
                    it->qoff = it->q[0]; it->toff = it->t[0]; 
                }
				return it->werr+sub_err; 
			} 

            it->qoff = it->q[0]; 
            it->toff = it->t[0]; 
            it->werr += exz->err;
		}
	} 
    if(it->k < tc->c_wsid) it->werr = aln->sec;
	return it->werr;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movsd %xmm0, 0x18(%rsp)
movq 0x150(%rsp), %rbp
movl 0x8(%rsi), %eax
cmpq %rbp, %rax
jne 0x7ff05
xorl %eax, %eax
jmp 0x8046e
movq %rcx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq 0x140(%rsp), %r13
testq %rcx, %rcx
jne 0x7ff25
movl (%r14), %ecx
imulq $0x34, %rcx, %r15
addq (%rdx), %r15
testq %r13, %r13
jne 0x7ff40
movq 0x138(%rsp), %rcx
movslq 0x30(%r15), %rdx
imulq $0xa8, %rdx, %r13
addq (%rcx), %r13
movq 0x148(%rsp), %rsi
cmpq $0x7fffffff, (%rbx)     # imm = 0x7FFFFFFF
jne 0x7ff9d
movslq 0x14(%r15), %rcx
movq %rcx, (%rbx)
movq %rax, 0x10(%rbx)
movl 0x14(%r14), %ecx
movq %rcx, 0x20(%rbx)
xorl %edx, %edx
movq %rdx, 0x68(%rbx)
movq %rdx, 0x58(%rbx)
movq %rax, 0x70(%rbx)
movq %rcx, 0x80(%rbx)
movq $0x7fffffff, 0x88(%rbx) # imm = 0x7FFFFFFF
movl $0x7fffffff, 0x2c(%rsi) # imm = 0x7FFFFFFF
movabsq $0x7fffffff7fffffff, %rax # imm = 0x7FFFFFFF7FFFFFFF
movq %rax, 0x1c(%rsi)
movq %rax, 0x10(%rsi)
movq %r9, 0x10(%rsp)
cmpq %rbp, 0x70(%rbx)
jl 0x80578
movq %r8, 0x8(%rsp)
movq (%rbx), %rax
movslq 0x10(%r15), %rcx
cmpq %rcx, %rax
jge 0x80091
movl 0x4(%r14), %esi
movq %rsi, 0x8(%rbx)
movl 0x10(%r14), %ecx
movq %rcx, 0x18(%rbx)
cmpq %rsi, 0x70(%rbx)
jle 0x80454
movq 0x10(%rbx), %rdx
cmpq %rsi, %rdx
jl 0x80454
movq 0x20(%rbx), %r8
cmpq %rcx, %r8
jl 0x80454
movq 0x148(%rsp), %r12
movslq 0x10(%r12), %rax
cmpq %rcx, %rax
jne 0x80025
movslq 0x14(%r12), %rax
cmpq %rax, %r8
jne 0x80025
movslq 0x1c(%r12), %rax
cmpq %rax, %rsi
jne 0x80025
movslq 0x20(%r12), %rax
cmpq %rax, %rdx
jne 0x8004c
movslq 0x28(%r15), %r9
movq %r13, %rdi
movsd 0x18(%rsp), %xmm0
pushq %r12
pushq 0x138(%rsp)
pushq 0x20(%rsp)
pushq 0x20(%rsp)
callq 0x7f761
addq $0x20, %rsp
movq 0x8(%rbx), %rax
cmpq %rbp, %rax
jg 0x8043c
cmpq %rbp, 0x10(%rbx)
jle 0x8043c
movq 0xa8(%r12), %rdx
movslq 0x10(%r12), %rax
movslq 0x14(%r12), %r8
incq %r8
movslq 0x1c(%r12), %rcx
movslq 0x20(%r12), %r9
incq %r9
subq $0x8, %rsp
movq %r12, %rdi
jmp 0x804d9
movq 0x58(%r13), %r12
movq %rax, %rcx
shlq $0x5, %rcx
movslq 0x4(%r12,%rcx), %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movslq 0xc(%r12,%rcx), %rcx
incq %rcx
movq %rcx, 0x18(%rbx)
cmpq %rsi, 0x70(%rbx)
jle 0x80172
movq 0x10(%rbx), %rdx
cmpq %rsi, %rdx
jl 0x80172
movq 0x20(%rbx), %r8
cmpq %rcx, %r8
jl 0x80172
movq 0x148(%rsp), %rdi
cmpl %ecx, 0x10(%rdi)
jne 0x80104
movslq 0x14(%rdi), %rdi
cmpq %rdi, %r8
jne 0x80104
movq 0x148(%rsp), %rdi
cmpl 0x1c(%rdi), %esi
jne 0x80104
movslq 0x20(%rdi), %rdi
cmpq %rdi, %rdx
jne 0x80140
movslq 0x14(%r15), %rdi
movq $-0x1, %r9
cmpq %rdi, %rax
jne 0x80118
movslq 0x24(%r15), %r9
movq %r13, %rdi
movsd 0x18(%rsp), %xmm0
pushq 0x148(%rsp)
pushq 0x138(%rsp)
pushq 0x20(%rsp)
pushq 0x20(%rsp)
callq 0x7f761
addq $0x20, %rsp
movq 0x8(%rbx), %rax
cmpq %rbp, %rax
jg 0x80153
cmpq %rbp, 0x10(%rbx)
jg 0x804b0
movq %rax, 0x70(%rbx)
movq 0x18(%rbx), %rax
movq %rax, 0x80(%rbx)
movq 0x148(%rsp), %rax
movslq 0x2c(%rax), %rax
addq %rax, 0x58(%rbx)
movq 0x70(%rbx), %rax
cmpq %rbp, %rax
je 0x8046a
movq (%rbx), %rcx
movq %rcx, %rsi
shlq $0x5, %rsi
movslq (%r12,%rsi), %rdi
movq %rdi, 0x8(%rbx)
movq %rdi, 0x28(%rbx)
movslq 0x4(%r12,%rsi), %r8
incq %r8
movq %r8, 0x10(%rbx)
movq %r8, 0x30(%rbx)
movslq 0x8(%r12,%rsi), %r9
movq %r9, 0x18(%rbx)
movq %r9, 0x38(%rbx)
movslq 0xc(%r12,%rsi), %rdx
incq %rdx
movq %rdx, 0x20(%rbx)
movq %rdx, 0x40(%rbx)
movq $0x0, 0x48(%rbx)
movl 0x1c(%r12,%rsi), %r10d
movq %r10, 0x50(%rbx)
cmpw $0x7fff, 0x14(%r12,%rsi) # imm = 0x7FFF
jne 0x801f4
leaq (%r12,%rsi), %r10
cmpl $0x0, 0x1c(%r10)
jne 0x801f4
cmpw $0x0, 0x12(%r10)
js 0x803aa
movq 0x58(%r13), %rdx
movl 0x18(%rdx,%rsi), %edi
addq %rdi, %rdi
addq 0x70(%r13), %rdi
movq %rdi, 0xd8(%rsp)
movl 0x1c(%rdx,%rsi), %edi
movq %rdi, 0xd0(%rsp)
movq %rdi, 0xc8(%rsp)
movl (%rdx,%rsi), %edi
movl %edi, 0x3c(%rsp)
movl 0x4(%rdx,%rsi), %edi
movl %edi, 0x40(%rsp)
movl 0x8(%rdx,%rsi), %edi
movl %edi, 0x30(%rsp)
movl 0xc(%rdx,%rsi), %edi
movl %edi, 0x34(%rsp)
movswl 0x14(%rdx,%rsi), %edx
movl %edx, 0x4c(%rsp)
movl %edx, 0x48(%rsp)
movslq 0x10(%r15), %rdx
cmpq %rdx, %rcx
jne 0x8028b
movslq (%r15), %rdx
movq %rdx, 0x28(%rbx)
movslq 0x8(%r15), %rsi
movq %rsi, 0x38(%rbx)
movslq 0x18(%r15), %rdi
movq %rdi, 0x48(%rbx)
movl 0x4(%r14), %edi
cmpl %edx, %edi
cmovlel %edx, %edi
movslq %edi, %rdx
movq %rdx, 0x8(%rbx)
movl 0x10(%r14), %edx
cmpl %esi, %edx
cmovlel %esi, %edx
movslq %edx, %rdx
movq %rdx, 0x18(%rbx)
movslq 0x14(%r15), %rdx
cmpq %rdx, %rcx
jne 0x802cc
movslq 0x4(%r15), %rcx
movq %rcx, 0x30(%rbx)
movslq 0xc(%r15), %rdx
movq %rdx, 0x40(%rbx)
movslq 0x1c(%r15), %rsi
movq %rsi, 0x50(%rbx)
movl 0x8(%r14), %esi
cmpl %ecx, %esi
cmovgel %ecx, %esi
movslq %esi, %rcx
movq %rcx, 0x10(%rbx)
movl 0x14(%r14), %ecx
cmpl %edx, %ecx
cmovgel %edx, %ecx
movslq %ecx, %rcx
movq %rcx, 0x20(%rbx)
movq 0x8(%rbx), %rcx
cmpq %rcx, %rax
jle 0x8032b
cmpq %rbp, %rcx
jge 0x802e7
movq 0x10(%rbx), %rax
cmpq %rbp, %rax
jg 0x80480
movq 0x48(%rbx), %rsi
movq 0x50(%rbx), %rdx
movq 0x40(%rbx), %r8
subq $0x8, %rsp
leaq 0x28(%rsp), %rdi
pushq %rbx
pushq %rcx
pushq 0x10(%rbx)
pushq %rcx
pushq 0x20(%rbx)
pushq 0x18(%rbx)
pushq 0x30(%rbx)
callq 0x7f94a
addq $0x40, %rsp
addq %rax, 0x58(%rbx)
movq 0x8(%rbx), %rax
movq 0x18(%rbx), %rcx
movq %rax, 0x70(%rbx)
movq %rcx, 0x80(%rbx)
movq 0x8(%rbx), %rcx
movq 0x18(%rbx), %rax
movq %rcx, 0x10(%rbx)
movq %rax, 0x20(%rbx)
cmpq %rbp, 0x70(%rbx)
jne 0x8038e
movq (%rbx), %rdx
movslq 0x10(%r15), %rsi
cmpq %rsi, %rdx
jle 0x80367
shlq $0x5, %rdx
movslq -0x1c(%r12,%rdx), %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movslq -0x14(%r12,%rdx), %rdx
incq %rdx
jmp 0x80373
movl 0x4(%r14), %edx
movq %rdx, 0x8(%rbx)
movl 0x10(%r14), %edx
movq %rdx, 0x18(%rbx)
cmpq %rcx, 0x8(%rbx)
jne 0x8046a
subq %rdx, %rax
jle 0x8046a
addq %rax, 0x58(%rbx)
movq (%rbx), %rcx
leaq -0x1(%rcx), %rax
movq %rax, (%rbx)
movslq 0x10(%r15), %rdx
cmpq %rdx, %rcx
jg 0x80095
jmp 0x7ffc1
cmpq %rdi, %rax
jle 0x8032b
movq %r8, %rax
subq %rdi, %rax
subq %r9, %rdx
cmpq %rbp, %rdi
jge 0x803ca
subq %rbp, %r8
jg 0x8050e
movq %rdi, 0x70(%rbx)
movq %r9, 0x80(%rbx)
cmpq $0x200, %rax            # imm = 0x200
jg 0x803eb
cmpq %rdx, %rax
cmovgq %rax, %rdx
cvtsi2sd %rdx, %xmm0
jmp 0x80421
cmpq %rdx, %rax
cmovlq %rax, %rdx
cvtsi2sd %rdx, %xmm1
cvtsi2sd %rax, %xmm2
mulsd 0x1a5144(%rip), %xmm2   # 0x225548
addsd 0x1a4e64(%rip), %xmm2   # 0x225270
movapd %xmm2, %xmm0
cmplesd %xmm1, %xmm0
andpd %xmm0, %xmm1
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
xorps %xmm1, %xmm1
cvtsi2sdq 0x58(%rbx), %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, 0x58(%rbx)
jmp 0x8032b
movq %rax, 0x70(%rbx)
movq 0x18(%rbx), %rax
movq %rax, 0x80(%rbx)
movslq 0x2c(%r12), %rax
addq %rax, 0x58(%rbx)
movslq 0x10(%r15), %rax
cmpq %rax, (%rbx)
jge 0x8046a
movl 0x18(%r14), %eax
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
movq %rax, 0x58(%rbx)
movq 0x58(%rbx), %rax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x48(%rbx), %rsi
movq 0x50(%rbx), %rdx
movq 0x40(%rbx), %r8
subq $0x8, %rsp
leaq 0x28(%rsp), %rdi
pushq %rbx
pushq %rbp
pushq %rax
pushq %rcx
pushq 0x20(%rbx)
pushq 0x18(%rbx)
pushq 0x30(%rbx)
callq 0x7f94a
addq $0x40, %rsp
jmp 0x8056f
movq 0x148(%rsp), %rdi
movq 0xa8(%rdi), %rdx
movslq 0x10(%rdi), %rax
movslq 0x14(%rdi), %r8
incq %r8
movslq 0x1c(%rdi), %rcx
movslq 0x20(%rdi), %r9
incq %r9
subq $0x8, %rsp
xorl %esi, %esi
pushq %rbx
pushq %rbp
pushq %r9
pushq %rcx
pushq %r8
pushq %rax
pushq %r9
callq 0x7f94a
addq $0x40, %rsp
movq 0x8(%rbx), %rcx
cmpq %rbp, %rcx
jne 0x8056f
addq %rax, 0x58(%rbx)
movq %rcx, 0x70(%rbx)
movq 0x18(%rbx), %rax
movq %rax, 0x80(%rbx)
xorl %eax, %eax
jmp 0x8056f
xorps %xmm0, %xmm0
cvtsi2sd %r8, %xmm0
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
cmpq $0x200, %rax            # imm = 0x200
jg 0x80535
cmpq %rdx, %rax
cmovgq %rax, %rdx
cvtsi2sd %rdx, %xmm2
jmp 0x80566
cmpq %rdx, %rax
cmovlq %rax, %rdx
cvtsi2sd %rdx, %xmm3
mulsd 0x1a4fff(%rip), %xmm1   # 0x225548
addsd 0x1a4d1f(%rip), %xmm1   # 0x225270
movapd %xmm1, %xmm2
cmplesd %xmm3, %xmm2
andpd %xmm2, %xmm3
andnpd %xmm1, %xmm2
orpd %xmm3, %xmm2
mulsd %xmm2, %xmm0
cvttsd2si %xmm0, %rax
addq 0x58(%rbx), %rax
jmp 0x8046e
leaq 0x1a8b11(%rip), %rdi    # 0x229090
leaq 0x1a50bd(%rip), %rsi    # 0x225643
leaq 0x1a8b12(%rip), %rcx    # 0x22909f
movl $0x5dad, %edx           # imm = 0x5DAD
callq 0x2110