// File: 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
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movq 0x40(%rbp), %rax
movl 0x38(%rbp), %eax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movl 0x20(%rbp), %eax
movl 0x18(%rbp), %eax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movsd %xmm0, -0x30(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq 0xa8(%rax), %rax
movq %rax, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0x78(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0xf9a9b
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
jmp 0xf9ac7
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq 0x30(%rbp), %rdx
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %r8
xorl %r9d, %r9d
movl $0x1, (%rsp)
callq 0xf7330
movl %eax, %eax
movq %rax, -0x48(%rbp)
cmpq $0x0, 0x28(%rbp)
je 0xf9adb
movq 0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
jmp 0xf9b07
movq 0x10(%rbp), %rdi
movl 0x18(%rbp), %esi
movq 0x30(%rbp), %rdx
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %r8
xorl %r9d, %r9d
movl $0x1, (%rsp)
callq 0xf7330
movl %eax, %eax
movq %rax, -0x50(%rbp)
movq $0x0, -0x70(%rbp)
movq -0x68(%rbp), %rax
movq $0x0, 0x180(%rax)
movq -0x68(%rbp), %rax
movq $0x0, 0x168(%rax)
movq -0x60(%rbp), %rax
cmpq $0x0, (%rax)
jbe 0xf9b55
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x60(%rbp), %rcx
movq 0x10(%rcx), %rcx
movslq (%rcx), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
je 0xf9b87
movl -0x20(%rbp), %eax
movq -0x70(%rbp), %rcx
movq 0x18(%rcx), %rcx
shrq $0x20, %rcx
cmpq %rcx, %rax
jae 0xf9d7b
movl 0x20(%rbp), %eax
movq -0x70(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpl %ecx, %eax
jae 0xf9d7b
jmp 0xf9b89
movq -0x68(%rbp), %rax
movq 0x180(%rax), %rax
movq -0x68(%rbp), %rcx
cmpq 0x188(%rcx), %rax
jne 0xf9c10
movq -0x68(%rbp), %rax
cmpq $0x0, 0x188(%rax)
je 0xf9bc6
movq -0x68(%rbp), %rax
movq 0x188(%rax), %rax
shlq %rax
movq %rax, -0x138(%rbp)
jmp 0xf9bd4
movl $0x2, %eax
movq %rax, -0x138(%rbp)
jmp 0xf9bd4
movq -0x138(%rbp), %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x188(%rax)
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rdi
movq -0x68(%rbp), %rax
imulq $0x1c, 0x188(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x190(%rax)
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rax
movq -0x68(%rbp), %rdx
movq 0x180(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x180(%rdx)
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movl -0x20(%rbp), %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0x10(%rax)
movl 0x20(%rbp), %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0x14(%rax)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x60(%rbp), %rcx
cmpq (%rcx), %rax
jae 0xf9d76
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x60(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x34(%rbp), %edx
movslq (%rcx,%rdx,4), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rax
movq 0x180(%rax), %rax
movq -0x68(%rbp), %rcx
cmpq 0x188(%rcx), %rax
jne 0xf9d13
movq -0x68(%rbp), %rax
cmpq $0x0, 0x188(%rax)
je 0xf9cc9
movq -0x68(%rbp), %rax
movq 0x188(%rax), %rax
shlq %rax
movq %rax, -0x140(%rbp)
jmp 0xf9cd7
movl $0x2, %eax
movq %rax, -0x140(%rbp)
jmp 0xf9cd7
movq -0x140(%rbp), %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x188(%rax)
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rdi
movq -0x68(%rbp), %rax
imulq $0x1c, 0x188(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x190(%rax)
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rax
movq -0x68(%rbp), %rdx
movq 0x180(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x180(%rdx)
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rax
movq 0x18(%rax), %rax
shrq $0x20, %rax
movl %eax, %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x70(%rbp), %rax
movq 0x18(%rax), %rax
movl %eax, %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0x14(%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xf9c5a
jmp 0xfa164
movq -0x60(%rbp), %rax
cmpq $0x1, (%rax)
jne 0xf9e5a
jmp 0xf9d8b
movq -0x68(%rbp), %rax
movq 0x180(%rax), %rax
movq -0x68(%rbp), %rcx
cmpq 0x188(%rcx), %rax
jne 0xf9e12
movq -0x68(%rbp), %rax
cmpq $0x0, 0x188(%rax)
je 0xf9dc8
movq -0x68(%rbp), %rax
movq 0x188(%rax), %rax
shlq %rax
movq %rax, -0x148(%rbp)
jmp 0xf9dd6
movl $0x2, %eax
movq %rax, -0x148(%rbp)
jmp 0xf9dd6
movq -0x148(%rbp), %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x188(%rax)
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rdi
movq -0x68(%rbp), %rax
imulq $0x1c, 0x188(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x190(%rax)
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rax
movq -0x68(%rbp), %rdx
movq 0x180(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x180(%rdx)
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movl -0x20(%rbp), %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0x10(%rax)
movl 0x20(%rbp), %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0x14(%rax)
jmp 0xfa162
movq -0x60(%rbp), %rax
cmpq $0x0, (%rax)
jbe 0xfa160
movl $0x0, -0x8c(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x60(%rbp), %rcx
cmpq (%rcx), %rax
jae 0xfa15e
movl $0xffffffff, -0x88(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x84(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x80(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x7c(%rbp) # imm = 0xFFFFFFFF
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x60(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x34(%rbp), %edx
movslq (%rcx,%rdx,4), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
shrq $0x20, %rax
movl %eax, -0x7c(%rbp)
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x60(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x34(%rbp), %edx
movslq (%rcx,%rdx,4), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movl %eax, -0x80(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movq -0x60(%rbp), %rcx
cmpq (%rcx), %rax
jae 0xf9f68
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x60(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x34(%rbp), %edx
addl $0x1, %edx
movl %edx, %edx
movslq (%rcx,%rdx,4), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
shrq $0x20, %rax
movl %eax, -0x84(%rbp)
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x60(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x34(%rbp), %edx
addl $0x1, %edx
movl %edx, %edx
movslq (%rcx,%rdx,4), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movl %eax, -0x88(%rbp)
jmp 0xf9f6a
movq -0x68(%rbp), %rax
movq 0x180(%rax), %rax
movq -0x68(%rbp), %rcx
cmpq 0x188(%rcx), %rax
jne 0xf9ff1
movq -0x68(%rbp), %rax
cmpq $0x0, 0x188(%rax)
je 0xf9fa7
movq -0x68(%rbp), %rax
movq 0x188(%rax), %rax
shlq %rax
movq %rax, -0x150(%rbp)
jmp 0xf9fb5
movl $0x2, %eax
movq %rax, -0x150(%rbp)
jmp 0xf9fb5
movq -0x150(%rbp), %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x188(%rax)
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rdi
movq -0x68(%rbp), %rax
imulq $0x1c, 0x188(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x190(%rax)
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rax
movq -0x68(%rbp), %rdx
movq 0x180(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x180(%rdx)
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movl -0x7c(%rbp), %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0x10(%rax)
movl -0x80(%rbp), %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0x14(%rax)
cmpl $0x0, -0x8c(%rbp)
je 0xfa042
jmp 0xfa150
movl -0x20(%rbp), %eax
cmpl -0x7c(%rbp), %eax
jbe 0xfa14e
movl -0x20(%rbp), %eax
cmpl -0x84(%rbp), %eax
jae 0xfa14e
movl 0x20(%rbp), %eax
cmpl -0x80(%rbp), %eax
jbe 0xfa14e
movl 0x20(%rbp), %eax
cmpl -0x88(%rbp), %eax
jae 0xfa14e
jmp 0xfa07a
movq -0x68(%rbp), %rax
movq 0x180(%rax), %rax
movq -0x68(%rbp), %rcx
cmpq 0x188(%rcx), %rax
jne 0xfa101
movq -0x68(%rbp), %rax
cmpq $0x0, 0x188(%rax)
je 0xfa0b7
movq -0x68(%rbp), %rax
movq 0x188(%rax), %rax
shlq %rax
movq %rax, -0x158(%rbp)
jmp 0xfa0c5
movl $0x2, %eax
movq %rax, -0x158(%rbp)
jmp 0xfa0c5
movq -0x158(%rbp), %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x188(%rax)
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rdi
movq -0x68(%rbp), %rax
imulq $0x1c, 0x188(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x190(%rax)
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rax
movq -0x68(%rbp), %rdx
movq 0x180(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x180(%rdx)
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movl -0x20(%rbp), %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0x10(%rax)
movl 0x20(%rbp), %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0x14(%rax)
movl $0x1, -0x8c(%rbp)
jmp 0xfa150
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xf9e79
jmp 0xfa160
jmp 0xfa162
jmp 0xfa164
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rax
movq -0x68(%rbp), %rcx
movq 0x180(%rcx), %rcx
subq $0x1, %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x48(%rbp), %rax
movq -0x78(%rbp), %rcx
movl 0x10(%rcx), %ecx
subq %rcx, %rax
movq -0x50(%rbp), %rcx
movq -0x78(%rbp), %rdx
movl 0x14(%rdx), %edx
subq %rdx, %rcx
cmpq %rcx, %rax
ja 0xfa1c1
movq -0x48(%rbp), %rax
movq -0x78(%rbp), %rcx
movl 0x10(%rcx), %ecx
subq %rcx, %rax
movq %rax, -0x160(%rbp)
jmp 0xfa1d6
movq -0x50(%rbp), %rax
movq -0x78(%rbp), %rcx
movl 0x14(%rcx), %ecx
subq %rcx, %rax
movq %rax, -0x160(%rbp)
movq -0x160(%rbp), %rax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
jbe 0xfa2fe
jmp 0xfa1ec
movq -0x68(%rbp), %rax
movq 0x180(%rax), %rax
movq -0x68(%rbp), %rcx
cmpq 0x188(%rcx), %rax
jne 0xfa273
movq -0x68(%rbp), %rax
cmpq $0x0, 0x188(%rax)
je 0xfa229
movq -0x68(%rbp), %rax
movq 0x188(%rax), %rax
shlq %rax
movq %rax, -0x168(%rbp)
jmp 0xfa237
movl $0x2, %eax
movq %rax, -0x168(%rbp)
jmp 0xfa237
movq -0x168(%rbp), %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x188(%rax)
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rdi
movq -0x68(%rbp), %rax
imulq $0x1c, 0x188(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x190(%rax)
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rax
movq -0x68(%rbp), %rdx
movq 0x180(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x180(%rdx)
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rax
movq -0x68(%rbp), %rcx
movq 0x180(%rcx), %rcx
subq $0x2, %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %ecx
addl -0x38(%rbp), %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rax
movq -0x68(%rbp), %rcx
movq 0x180(%rcx), %rcx
subq $0x2, %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %ecx
addl -0x38(%rbp), %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpl $0x0, 0x10(%rax)
je 0xfa4e6
movq -0x78(%rbp), %rax
cmpl $0x0, 0x14(%rax)
je 0xfa4e6
movq -0x78(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x78(%rbp), %rcx
cmpl 0x14(%rcx), %eax
ja 0xfa348
movq -0x78(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x16c(%rbp)
jmp 0xfa355
movq -0x78(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x16c(%rbp)
movl -0x16c(%rbp), %eax
movl %eax, -0x38(%rbp)
movq -0x68(%rbp), %rax
movq 0x180(%rax), %rax
movq -0x68(%rbp), %rcx
cmpq 0x188(%rcx), %rax
jne 0xfa3e5
movq -0x68(%rbp), %rax
cmpq $0x0, 0x188(%rax)
je 0xfa39b
movq -0x68(%rbp), %rax
movq 0x188(%rax), %rax
shlq %rax
movq %rax, -0x178(%rbp)
jmp 0xfa3a9
movl $0x2, %eax
movq %rax, -0x178(%rbp)
jmp 0xfa3a9
movq -0x178(%rbp), %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x188(%rax)
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rdi
movq -0x68(%rbp), %rax
imulq $0x1c, 0x188(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x190(%rax)
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rax
movq -0x68(%rbp), %rdx
movq 0x180(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x180(%rdx)
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movq -0x68(%rbp), %rcx
cmpq 0x180(%rcx), %rax
jae 0xfa4a8
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rcx
movq -0x68(%rbp), %rax
movq 0x180(%rax), %rax
movl -0x34(%rbp), %edx
subq %rdx, %rax
subq $0x2, %rax
imulq $0x1c, %rax, %rax
addq %rax, %rcx
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rax
movq -0x68(%rbp), %rdx
movq 0x180(%rdx), %rdx
movl -0x34(%rbp), %esi
subq %rsi, %rdx
subq $0x1, %rdx
imulq $0x1c, %rdx, %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movl 0x18(%rcx), %ecx
movl %ecx, 0x18(%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xfa41b
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rax
movl 0x2c(%rax), %ecx
subl -0x38(%rbp), %ecx
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rax
movl %ecx, 0x10(%rax)
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rax
movl 0x30(%rax), %ecx
subl -0x38(%rbp), %ecx
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rax
movl %ecx, 0x14(%rax)
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rax
cmpl $0x0, 0x10(%rax)
je 0xfa520
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rax
cmpl $0x0, 0x14(%rax)
je 0xfa520
movq 0x2c9ad1(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
leaq 0x28cd41(%rip), %rsi    # 0x38725a
movb $0x0, %al
callq 0x22a0
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rax
movq -0x68(%rbp), %rcx
movq 0x180(%rcx), %rcx
subq $0x1, %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
cmpq -0x48(%rbp), %rax
je 0xfa58c
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rax
movq -0x68(%rbp), %rcx
movq 0x180(%rcx), %rcx
subq $0x1, %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
cmpq -0x50(%rbp), %rax
je 0xfa58c
movq 0x2c9a65(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
leaq 0x28ccdd(%rip), %rsi    # 0x387262
movb $0x0, %al
callq 0x22a0
movq $0x0, -0x118(%rbp)
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movq 0x30(%rbp), %rcx
movq -0x10(%rbp), %r8
movq -0x68(%rbp), %r9
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rax
movl 0x10(%rax), %r10d
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rax
movq -0x68(%rbp), %rdi
movq 0x180(%rdi), %rdi
subq $0x1, %rdi
imulq $0x1c, %rdi, %rdi
addq %rdi, %rax
movl 0x10(%rax), %eax
leaq -0xe8(%rbp), %rdi
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0xf8900
leaq -0xe8(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0xf89e0
cmpl $0x0, %eax
je 0xfa6ec
movq -0x68(%rbp), %rsi
addq $0x180, %rsi            # imm = 0x180
leaq -0x110(%rbp), %rdi
callq 0xf8090
movq -0x68(%rbp), %rax
movq 0x168(%rax), %rax
movq -0x68(%rbp), %rcx
cmpq 0x170(%rcx), %rax
jne 0xfa6ab
movq -0x68(%rbp), %rax
cmpq $0x0, 0x170(%rax)
je 0xfa661
movq -0x68(%rbp), %rax
movq 0x170(%rax), %rax
shlq %rax
movq %rax, -0x180(%rbp)
jmp 0xfa66f
movl $0x2, %eax
movq %rax, -0x180(%rbp)
jmp 0xfa66f
movq -0x180(%rbp), %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x170(%rax)
movq -0x68(%rbp), %rax
movq 0x178(%rax), %rdi
movq -0x68(%rbp), %rax
imulq $0x28, 0x170(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x178(%rax)
movq -0x68(%rbp), %rax
movq 0x178(%rax), %rdi
movq -0x68(%rbp), %rcx
movq 0x168(%rcx), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x168(%rcx)
imulq $0x28, %rax, %rax
addq %rax, %rdi
leaq -0x110(%rbp), %rsi
movl $0x28, %edx
callq 0x2180
jmp 0xfa5f1
movq -0x68(%rbp), %rax
movq 0x168(%rax), %rax
movl %eax, -0x3c(%rbp)
movq 0x10(%rbp), %rsi
movl 0x18(%rbp), %edx
movq 0x30(%rbp), %rcx
movq -0x10(%rbp), %r8
movq -0x68(%rbp), %r9
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rax
movl 0x14(%rax), %r10d
movq -0x68(%rbp), %rax
movq 0x190(%rax), %rax
movq -0x68(%rbp), %rdi
movq 0x180(%rdi), %rdi
subq $0x1, %rdi
imulq $0x1c, %rdi, %rdi
addq %rdi, %rax
movl 0x14(%rax), %eax
leaq -0xe8(%rbp), %rdi
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0xf8900
leaq -0xe8(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0xf89e0
cmpl $0x0, %eax
je 0xfa7a3
movl -0x108(%rbp), %edi
movl -0x104(%rbp), %esi
movl -0x110(%rbp), %edx
movl -0x10c(%rbp), %ecx
movl -0x100(%rbp), %r8d
movq -0x68(%rbp), %r9
addq $0x168, %r9             # imm = 0x168
movl -0x3c(%rbp), %eax
movl %eax, (%rsp)
callq 0xf8400
jmp 0xfa754
movq -0x68(%rbp), %rax
movq 0x168(%rax), %rax
movl -0x3c(%rbp), %ecx
subq %rcx, %rax
cmpq $0x0, %rax
jne 0xfa7d2
movq 0x2c981f(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
leaq 0x28cc78(%rip), %rsi    # 0x387443
movb $0x0, %al
callq 0x22a0
movq $0x0, -0x120(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x68(%rbp), %rcx
cmpq 0x168(%rcx), %rax
jae 0xfab62
movq -0x68(%rbp), %rax
movq 0x178(%rax), %rax
movl -0x34(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x118(%rbp)
movq -0x118(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x118(%rbp), %rcx
cmpl (%rcx), %eax
ja 0xfa82d
jmp 0xfab54
movq -0x118(%rbp), %rax
movl 0x18(%rax), %eax
movq -0x118(%rbp), %rcx
cmpl 0x14(%rcx), %eax
ja 0xfa848
jmp 0xfab54
jmp 0xfa84a
movq -0x68(%rbp), %rax
movq 0x138(%rax), %rax
movq -0x68(%rbp), %rcx
cmpq 0x140(%rcx), %rax
jne 0xfa8d1
movq -0x68(%rbp), %rax
cmpq $0x0, 0x140(%rax)
je 0xfa887
movq -0x68(%rbp), %rax
movq 0x140(%rax), %rax
shlq %rax
movq %rax, -0x188(%rbp)
jmp 0xfa895
movl $0x2, %eax
movq %rax, -0x188(%rbp)
jmp 0xfa895
movq -0x188(%rbp), %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x140(%rax)
movq -0x68(%rbp), %rax
movq 0x148(%rax), %rdi
movq -0x68(%rbp), %rax
imulq $0x30, 0x140(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x148(%rax)
movq -0x68(%rbp), %rax
movq 0x148(%rax), %rax
movq -0x68(%rbp), %rdx
movq 0x138(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x138(%rdx)
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x120(%rbp)
movl 0x38(%rbp), %eax
movb %al, %dl
movq -0x120(%rbp), %rax
movb 0x28(%rax), %cl
andb $0x3f, %dl
andb $-0x40, %cl
orb %dl, %cl
movb %cl, 0x28(%rax)
movq -0x118(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x118(%rbp), %rcx
xorl 0x24(%rcx), %eax
andl $0x1, %eax
movb %al, %dl
movq -0x120(%rbp), %rax
movb 0x28(%rax), %cl
andb $0x1, %dl
shlb $0x6, %dl
andb $-0x41, %cl
orb %dl, %cl
movb %cl, 0x28(%rax)
movq -0x120(%rbp), %rax
movb 0x28(%rax), %cl
andb $0x7f, %cl
orb $0x0, %cl
movb %cl, 0x28(%rax)
movq -0x118(%rbp), %rax
movl 0x10(%rax), %ecx
shrl %ecx
movq -0x120(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x118(%rbp), %rax
movl (%rax), %ecx
movq -0x120(%rbp), %rax
movl %ecx, (%rax)
movq -0x118(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x120(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x118(%rbp), %rax
movl 0x24(%rax), %ecx
shrl %ecx
movq -0x120(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x118(%rbp), %rax
movl 0x14(%rax), %ecx
movq -0x120(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x118(%rbp), %rax
movl 0x18(%rax), %ecx
movq -0x120(%rbp), %rax
movl %ecx, 0x10(%rax)
xorps %xmm0, %xmm0
ucomisd -0x30(%rbp), %xmm0
jbe 0xfaa63
movq -0x120(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x120(%rbp), %rcx
subl (%rcx), %eax
movq -0x120(%rbp), %rcx
movl 0x10(%rcx), %ecx
movq -0x120(%rbp), %rdx
subl 0xc(%rdx), %ecx
cmpl %ecx, %eax
ja 0xfaa2b
movq -0x120(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x120(%rbp), %rcx
subl (%rcx), %eax
movl %eax, -0x18c(%rbp)
jmp 0xfaa45
movq -0x120(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x120(%rbp), %rcx
subl 0xc(%rcx), %eax
movl %eax, -0x18c(%rbp)
movl -0x18c(%rbp), %eax
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movq -0x120(%rbp), %rax
movsd %xmm0, 0x20(%rax)
jmp 0xfab52
movq -0x120(%rbp), %rax
movl (%rax), %ecx
movl 0x4(%rax), %eax
subl %ecx, %eax
cvtsi2sd %rax, %xmm0
movq -0x68(%rbp), %rax
movq 0x180(%rax), %rdx
movq 0x190(%rax), %rcx
leaq (%rdx,%rdx,8), %rax
leaq (%rax,%rax,2), %rax
addq %rdx, %rax
movl -0xc(%rcx,%rax), %eax
movl 0x10(%rcx), %ecx
subl %ecx, %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd -0x30(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x128(%rbp)
movq -0x120(%rbp), %rax
movl 0xc(%rax), %ecx
movl 0x10(%rax), %eax
subl %ecx, %eax
cvtsi2sd %rax, %xmm0
movq -0x68(%rbp), %rax
movq 0x180(%rax), %rdx
movq 0x190(%rax), %rcx
leaq (%rdx,%rdx,8), %rax
leaq (%rax,%rax,2), %rax
addq %rdx, %rax
movl -0x8(%rcx,%rax), %eax
movl 0x14(%rcx), %ecx
subl %ecx, %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
mulsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x130(%rbp)
movsd -0x128(%rbp), %xmm1
movsd -0x130(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0xfab2e
movsd -0x128(%rbp), %xmm0
movsd %xmm0, -0x198(%rbp)
jmp 0xfab3e
movsd -0x130(%rbp), %xmm0
movsd %xmm0, -0x198(%rbp)
movsd -0x198(%rbp), %xmm0
movq -0x120(%rbp), %rax
movsd %xmm0, 0x20(%rax)
jmp 0xfab54
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xfa7e3
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
nopl (%rax,%rax)