// File: /workspace/github_cpp_makefile_star2_O3/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 $0xd8, %rsp
movdqa %xmm0, 0x70(%rsp)
movl %r8d, 0x8(%rsp)
movl %ecx, %r13d
movq %rsi, %r14
movq %rdi, %r15
movq 0x130(%rsp), %r12
movq 0x128(%rsp), %rbx
movq 0xa8(%rdi), %rbp
testq %r9, %r9
movq %rdx, 0x68(%rsp)
je 0xbdb10
movq (%r9), %rax
jmp 0xbdb31
movq 0x10(%r15), %r8
movl $0x1, (%rsp)
movq %rdx, %rdi
movl %r13d, %esi
movq %r12, %rdx
movq %r14, %rcx
xorl %r9d, %r9d
callq 0xbc79b
movl %eax, %eax
movq %rax, 0x30(%rsp)
movl 0x118(%rsp), %esi
movq 0x110(%rsp), %rdi
testq %rbx, %rbx
je 0xbdb4f
movq (%rbx), %rax
jmp 0xbdb6a
movq 0x10(%r15), %r8
movl $0x1, (%rsp)
movq %r12, %rdx
movq %r14, %rcx
xorl %r9d, %r9d
callq 0xbc79b
movl %eax, %eax
movq %rax, 0x20(%rsp)
movl 0x120(%rsp), %r9d
leaq 0x180(%rbp), %rbx
xorl %eax, %eax
movq %rax, 0x180(%rbp)
movq %rax, 0x168(%rbp)
movq 0x60(%r15), %rdx
testq %rdx, %rdx
movq %rbx, 0x10(%rsp)
movq %r14, 0x38(%rsp)
movl %r13d, 0xc(%rsp)
je 0xbdbdb
movq 0x50(%r15), %rax
testq %rax, %rax
je 0xbdbdb
movq 0x70(%r15), %rcx
movslq (%rcx), %rcx
leaq (%rcx,%rcx,4), %rcx
movq 0x18(%rax,%rcx,8), %rax
movq %rax, %rcx
shrq $0x20, %rcx
cmpl 0x8(%rsp), %ecx
setbe %cl
cmpl %r9d, %eax
setbe %al
orb %cl, %al
jne 0xbdcf8
cmpq $0x0, 0x188(%rbp)
je 0xbdbf0
movq 0x190(%rbp), %rax
xorl %ecx, %ecx
jmp 0xbdc26
movq $0x2, 0x188(%rbp)
movq 0x190(%rbp), %rdi
movl $0x38, %esi
callq 0x2370
movl 0x120(%rsp), %r9d
movq %rax, 0x190(%rbp)
movq 0x180(%rbp), %rcx
movq 0x60(%r15), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x180(%rbp)
leaq (%rcx,%rcx,8), %rdi
leaq (%rdi,%rdi,2), %rdi
addq %rcx, %rdi
movl 0x8(%rsp), %ecx
movl %ecx, 0x10(%rax,%rdi)
movl %r9d, 0x14(%rax,%rdi)
testq %rdx, %rdx
je 0xbdcf0
movl $0x1, %ebx
xorl %edi, %edi
movl $0x2, %r14d
movq 0x50(%r15), %r12
movq 0x70(%r15), %rcx
movslq (%rcx,%rdi,4), %r13
cmpq 0x188(%rbp), %rsi
jne 0xbdcab
leaq (%rsi,%rsi), %rcx
testq %rsi, %rsi
cmoveq %r14, %rcx
movq %rcx, 0x188(%rbp)
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rsi
addq %rcx, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x190(%rbp)
movq 0x180(%rbp), %rsi
movq 0x60(%r15), %rdx
leaq 0x1(%rsi), %rcx
movq 0x10(%rsp), %rdi
movq %rcx, (%rdi)
leaq (%rsi,%rsi,8), %rdi
leaq (%rdi,%rdi,2), %rdi
addq %rsi, %rdi
leaq (,%r13,4), %rsi
addq %r13, %rsi
movq 0x18(%r12,%rsi,8), %rsi
rorq $0x20, %rsi
movq %rsi, 0x10(%rax,%rdi)
movl %ebx, %edi
incl %ebx
movq %rcx, %rsi
cmpq %rdi, %rdx
ja 0xbdc5f
jmp 0xbdef6
movq %rsi, %rcx
jmp 0xbdef6
cmpq $0x1, %rdx
jne 0xbdd1a
cmpq $0x0, 0x188(%rbp)
je 0xbdea5
movq 0x190(%rbp), %rax
xorl %edx, %edx
jmp 0xbded7
xorl %ecx, %ecx
movl $0x1, %esi
xorl %ebx, %ebx
xorl %r12d, %r12d
movq %rbx, %rax
movq 0x50(%r15), %rdi
movq 0x70(%r15), %r8
movl %esi, %ebx
movl $0xffffffff, %r11d      # imm = 0xFFFFFFFF
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
cmpq %rbx, %rdx
jbe 0xbdd58
movslq (%r8,%rbx,4), %rdx
leaq (%rdx,%rdx,4), %rdx
movq 0x18(%rdi,%rdx,8), %r10
movq %r10, %r11
shrq $0x20, %r11
movslq (%r8,%rax,4), %rax
leaq (%rax,%rax,4), %rax
movq 0x18(%rdi,%rax,8), %r14
movq 0x190(%rbp), %rax
cmpq 0x188(%rbp), %rcx
jne 0xbddd1
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rdx
movq %rdx, 0x188(%rbp)
leaq (%rdx,%rdx,8), %rcx
leaq (%rcx,%rcx,2), %rsi
addq %rdx, %rsi
movq %rax, %rdi
movl %r12d, 0x2c(%rsp)
movq %rbx, %r12
movq %r10, %rbx
movq %r11, %r13
callq 0x2370
movq %r13, %r11
movq %rbx, %r10
movq %r12, %rbx
movl 0x2c(%rsp), %r12d
movl 0x120(%rsp), %r9d
movq %rax, 0x190(%rbp)
movq 0x180(%rbp), %rcx
movq %r14, %rdx
shrq $0x20, %rdx
leaq (%rcx,%rcx,8), %rsi
leaq (%rsi,%rsi,2), %rsi
addq %rcx, %rsi
incq %rcx
movq 0x10(%rsp), %rdi
movq %rcx, (%rdi)
movl %edx, 0x10(%rax,%rsi)
movl %r14d, 0x14(%rax,%rsi)
movl $0x1, %edi
testl %r12d, %r12d
jne 0xbde90
movl 0x8(%rsp), %r13d
cmpl %r13d, %edx
jae 0xbde8e
cmpl %r13d, %r11d
jbe 0xbde8e
cmpl %r9d, %r14d
jae 0xbde8e
cmpl %r9d, %r10d
jbe 0xbde8e
cmpq 0x188(%rbp), %rcx
jne 0xbde6c
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rdx
movq %rdx, 0x188(%rbp)
leaq (%rdx,%rdx,8), %rcx
leaq (%rcx,%rcx,2), %rsi
addq %rdx, %rsi
movq %rax, %rdi
callq 0x2370
movl $0x1, %edi
movl 0x120(%rsp), %r9d
movq %rax, 0x190(%rbp)
movq 0x180(%rbp), %rcx
movq 0x10(%rsp), %rsi
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
incq %rcx
movq %rcx, (%rsi)
movl %r13d, 0x10(%rax,%rdx)
movl %r9d, 0x14(%rax,%rdx)
jmp 0xbde90
xorl %edi, %edi
movq 0x60(%r15), %rdx
leal 0x1(%rbx), %esi
movl %edi, %r12d
cmpq %rbx, %rdx
ja 0xbdd26
jmp 0xbdef6
movq $0x2, 0x188(%rbp)
movq 0x190(%rbp), %rdi
movl $0x38, %esi
callq 0x2370
movl 0x120(%rsp), %r9d
movq %rax, 0x190(%rbp)
movq 0x180(%rbp), %rdx
leaq 0x1(%rdx), %rcx
movq %rcx, (%rbx)
leaq (%rdx,%rdx,8), %rsi
leaq (%rsi,%rsi,2), %rsi
addq %rdx, %rsi
movl 0x8(%rsp), %edx
movl %edx, 0x10(%rax,%rsi)
movl %r9d, 0x14(%rax,%rsi)
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
movl -0xc(%rax,%rdx), %esi
movl -0x8(%rax,%rdx), %edx
movq 0x30(%rsp), %r14
movq %r14, %rdi
subq %rsi, %rdi
movq 0x20(%rsp), %rbx
subq %rdx, %rbx
cmpq %rbx, %rdi
cmovbq %rdi, %rbx
testl %ebx, %ebx
je 0xbdfab
cmpq 0x188(%rbp), %rcx
movq 0x10(%rsp), %r12
movl 0xc(%rsp), %r13d
jne 0xbdf76
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
movl $0x2, %ecx
cmovneq %rdx, %rcx
movq %rcx, 0x188(%rbp)
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rsi
addq %rcx, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x190(%rbp)
movq 0x180(%rbp), %rcx
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
incq %rcx
movq %rcx, (%r12)
movq -0xc(%rax,%rdx), %xmm0
movd %ebx, %xmm1
pshufd $0x50, %xmm1, %xmm1     # xmm1 = xmm1[0,0,1,1]
paddd %xmm0, %xmm1
movq %xmm1, 0x10(%rax,%rdx)
movq 0x130(%rsp), %r15
jmp 0xbdfbd
movq 0x130(%rsp), %r15
movq 0x10(%rsp), %r12
movl 0xc(%rsp), %r13d
movl 0x10(%rax), %edx
testl %edx, %edx
je 0xbe08b
movl 0x14(%rax), %ebx
testl %ebx, %ebx
je 0xbe081
cmpl %ebx, %edx
cmovbl %edx, %ebx
cmpq 0x188(%rbp), %rcx
jne 0xbe019
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
movl $0x2, %ecx
cmovneq %rdx, %rcx
movq %rcx, 0x188(%rbp)
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rsi
addq %rcx, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x190(%rbp)
movq 0x180(%rbp), %rcx
incq %rcx
movq %rcx, (%r12)
cmpq $0x2, %rcx
jb 0xbe06f
xorl %eax, %eax
movq 0x190(%rbp), %rdx
movl %eax, %esi
subq %rsi, %rcx
leaq (%rcx,%rcx,8), %rsi
leaq (%rsi,%rsi,2), %rsi
addq %rcx, %rsi
movdqu -0x38(%rdx,%rsi), %xmm0
movdqu -0x2c(%rdx,%rsi), %xmm1
movdqu %xmm1, -0x10(%rdx,%rsi)
movdqu %xmm0, -0x1c(%rdx,%rsi)
leal 0x2(%rax), %edx
movq 0x180(%rbp), %rcx
incl %eax
cmpq %rdx, %rcx
ja 0xbe028
movq 0x190(%rbp), %rax
movl 0x2c(%rax), %edx
movl 0x30(%rax), %esi
subl %ebx, %esi
subl %ebx, %edx
movl %edx, 0x10(%rax)
movl %esi, 0x14(%rax)
je 0xbe08b
cmpl $0x0, 0x14(%rax)
jne 0xbe4de
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
movl -0xc(%rax,%rdx), %ecx
cmpq %rcx, %r14
je 0xbe0b0
addq %rax, %rdx
movl -0x8(%rdx), %edx
cmpq %rdx, 0x20(%rsp)
jne 0xbe49c
leaq 0x168(%rbp), %r14
movl 0x10(%rax), %eax
leaq 0x80(%rsp), %rdi
movq 0x68(%rsp), %rdx
movq %rdx, 0x30(%rdi)
movl %r13d, 0x38(%rdi)
movq %r15, 0x40(%rdi)
movq 0x38(%rsp), %rdx
movq %rdx, 0x48(%rdi)
movq %rbp, 0x50(%rdi)
movl %eax, 0x24(%rdi)
movl %ecx, 0x28(%rdi)
pxor %xmm0, %xmm0
movdqa %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movl $0xffffffff, 0x20(%rdi) # imm = 0xFFFFFFFF
movq $-0x1, 0x18(%rdi)
leaq 0x40(%rsp), %rsi
callq 0xbd461
testl %eax, %eax
je 0xbe1ba
leaq 0x40(%rsp), %r15
movl $0x2, %ebx
leaq 0x80(%rsp), %r13
movq %r15, %rdi
movq %r12, %rsi
callq 0xbcef2
movq 0x168(%rbp), %rcx
movq 0x178(%rbp), %rax
cmpq 0x170(%rbp), %rcx
jne 0xbe17b
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
cmoveq %rbx, %rdx
movq %rdx, 0x170(%rbp)
shlq $0x3, %rdx
leaq (%rdx,%rdx,4), %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x178(%rbp)
movq 0x168(%rbp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r14)
leaq (%rcx,%rcx,4), %rcx
movq 0x60(%rsp), %rdx
movq %rdx, 0x20(%rax,%rcx,8)
movdqu 0x40(%rsp), %xmm0
movdqu 0x50(%rsp), %xmm1
movdqu %xmm1, 0x10(%rax,%rcx,8)
movdqu %xmm0, (%rax,%rcx,8)
movq %r13, %rdi
movq %r15, %rsi
callq 0xbd461
testl %eax, %eax
jne 0xbe129
movq 0x168(%rbp), %r12
movq 0x180(%rbp), %rax
movl %r12d, %r13d
movq 0x190(%rbp), %rcx
movl 0x14(%rcx), %edx
leaq (%rax,%rax,8), %rsi
leaq (%rsi,%rsi,2), %rsi
addq %rax, %rsi
movl -0x8(%rcx,%rsi), %eax
leaq 0x80(%rsp), %rdi
movq 0x110(%rsp), %rcx
movq %rcx, 0x30(%rdi)
movl 0x118(%rsp), %ecx
movl %ecx, 0x38(%rdi)
movq 0x130(%rsp), %rcx
movq %rcx, 0x40(%rdi)
movq 0x38(%rsp), %rcx
movq %rcx, 0x48(%rdi)
movq %rbp, 0x50(%rdi)
movl %edx, 0x24(%rdi)
movl %eax, 0x28(%rdi)
pxor %xmm0, %xmm0
movdqa %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movl $0xffffffff, 0x20(%rdi) # imm = 0xFFFFFFFF
movq $-0x1, 0x18(%rdi)
leaq 0x40(%rsp), %rsi
callq 0xbd461
testl %eax, %eax
je 0xbe28b
leaq 0x80(%rsp), %rbx
leaq 0x40(%rsp), %r15
movl 0x48(%rsp), %edi
movl 0x4c(%rsp), %esi
movl 0x40(%rsp), %edx
movl 0x44(%rsp), %ecx
movl 0x50(%rsp), %r8d
movl %r12d, (%rsp)
movq %r14, %r9
callq 0xbd1a6
movq %rbx, %rdi
movq %r15, %rsi
callq 0xbd461
testl %eax, %eax
jne 0xbe25b
movq (%r14), %rax
cmpq %r13, %rax
je 0xbe474
cmpq %r13, %rax
jbe 0xbe462
movl 0x138(%rsp), %ebx
andb $0x3f, %bl
movapd 0x70(%rsp), %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movapd %xmm0, 0x10(%rsp)
incl %r12d
movl $0x2, %r15d
xorpd %xmm3, %xmm3
movq 0x178(%rbp), %rax
leaq (,%r13,4), %rcx
addq %r13, %rcx
movl 0x4(%rax,%rcx,8), %edx
cmpl (%rax,%rcx,8), %edx
jbe 0xbe453
leaq (%rax,%rcx,8), %r13
movl 0x18(%r13), %eax
cmpl 0x14(%r13), %eax
jbe 0xbe453
movq 0x138(%rbp), %rcx
movq 0x148(%rbp), %rax
cmpq 0x140(%rbp), %rcx
jne 0xbe343
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
cmoveq %r15, %rdx
movq %rdx, 0x140(%rbp)
shlq $0x4, %rdx
leaq (%rdx,%rdx,2), %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)
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
movb 0x28(%rax,%rcx), %dl
andb $-0x40, %dl
orb %bl, %dl
movb %dl, 0x28(%rax,%rcx)
movl 0x24(%r13), %edx
xorl 0x10(%r13), %edx
shlb $0x6, %dl
andb $0x40, %dl
orb %bl, %dl
movb %dl, 0x28(%rax,%rcx)
movl 0x10(%r13), %edx
shrl %edx
movl %edx, 0x8(%rax,%rcx)
movl (%r13), %esi
movl %esi, (%rax,%rcx)
movl 0x4(%r13), %edx
movl %edx, 0x4(%rax,%rcx)
movl 0x24(%r13), %edi
shrl %edi
subl %esi, %edx
ucomisd 0x70(%rsp), %xmm3
movl %edi, 0x14(%rax,%rcx)
movl 0x14(%r13), %edi
movl %edi, 0xc(%rax,%rcx)
movl 0x18(%r13), %esi
movl %esi, 0x10(%rax,%rcx)
jbe 0xbe3c8
subl %edi, %esi
cmpl %esi, %edx
cmovbl %edx, %esi
xorps %xmm0, %xmm0
cvtsi2sd %rsi, %xmm0
jmp 0xbe44b
movq 0x180(%rbp), %r8
movq 0x190(%rbp), %r9
leaq (%r8,%r8,8), %r10
leaq (%r10,%r10,2), %r10
addq %r8, %r10
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 0x177881(%rip), %xmm5   # 0x235c80
por %xmm5, %xmm1
subpd %xmm5, %xmm1
movq -0xc(%r9,%r10), %xmm0
movq 0x10(%r9), %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 0x10(%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)
movl %r12d, %r13d
incl %r12d
cmpq %r13, (%r14)
ja 0xbe2c7
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1d6b65(%rip), %rax    # 0x294fe0
movq (%rax), %rcx
leaq 0x178590(%rip), %rdi    # 0x236a15
movl $0x7, %esi
movl $0x1, %edx
callq 0x2410
movq (%r14), %rax
jmp 0xbe297
movq 0x1d6b3d(%rip), %rax    # 0x294fe0
movq (%rax), %rcx
leaq 0x178387(%rip), %rdi    # 0x236834
movl $0x7, %esi
movl $0x1, %edx
callq 0x2410
movq 0x180(%rbp), %rcx
movq 0x190(%rbp), %rax
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
movl -0xc(%rax,%rdx), %ecx
jmp 0xbe0b0
movq 0x1d6afb(%rip), %rax    # 0x294fe0
movq (%rax), %rcx
leaq 0x17833d(%rip), %rdi    # 0x23682c
movl $0x7, %esi
movl $0x1, %edx
callq 0x2410
movq 0x180(%rbp), %rcx
movq 0x190(%rbp), %rax
jmp 0xbe08b