// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Overlaps.cpp
// Function: chain_origin_trans_uid_by_distance(hap_cov_t*, asg_t*, unsigned int*, unsigned int, unsigned int, unsigned long*, unsigned int*, unsigned int, unsigned int, unsigned long*, ma_ug_t*, unsigned int, double, char const*)
void chain_origin_trans_uid_by_distance(hap_cov_t *cov, asg_t *read_sg, 
uint32_t *pri_a, uint32_t pri_n, uint32_t pri_beg, uint64_t *i_pri_len, 
uint32_t *aux_a, uint32_t aux_n, uint32_t aux_beg, uint64_t *i_aux_len,
ma_ug_t *ug, uint32_t flag, double score, const char* cmd)
{
    uint32_t i, len, bn;
    uint64_t pri_len, aux_len;
    kvec_asg_arc_t_offset* u_buffer = &(cov->u_buffer);
    kvec_t_i32_warp* tailIndex = &(cov->tailIndex);
    trans_chain* t_ch = cov->t_ch;
    asg_arc_t_offset *tt = NULL;
    ca_buf_t *tx = NULL;

    if(i_pri_len) pri_len = (*i_pri_len);
    else pri_len = set_utg_offset(pri_a, pri_n, ug, read_sg, cov->pos_idx, 0, 1);

    if(i_aux_len) aux_len = (*i_aux_len);
    else aux_len = set_utg_offset(aux_a, aux_n, ug, read_sg, cov->pos_idx, 0, 1);
    
    tt = NULL; t_ch->c_buf.n = 0; t_ch->k_t_b.n = 0;
    if(tailIndex->a.n > 0) tt = &(u_buffer->a.a[tailIndex->a.a[0]]);
    if(!tt || (pri_beg < (tt->Off>>32) && aux_beg < ((uint32_t)tt->Off)))
    {
        kv_pushp(ca_buf_t, t_ch->c_buf, &tx);
        tx->c_x_p = pri_beg; 
        tx->c_y_p = aux_beg;

        for (i = 0; i < tailIndex->a.n; i++)
        {
            tt = &(u_buffer->a.a[tailIndex->a.a[i]]);
            kv_pushp(ca_buf_t, t_ch->c_buf, &tx);

            tx->c_x_p = tt->Off>>32;
            tx->c_y_p = (uint32_t)tt->Off;
        }
    }
    else if(tailIndex->a.n == 1)//1 ele in chain
    {
        kv_pushp(ca_buf_t, t_ch->c_buf, &tx);
        tx->c_x_p = pri_beg; tx->c_y_p = aux_beg;
    }
    else if(tailIndex->a.n > 0)
    {
        uint32_t cx, cy, ax, ay, found = 0;
        for (i = 0; i < tailIndex->a.n; i++)
        {
            cx = cy = ax = ay = (uint32_t)-1;

            cx = u_buffer->a.a[tailIndex->a.a[i]].Off>>32;
            cy = (uint32_t)u_buffer->a.a[tailIndex->a.a[i]].Off;
            if((i + 1) < tailIndex->a.n)
            {
                ax = u_buffer->a.a[tailIndex->a.a[i+1]].Off>>32;
                ay = (uint32_t)u_buffer->a.a[tailIndex->a.a[i+1]].Off;
            }

            kv_pushp(ca_buf_t, t_ch->c_buf, &tx);
            tx->c_x_p = cx; tx->c_y_p = cy;

            if(found) continue;
            if(pri_beg > cx && pri_beg < ax && aux_beg > cy && aux_beg < ay)
            {
                kv_pushp(ca_buf_t, t_ch->c_buf, &tx);
                tx->c_x_p = pri_beg; tx->c_y_p = aux_beg;
                found = 1;
            } 
        }
    }

    
    // fprintf(stderr, "\ncmd-%s\n", cmd);
    // fprintf(stderr, "pri_beg=%u, pri_len=%lu\n", pri_beg, pri_len);
    // fprintf(stderr, "aux_beg=%u, aux_len=%lu\n", aux_beg, aux_len);

    // print_buf_t(ug, pri, "pri");
    // print_buf_t(ug, aux, "aux");


    tx = &(t_ch->c_buf.a[t_ch->c_buf.n-1]);
    len = MIN(pri_len - tx->c_x_p, aux_len - tx->c_y_p);
    if(len > 0)///insert boundary
    {
        kv_pushp(ca_buf_t, t_ch->c_buf, &tx);
        tx->c_x_p = t_ch->c_buf.a[t_ch->c_buf.n-2].c_x_p + len;
        tx->c_y_p = t_ch->c_buf.a[t_ch->c_buf.n-2].c_y_p + len;     
    }

    tx = &(t_ch->c_buf.a[0]);///insert boundary
    if(tx->c_x_p != 0 && tx->c_y_p != 0)///already at boundary
    {
        len = MIN(tx->c_x_p, tx->c_y_p);///offset
        kv_pushp(ca_buf_t, t_ch->c_buf, &tx);
        for (i = 0; (i + 1)< t_ch->c_buf.n; i++)
        {
            t_ch->c_buf.a[t_ch->c_buf.n - i - 1] = t_ch->c_buf.a[t_ch->c_buf.n - i - 2];
        }
        t_ch->c_buf.a[0].c_x_p = t_ch->c_buf.a[1].c_x_p - len;
        t_ch->c_buf.a[0].c_y_p = t_ch->c_buf.a[1].c_y_p - len;
    }

    ///chain is [s, e)
    if(t_ch->c_buf.a[0].c_x_p != 0 && t_ch->c_buf.a[0].c_y_p != 0) fprintf(stderr, "ERROR1\n");
    if(t_ch->c_buf.a[t_ch->c_buf.n-1].c_x_p!= pri_len && 
                                            t_ch->c_buf.a[t_ch->c_buf.n-1].c_y_p!= aux_len)
    {
        fprintf(stderr, "ERROR2\n");
    }

    u_trans_hit_idx iter;
    u_trans_hit_t hit, *kh = NULL;
    ////////prx
    reset_u_trans_hit_idx(&iter, pri_a, pri_n, ug, read_sg, t_ch, 
                    t_ch->c_buf.a[0].c_x_p, t_ch->c_buf.a[t_ch->c_buf.n-1].c_x_p);    
    while(get_u_trans_hit(&iter, &hit))//get [qScur, qEcur), [qSpre, qEpre)
    {
        refine_u_trans_t(&hit, &(t_ch->c_buf)); ///get [tScur, tEcur)
        kv_push(u_trans_hit_t, t_ch->k_t_b, hit);
    }
    bn = t_ch->k_t_b.n;
    
    ////////aux
    reset_u_trans_hit_idx(&iter, aux_a, aux_n, ug, read_sg, t_ch, 
                    t_ch->c_buf.a[0].c_y_p, t_ch->c_buf.a[t_ch->c_buf.n-1].c_y_p);    
    while(get_u_trans_hit(&iter, &hit))
    {
        extract_sub_overlaps(hit.qScur, hit.qEcur, hit.qSpre, hit.qEpre, hit.qn, &(t_ch->k_t_b), bn);
    }

    
    if(t_ch->k_t_b.n - bn == 0) fprintf(stderr, "ERROR6\n");
    
    

    u_trans_t *kt = NULL;
    double x_score, y_score;
    for (i = bn; i < t_ch->k_t_b.n; i++)
    {
        kh = &(t_ch->k_t_b.a[i]);
        if(kh->qEpre <= kh->qSpre) continue;
        if(kh->tEpre <= kh->tSpre) continue;
        kv_pushp(u_trans_t, t_ch->k_trans, &kt);
        kt->f = flag; kt->rev = ((kh->qn ^ kh->tn) & 1); kt->del = 0; 
        kt->qn = kh->qn>>1; kt->qs = kh->qSpre; kt->qe = kh->qEpre;
        kt->tn = kh->tn>>1; kt->ts = kh->tSpre; kt->te = kh->tEpre;
        if(score < 0)
        {
            kt->nw = (MIN((kt->qe - kt->qs), (kt->te - kt->ts)))*CHAIN_MATCH;
        } 
        else
        {
            x_score = ((double)(kt->qe-kt->qs)/(double)(t_ch->c_buf.a[t_ch->c_buf.n-1].c_x_p-t_ch->c_buf.a[0].c_x_p))*score;
            y_score = ((double)(kt->te-kt->ts)/(double)(t_ch->c_buf.a[t_ch->c_buf.n-1].c_y_p-t_ch->c_buf.a[0].c_y_p))*score;
            kt->nw = MIN(x_score, y_score);
        }
    }

    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movapd %xmm0, 0x80(%rsp)
movq %rsi, %r14
movq %rdi, %r15
movq 0x140(%rsp), %r12
movq 0x138(%rsp), %rbx
movq 0xa8(%rdi), %rbp
testq %r9, %r9
movl %ecx, 0x28(%rsp)
movq %rdx, 0x50(%rsp)
movl %r8d, 0x14(%rsp)
je 0x822e6
movq (%r9), %rax
jmp 0x8230b
movq 0x10(%r15), %r8
movl $0x1, (%rsp)
movq %rdx, %rdi
movl %ecx, %esi
movq %r12, %rdx
movq %r14, %rcx
xorl %r9d, %r9d
callq 0x80ffc
movl 0x14(%rsp), %r8d
movl %eax, %eax
movq %rax, 0x20(%rsp)
movl 0x128(%rsp), %esi
movq 0x120(%rsp), %rdi
testq %rbx, %rbx
movq %r14, 0x48(%rsp)
je 0x8232e
movq (%rbx), %rax
jmp 0x8234e
movq 0x10(%r15), %r8
movl $0x1, (%rsp)
movq %r12, %rdx
movq %r14, %rcx
xorl %r9d, %r9d
callq 0x80ffc
movl 0x14(%rsp), %r8d
movl %eax, %eax
movq %rax, 0x18(%rsp)
andq $0x0, 0x180(%rbp)
movl 0x130(%rsp), %r10d
andq $0x0, 0x168(%rbp)
leaq 0x180(%rbp), %r12
movq 0x60(%r15), %rax
testq %rax, %rax
je 0x823af
movq 0x50(%r15), %rcx
testq %rcx, %rcx
je 0x823af
movq 0x70(%r15), %rdx
movslq (%rdx), %rdx
imulq $0x28, %rdx, %rdx
movq 0x18(%rcx,%rdx), %rcx
movq %rcx, %rdx
shrq $0x20, %rdx
cmpl %r8d, %edx
setbe %dl
cmpl %r10d, %ecx
setbe %cl
orb %dl, %cl
jne 0x82489
cmpq $0x0, 0x188(%rbp)
je 0x823c4
movq 0x190(%rbp), %rax
xorl %edx, %edx
jmp 0x823f9
movq $0x2, 0x188(%rbp)
movq 0x190(%rbp), %rdi
pushq $0x38
popq %rsi
callq 0x2370
movl 0x130(%rsp), %r10d
movl 0x14(%rsp), %r8d
movq %rax, 0x190(%rbp)
movq 0x180(%rbp), %rdx
leaq 0x1(%rdx), %rcx
movq %rcx, 0x180(%rbp)
imulq $0x1c, %rdx, %rdx
movl %r8d, 0x10(%rax,%rdx)
movl %r10d, 0x14(%rax,%rdx)
xorl %ebx, %ebx
movl %ebx, %ebx
cmpq %rbx, 0x60(%r15)
jbe 0x82606
movq 0x50(%r15), %r14
movq 0x70(%r15), %rdx
movslq (%rdx,%rbx,4), %r13
cmpq 0x188(%rbp), %rcx
jne 0x82464
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rdx
movq %rdx, 0x188(%rbp)
imulq $0x1c, %rdx, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x190(%rbp)
movq 0x180(%rbp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r12)
imulq $0x28, %r13, %rsi
movq 0x18(%r14,%rsi), %rsi
rorq $0x20, %rsi
imulq $0x1c, %rcx, %rcx
movq %rsi, 0x10(%rax,%rcx)
incl %ebx
movq %rdx, %rcx
jmp 0x82414
cmpq $0x1, %rax
jne 0x824ab
cmpq $0x0, 0x188(%rbp)
je 0x82ad9
movq 0x190(%rbp), %rax
xorl %edx, %edx
jmp 0x82b0e
xorl %ecx, %ecx
pushq $0x1
popq %rdx
movl %edx, %ebx
xorl %esi, %esi
leal -0x1(%rbx), %edx
cmpq %rdx, %rax
jbe 0x825ff
movl %esi, 0x2c(%rsp)
movq 0x50(%r15), %rsi
movq 0x70(%r15), %rdi
movq %rbx, 0x30(%rsp)
movl %ebx, %r9d
pushq $-0x1
popq %r11
movl %r11d, %ebx
movl %r11d, %r14d
cmpq %r9, %rax
jbe 0x824f7
movslq (%rdi,%r9,4), %rax
imulq $0x28, %rax, %rax
movq 0x18(%rsi,%rax), %r14
movq %r14, %rbx
shrq $0x20, %rbx
movslq (%rdi,%rdx,4), %rax
imulq $0x28, %rax, %rax
movq 0x18(%rsi,%rax), %r13
movq 0x190(%rbp), %rax
cmpq 0x188(%rbp), %rcx
jne 0x82550
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rdx
movq %rdx, 0x188(%rbp)
imulq $0x1c, %rdx, %rsi
movq %rax, %rdi
callq 0x2370
movl 0x130(%rsp), %r10d
movl 0x14(%rsp), %r8d
movq %rax, 0x190(%rbp)
movq 0x180(%rbp), %rcx
movq %r13, %rdx
shrq $0x20, %rdx
imulq $0x1c, %rcx, %rsi
incq %rcx
movq %rcx, (%r12)
movl %edx, 0x10(%rax,%rsi)
movl %r13d, 0x14(%rax,%rsi)
cmpl $0x0, 0x2c(%rsp)
je 0x8257c
pushq $0x1
popq %rsi
movq 0x30(%rsp), %rbx
jmp 0x825f4
xorl %esi, %esi
cmpl %r8d, %edx
jae 0x82575
cmpl %r8d, %ebx
jbe 0x82575
cmpl %r10d, %r13d
movq 0x30(%rsp), %rbx
jae 0x825f4
cmpl %r10d, %r14d
jbe 0x825f4
cmpq 0x188(%rbp), %rcx
jne 0x825dc
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rdx
movq %rdx, 0x188(%rbp)
imulq $0x1c, %rdx, %rsi
movq %rax, %rdi
callq 0x2370
movl 0x130(%rsp), %r10d
movl 0x14(%rsp), %r8d
movq %rax, 0x190(%rbp)
movq 0x180(%rbp), %rcx
imulq $0x1c, %rcx, %rdx
incq %rcx
movq %rcx, (%r12)
movl %r8d, 0x10(%rax,%rdx)
movl %r10d, 0x14(%rax,%rdx)
pushq $0x1
popq %rsi
movq 0x60(%r15), %rax
incl %ebx
jmp 0x824b4
movq 0x190(%rbp), %rax
movq 0x20(%rsp), %r14
movq 0x18(%rsp), %r15
imulq $0x1c, %rcx, %rsi
movl -0xc(%rax,%rsi), %edx
movl -0x8(%rax,%rsi), %esi
movq %r14, %rdi
subq %rdx, %rdi
movq %r15, %rbx
subq %rsi, %rbx
cmpq %rbx, %rdi
cmovbq %rdi, %rbx
testl %ebx, %ebx
je 0x8268c
cmpq 0x188(%rbp), %rcx
jne 0x82673
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rdx
movq %rdx, 0x188(%rbp)
imulq $0x1c, %rdx, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x190(%rbp)
movq 0x180(%rbp), %rcx
imulq $0x1c, %rcx, %rdx
movl -0xc(%rax,%rdx), %edx
imulq $0x1c, %rcx, %rsi
incq %rcx
movq %rcx, (%r12)
addl %ebx, %edx
movl %edx, 0x10(%rax,%rsi)
addl -0x8(%rax,%rsi), %ebx
movl %ebx, 0x14(%rax,%rsi)
movl 0x10(%rax), %edx
testl %edx, %edx
je 0x8273c
movl 0x14(%rax), %ebx
testl %ebx, %ebx
je 0x82732
cmpl %ebx, %edx
cmovbl %edx, %ebx
cmpq 0x188(%rbp), %rcx
jne 0x826df
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rdx
movq %rdx, 0x188(%rbp)
imulq $0x1c, %rdx, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x190(%rbp)
movq 0x180(%rbp), %rcx
incq %rcx
movq %rcx, (%r12)
xorl %esi, %esi
leal 0x1(%rsi), %edx
movq 0x190(%rbp), %rax
cmpq %rdx, %rcx
jbe 0x82720
movl %esi, %esi
subq %rsi, %rcx
imulq $0x1c, %rcx, %rcx
movupd -0x38(%rax,%rcx), %xmm0
movupd -0x2c(%rax,%rcx), %xmm1
movupd %xmm1, -0x10(%rax,%rcx)
movupd %xmm0, -0x1c(%rax,%rcx)
movq (%r12), %rcx
movl %edx, %esi
jmp 0x826e8
movl 0x2c(%rax), %edx
movl 0x30(%rax), %esi
subl %ebx, %esi
subl %ebx, %edx
movl %edx, 0x10(%rax)
movl %esi, 0x14(%rax)
je 0x8273c
cmpl $0x0, 0x14(%rax)
jne 0x82b67
imulq $0x1c, %rcx, %rdx
movl -0xc(%rax,%rdx), %ecx
cmpq %rcx, %r14
je 0x82758
addq %rax, %rdx
movl -0x8(%rdx), %edx
cmpq %rdx, %r15
jne 0x82b33
leaq 0x168(%rbp), %r14
movl 0x10(%rax), %eax
leaq 0x90(%rsp), %r15
movq 0x50(%rsp), %rdx
movq %rdx, 0x30(%r15)
movl 0x28(%rsp), %edx
movl %edx, 0x38(%r15)
movq 0x140(%rsp), %rdx
movq %rdx, 0x40(%r15)
movq 0x48(%rsp), %rdx
movq %rdx, 0x48(%r15)
movq %rbp, 0x50(%r15)
movl %eax, 0x24(%r15)
movl %ecx, 0x28(%r15)
xorpd %xmm0, %xmm0
andq $0x0, 0x10(%r15)
movapd %xmm0, (%r15)
orl $-0x1, 0x20(%r15)
orq $-0x1, 0x18(%r15)
leaq 0x58(%rsp), %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0x81cf5
testl %eax, %eax
je 0x8284e
movq %r13, %rdi
movq %r12, %rsi
callq 0x817d1
movq 0x168(%rbp), %rcx
movq 0x178(%rbp), %rax
cmpq 0x170(%rbp), %rcx
jne 0x8281d
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rdx
movq %rdx, 0x170(%rbp)
imulq $0x28, %rdx, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x178(%rbp)
movq 0x168(%rbp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r14)
imulq $0x28, %rcx, %rcx
movq 0x78(%rsp), %rdx
movq %rdx, 0x20(%rax,%rcx)
movupd 0x58(%rsp), %xmm0
movupd 0x68(%rsp), %xmm1
movupd %xmm1, 0x10(%rax,%rcx)
movupd %xmm0, (%rax,%rcx)
jmp 0x827b9
movq 0x168(%rbp), %r12
movq 0x190(%rbp), %rax
movl %r12d, %r13d
movl 0x14(%rax), %ecx
imulq $0x1c, 0x180(%rbp), %rdx
movl -0x8(%rax,%rdx), %eax
leaq 0x90(%rsp), %r15
movq 0x120(%rsp), %rdx
movq %rdx, 0x30(%r15)
movl 0x128(%rsp), %edx
movl %edx, 0x38(%r15)
movq 0x140(%rsp), %rdx
movq %rdx, 0x40(%r15)
movq 0x48(%rsp), %rdx
movq %rdx, 0x48(%r15)
movq %rbp, 0x50(%r15)
movl %ecx, 0x24(%r15)
movl %eax, 0x28(%r15)
xorpd %xmm0, %xmm0
andq $0x0, 0x10(%r15)
movapd %xmm0, (%r15)
orl $-0x1, 0x20(%r15)
orq $-0x1, 0x18(%r15)
leaq 0x58(%rsp), %rbx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x81cf5
testl %eax, %eax
je 0x828fd
movl 0x60(%rsp), %edi
movl 0x64(%rsp), %esi
movl 0x58(%rsp), %edx
movl 0x5c(%rsp), %ecx
movl 0x68(%rsp), %r8d
movl %r12d, (%rsp)
movq %r14, %r9
callq 0x81a5f
jmp 0x828cb
cmpq %r13, (%r14)
je 0x82ab8
movl 0x148(%rsp), %r15d
andb $0x3f, %r15b
movapd 0x80(%rsp), %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movapd %xmm0, 0x30(%rsp)
xorpd %xmm3, %xmm3
movl %r12d, %r12d
cmpq %r12, (%r14)
jbe 0x82aa6
movq 0x178(%rbp), %rbx
imulq $0x28, %r12, %rax
movl 0x4(%rbx,%rax), %ecx
cmpl (%rbx,%rax), %ecx
jbe 0x82a9e
addq %rax, %rbx
movl 0x18(%rbx), %eax
cmpl 0x14(%rbx), %eax
jbe 0x82a9e
movq 0x138(%rbp), %rcx
movq 0x148(%rbp), %rax
cmpq 0x140(%rbp), %rcx
jne 0x829a6
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rdx
movq %rdx, 0x140(%rbp)
imulq $0x30, %rdx, %rsi
movq %rax, %rdi
callq 0x2370
xorpd %xmm3, %xmm3
movq %rax, 0x148(%rbp)
movq 0x138(%rbp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x138(%rbp)
imulq $0x30, %rcx, %rcx
movb 0x28(%rax,%rcx), %dl
andb $-0x40, %dl
orb %r15b, %dl
movb %dl, 0x28(%rax,%rcx)
movl 0x24(%rbx), %edx
xorl 0x10(%rbx), %edx
shlb $0x6, %dl
andb $0x40, %dl
orb %r15b, %dl
movb %dl, 0x28(%rax,%rcx)
movl 0x10(%rbx), %edx
shrl %edx
movl %edx, 0x8(%rax,%rcx)
movl (%rbx), %esi
movl %esi, (%rax,%rcx)
movl 0x4(%rbx), %edx
movl %edx, 0x4(%rax,%rcx)
movl 0x24(%rbx), %edi
shrl %edi
subl %esi, %edx
ucomisd 0x80(%rsp), %xmm3
movl %edi, 0x14(%rax,%rcx)
movl 0x14(%rbx), %edi
movl %edi, 0xc(%rax,%rcx)
movl 0x18(%rbx), %esi
movl %esi, 0x10(%rax,%rcx)
jbe 0x82a1d
subl %edi, %esi
cmpl %esi, %edx
cmovbl %edx, %esi
cvtsi2sd %rsi, %xmm0
jmp 0x82a96
movq 0x190(%rbp), %r8
imulq $0x1c, 0x180(%rbp), %r9
subl %edi, %esi
movd %esi, %xmm0
movd %edx, %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
pxor %xmm4, %xmm4
punpckldq %xmm4, %xmm1    # xmm1 = xmm1[0],xmm4[0],xmm1[1],xmm4[1]
movdqa 0x165186(%rip), %xmm5   # 0x1e7bd0
por %xmm5, %xmm1
subpd %xmm5, %xmm1
movq -0xc(%r8,%r9), %xmm0
movq 0x10(%r8), %xmm2
psubd %xmm2, %xmm0
punpckldq %xmm4, %xmm0    # xmm0 = xmm0[0],xmm4[0],xmm0[1],xmm4[1]
por %xmm5, %xmm0
subpd %xmm5, %xmm0
divpd %xmm0, %xmm1
mulpd 0x30(%rsp), %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
movapd %xmm1, %xmm0
cmplesd %xmm2, %xmm0
andpd %xmm0, %xmm1
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
addq %rcx, %rax
movsd %xmm0, 0x20(%rax)
incl %r12d
jmp 0x82929
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1d0521(%rip), %rax    # 0x252fe0
movq (%rax), %rcx
leaq 0x165e4c(%rip), %rdi    # 0x1e8915
pushq $0x7
popq %rsi
pushq $0x1
popq %rdx
callq 0x2410
jmp 0x82906
movq $0x2, 0x188(%rbp)
movq 0x190(%rbp), %rdi
pushq $0x38
popq %rsi
callq 0x2370
movl 0x130(%rsp), %r10d
movl 0x14(%rsp), %r8d
movq %rax, 0x190(%rbp)
movq 0x180(%rbp), %rdx
movq 0x20(%rsp), %r14
movq 0x18(%rsp), %r15
leaq 0x1(%rdx), %rcx
movq %rcx, (%r12)
imulq $0x1c, %rdx, %rdx
movl %r8d, 0x10(%rax,%rdx)
movl %r10d, 0x14(%rax,%rdx)
jmp 0x82610
movq 0x1d04a6(%rip), %rax    # 0x252fe0
movq (%rax), %rcx
leaq 0x165bf0(%rip), %rdi    # 0x1e8734
pushq $0x7
popq %rsi
pushq $0x1
popq %rdx
callq 0x2410
movq 0x190(%rbp), %rax
imulq $0x1c, 0x180(%rbp), %rcx
movl -0xc(%rax,%rcx), %ecx
jmp 0x82758
movq 0x1d0472(%rip), %rax    # 0x252fe0
movq (%rax), %rcx
leaq 0x165bb4(%rip), %rdi    # 0x1e872c
pushq $0x7
popq %rsi
pushq $0x1
popq %rdx
callq 0x2410
movq 0x180(%rbp), %rcx
movq 0x190(%rbp), %rax
jmp 0x8273c