// File: chhylp123[P]hifiasm/horder.cpp
// Function: update_scg(horder_t*, trans_col_t*)
void update_scg(horder_t *h, trans_col_t *t_idx)
{
    uint64_t i, k, l, p0s, p0e, p1s, p1e, span_s, span_e, suid, euid, v, w, slen, elen, sd, ed;
    uint64_t t_hits = 0, a_hits = 0;
    double max_div, we;
    h_w_t e; kv_init(e);
    dens_idx_t *idx = NULL;
    hw_aux_t *ep = NULL;
    ma_ug_t *ug = h->ug;
    kvec_pe_hit *hits = &(h->u_hits);
    osg_arc_t *p = NULL;
    osg_destroy(h->sg.g); 
    h->sg.g = osg_init();
    for (i = 0; i < ug->u.n; i++) {
        osg_seq_set(h->sg.g, i, 0);
        h->sg.g->seq[i].mw[0] = h->sg.g->seq[i].mw[1] = 0;
        h->sg.g->seq[i].ez[0] = ug->u.a[i].len>>1;
        h->sg.g->seq[i].ez[1] = ug->u.a[i].len - (ug->u.a[i].len>>1);
    }
    idx = build_interval_idx(hits, ug);///idx is used to get density
    
    for (i = 0, e.n = 0; i < hits->a.n; i++) {
        if(!hits->a.a[i].id) continue;//hom hits
        suid = get_hit_suid(*hits, i);
        euid = get_hit_euid(*hits, i);
        if(suid == euid) continue;//same unitig
        slen = ug->u.a[suid].len;
        elen = ug->u.a[euid].len;

        p0s = get_hit_spos(*hits, i);
        p0e = get_hit_spos_e(*hits, i);
        span_s = MIN(p0s, p0e);
        span_s = MIN(span_s, slen-1);
        span_e = MAX(p0s, p0e);
        span_e =  MIN(span_e, slen-1);
        span_s = ((span_s+span_e)>>1);
        sd = span_s;
        v = suid << 1;
        if(span_s > (slen>>1)) v++;


        p1s = get_hit_epos(*hits, i);
        p1e = get_hit_epos_e(*hits, i);
        span_s = MIN(p1s, p1e);
        span_s = MIN(span_s, elen-1);
        span_e = MAX(p1s, p1e);
        span_e =  MIN(span_e, elen-1);
        span_s = ((span_s+span_e)>>1);
        ed = span_s;
        w = euid << 1;
        if(span_s > (elen>>1)) w++;
        t_hits++;
        
        kv_pushp(hw_aux_t, e, &ep);
        ep->w = 0;
        ep->e = (v<<32)|w; 
        ep->d = (sd<<32)|ed;

        if(v > w) {
            ep->e = (w<<32)|v;
            ep->d = (ed<<32)|sd;
        } 
        
        // div = h->sg.g->seq[v>>1].ez[v&1] + h->sg.g->seq[w>>1].ez[w&1];
        // max_div = MAX(max_div, div);
        a_hits++;
    }

    // fprintf(stderr, "sa-0-sa: occ-%lu\n", get_vw_hits_num(&e, 12, 690));
    // print_specfic_hic_hits(hits, 12, 690, ug);

    
    
    update_h_w(&e, idx, &max_div);

    // fprintf(stderr, "sa-1-sa: occ-%lu\n", get_vw_hits_num(&e, 676, 738));

    radix_sort_hw_e(e.a, e.a+e.n);
    for (k = 1, l = 0; k <= e.n; ++k) 
    {   
        if (k == e.n || e.a[k].e != e.a[l].e) 
        {
            for (i = 0; i < h->avoid.n; i++)
            {
                v = e.a[l].e;
                w = e.a[l].e<<32; w |= (e.a[l].e>>32);
                if(h->avoid.a[i] == v || h->avoid.a[i] == w)
                {
                    break;
                }
            }

            if(i >= h->avoid.n)
            {
                for (i = l, we = 0; i < k; i++)
                {
                    if(e.a[i].w == 0) fprintf(stderr, "ERROR-3\n");
                    we += (max_div/e.a[i].w);
                }
                
                p = osg_arc_pushp(h->sg.g);
                p->u = p->v = p->occ = p->del = p->w = p->nw = 0;
                p->u = e.a[l].e>>32; p->v = (uint32_t)e.a[l].e;
                p->occ = k - l; p->w = we;
                // if(div != 0) p->w = (double)(k - l)*(max_div/div);
                p = osg_arc_pushp(h->sg.g);
                p->u = p->v = p->occ = p->del = p->w = p->nw = 0;
                p->u = (uint32_t)e.a[l].e; p->v = e.a[l].e>>32;
                p->occ = k - l; p->w = we;
                

                h->sg.g->seq[e.a[l].e>>33].mw[(e.a[l].e>>32)&1] 
                                = MAX(h->sg.g->seq[e.a[l].e>>33].mw[(e.a[l].e>>32)&1], p->w);
                h->sg.g->seq[((uint32_t)e.a[l].e)>>1].mw[e.a[l].e&1]
                                = MAX(h->sg.g->seq[((uint32_t)e.a[l].e)>>1].mw[e.a[l].e&1], p->w);
            }

            l = k;
        }
    }

    // fprintf(stderr, "sa-2-sa: occ-%lu\n", get_vw_hits_num(&e, 676, 738));
    osg_cleanup(h->sg.g);
    double bestAlt;
    uint64_t eg_edges = 0;
    for (i = 0; i < h->sg.g->n_arc; i++)///all p->w should be >= 2
    {
        p = &(h->sg.g->arc[i]);
        bestAlt = MAX(h->sg.g->seq[p->u>>1].mw[p->u&1], h->sg.g->seq[p->v>>1].mw[p->v&1]);
        if(p->w >= bestAlt*0.95)///acutally should be p->w == bestAlt
        {
            bestAlt = get_max_weight(p->u, p->v, h->sg.g);
        }

        if(bestAlt == 0) bestAlt = 1;
        ///if there is just one edges between p->u and p->v, then bestAlt -> p->nw <= 1; this is wrong
        p->nw = p->w/bestAlt;
        if(p->nw > 1) eg_edges++;
    }

    fprintf(stderr, "[M::%s::] # Nodes: %u, # Edges: %u, # Best Edges: %lu, t_hits: %lu, a_hits: %lu\n", 
    __func__, h->sg.g->n_seq, h->sg.g->n_arc, eg_edges, t_hits, a_hits);

    /*******************************for debug************************************/
    /**
    for (i = 0; i < h->sg.g->n_arc; i++)
    {
        p = &(h->sg.g->arc[i]);
        fprintf(stderr, "u-stg%.6ul(%c)(div:%f)\tv-stg%.6ul(%c)(div:%f)\tocc:%u\tw:%f\tnw:%f\n", 
        (p->u>>1)+1, "+-"[p->u&1], h->sg.g->seq[p->u>>1].ez[p->u&1],
        (p->v>>1)+1, "+-"[p->v&1], h->sg.g->seq[p->v>>1].ez[p->v&1], p->occ, p->w, p->nw);
    }
    fprintf(stderr, "sbsbsbsb\n\n\n\n\n\n");
    **/
    
    // uint32_t u, nv, f;
    // osg_arc_t *av = NULL;
    // for (k = 0; k < h->sg.g->n_arc; k++)
    // {
    //     p = &(h->sg.g->arc[k]);
    //     u = p->u; v = p->v;
    //     f = 0;

    //     nv = asg_arc_n(h->sg.g, u);
    //     av = asg_arc_a(h->sg.g, u);
    //     for (i = 0; i < nv; i++)
    //     {
    //         if(av[i].v == v) continue;
    //         if(av[i].w > p->w) f = 1;
    //     }

    //     nv = asg_arc_n(h->sg.g, v);
    //     av = asg_arc_a(h->sg.g, v);
    //     for (i = 0; i < nv; i++)
    //     {
    //         if(av[i].v == u) continue;
    //         if(av[i].w > p->w) f = 1;
    //     }

    //     if(p->nw > 1 && f == 1) fprintf(stderr, "ERROR1\n");
    //     if(p->nw <= 1 && f == 0)
    //     {
    //         fprintf(stderr, "\nERROR2, nw-%f, w-%f, u-%u, v-%u\n", p->nw, p->w, p->u, p->v);
    //          nv = asg_arc_n(h->sg.g, u);
    //         av = asg_arc_a(h->sg.g, u);
    //         for (i = 0; i < nv; i++)
    //         {
    //             if(av[i].v == v) continue;
    //             fprintf(stderr, "+u-%u, v-%u, w-%f\n", av[i].u, av[i].v, av[i].w);
    //         }

    //         nv = asg_arc_n(h->sg.g, v);
    //         av = asg_arc_a(h->sg.g, v);
    //         for (i = 0; i < nv; i++)
    //         {
    //             if(av[i].v == u) continue;
    //             fprintf(stderr, "-u-%u, v-%u, w-%f\n", av[i].u, av[i].v, av[i].w);
    //         }
    //     } 
        
    // }
    /*******************************for debug************************************/
    kv_destroy(e); 
    free(idx->pos.a);
    free(idx->a);
    free(idx);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0xa0(%rbp)
movq $0x0, -0xa8(%rbp)
movq $0x0, -0xc0(%rbp)
movq $0x0, -0xc8(%rbp)
movq $0x0, -0xd0(%rbp)
movq $0x0, -0xd8(%rbp)
movq $0x0, -0xe0(%rbp)
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rax
movq %rax, -0xe8(%rbp)
movq -0x8(%rbp), %rax
addq $0x70, %rax
movq %rax, -0xf0(%rbp)
movq $0x0, -0xf8(%rbp)
movq -0x8(%rbp), %rax
movq 0xd8(%rax), %rdi
callq 0x23f890
callq 0x23f870
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0xd8(%rax)
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0xe8(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x241806
movq -0x8(%rbp), %rax
movq 0xd8(%rax), %rdi
movq -0x18(%rbp), %rax
movl %eax, %esi
xorl %edx, %edx
callq 0x23f8e0
movq -0x8(%rbp), %rax
movq 0xd8(%rax), %rax
movq 0x18(%rax), %rax
imulq $0x28, -0x18(%rbp), %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0xd8(%rax), %rax
movq 0x18(%rax), %rax
imulq $0x28, -0x18(%rbp), %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movq -0xe8(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x18(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
sarl %eax
cvtsi2sd %eax, %xmm0
movq -0x8(%rbp), %rax
movq 0xd8(%rax), %rax
movq 0x18(%rax), %rax
imulq $0x28, -0x18(%rbp), %rcx
addq %rcx, %rax
movsd %xmm0, 0x10(%rax)
movq -0xe8(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x18(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq -0xe8(%rbp), %rcx
movq 0x10(%rcx), %rcx
imulq $0x28, -0x18(%rbp), %rdx
addq %rdx, %rcx
movl (%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
sarl %ecx
subl %ecx, %eax
cvtsi2sd %eax, %xmm0
movq -0x8(%rbp), %rax
movq 0xd8(%rax), %rax
movq 0x18(%rax), %rax
imulq $0x28, -0x18(%rbp), %rcx
addq %rcx, %rax
movsd %xmm0, 0x18(%rax)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x2416f7
movq -0xf0(%rbp), %rdi
movq -0xe8(%rbp), %rsi
callq 0x23fee0
movq %rax, -0xd8(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0xc8(%rbp)
movq -0x18(%rbp), %rax
movq -0xf0(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x241f4c
movq -0xf0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpq $0x0, 0x10(%rax)
jne 0x241869
jmp 0x241f3b
movq -0xf0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
shlq %rax
movq -0xf0(%rbp), %rdx
movl $0x40, %ecx
subq 0x48(%rdx), %rcx
shrq %cl, %rax
movq %rax, -0x60(%rbp)
movq -0xf0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
shlq %rax
movq -0xf0(%rbp), %rdx
movl $0x40, %ecx
subq 0x48(%rdx), %rcx
shrq %cl, %rax
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rax
cmpq -0x68(%rbp), %rax
jne 0x2418df
jmp 0x241f3b
movq -0xe8(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x60(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movq %rax, -0x80(%rbp)
movq -0xe8(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x68(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movq %rax, -0x88(%rbp)
movq -0xf0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0xf0(%rbp), %rcx
andq 0x50(%rcx), %rax
movq %rax, -0x30(%rbp)
movq -0xf0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
shrq $0x3f, %rax
cmpq $0x0, %rax
je 0x241a29
movq -0xf0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0xf0(%rbp), %rcx
andq 0x50(%rcx), %rax
addq $0x1, %rax
movq -0xf0(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x18(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movq 0x18(%rcx), %rcx
shrq $0x20, %rcx
cmpq %rcx, %rax
jb 0x241a0e
movq -0xf0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0xf0(%rbp), %rcx
andq 0x50(%rcx), %rax
addq $0x1, %rax
movq -0xf0(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x18(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movq 0x18(%rcx), %rcx
shrq $0x20, %rcx
subq %rcx, %rax
movq %rax, -0x110(%rbp)
jmp 0x241a19
xorl %eax, %eax
movq %rax, -0x110(%rbp)
jmp 0x241a19
movq -0x110(%rbp), %rax
movq %rax, -0x118(%rbp)
jmp 0x241a79
movq -0xf0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0xf0(%rbp), %rcx
andq 0x50(%rcx), %rax
movq -0xf0(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x18(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movq 0x18(%rcx), %rcx
shrq $0x20, %rcx
addq %rcx, %rax
subq $0x1, %rax
movq %rax, -0x118(%rbp)
movq -0x118(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x38(%rbp), %rax
ja 0x241a9b
movq -0x30(%rbp), %rax
movq %rax, -0x120(%rbp)
jmp 0x241aa6
movq -0x38(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0x120(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x80(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
ja 0x241acf
movq -0x50(%rbp), %rax
movq %rax, -0x128(%rbp)
jmp 0x241ade
movq -0x80(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x128(%rbp)
movq -0x128(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x38(%rbp), %rax
jb 0x241b00
movq -0x30(%rbp), %rax
movq %rax, -0x130(%rbp)
jmp 0x241b0b
movq -0x38(%rbp), %rax
movq %rax, -0x130(%rbp)
movq -0x130(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq -0x80(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
ja 0x241b34
movq -0x58(%rbp), %rax
movq %rax, -0x138(%rbp)
jmp 0x241b43
movq -0x80(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x138(%rbp)
movq -0x138(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
addq -0x58(%rbp), %rax
shrq %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x60(%rbp), %rax
shlq %rax
movq %rax, -0x70(%rbp)
movq -0x50(%rbp), %rax
movq -0x80(%rbp), %rcx
shrq %rcx
cmpq %rcx, %rax
jbe 0x241b8f
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
movq -0xf0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq -0xf0(%rbp), %rcx
andq 0x50(%rcx), %rax
movq %rax, -0x40(%rbp)
movq -0xf0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
shrq $0x3f, %rax
cmpq $0x0, %rax
je 0x241c96
movq -0xf0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq -0xf0(%rbp), %rcx
andq 0x50(%rcx), %rax
addq $0x1, %rax
movq -0xf0(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x18(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movq 0x18(%rcx), %rcx
movl %ecx, %ecx
cmpq %rcx, %rax
jb 0x241c7b
movq -0xf0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq -0xf0(%rbp), %rcx
andq 0x50(%rcx), %rax
addq $0x1, %rax
movq -0xf0(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x18(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movq 0x18(%rcx), %rcx
movl %ecx, %ecx
subq %rcx, %rax
movq %rax, -0x140(%rbp)
jmp 0x241c86
xorl %eax, %eax
movq %rax, -0x140(%rbp)
jmp 0x241c86
movq -0x140(%rbp), %rax
movq %rax, -0x148(%rbp)
jmp 0x241ce5
movq -0xf0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq -0xf0(%rbp), %rcx
andq 0x50(%rcx), %rax
movq -0xf0(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x18(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movq 0x18(%rcx), %rcx
movl %ecx, %ecx
addq %rcx, %rax
subq $0x1, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x48(%rbp), %rax
ja 0x241d07
movq -0x40(%rbp), %rax
movq %rax, -0x150(%rbp)
jmp 0x241d12
movq -0x48(%rbp), %rax
movq %rax, -0x150(%rbp)
movq -0x150(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x88(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
ja 0x241d3e
movq -0x50(%rbp), %rax
movq %rax, -0x158(%rbp)
jmp 0x241d50
movq -0x88(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x158(%rbp)
movq -0x158(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x48(%rbp), %rax
jb 0x241d72
movq -0x40(%rbp), %rax
movq %rax, -0x160(%rbp)
jmp 0x241d7d
movq -0x48(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0x160(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq -0x88(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
ja 0x241da9
movq -0x58(%rbp), %rax
movq %rax, -0x168(%rbp)
jmp 0x241dbb
movq -0x88(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x168(%rbp)
movq -0x168(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
addq -0x58(%rbp), %rax
shrq %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x68(%rbp), %rax
shlq %rax
movq %rax, -0x78(%rbp)
movq -0x50(%rbp), %rax
movq -0x88(%rbp), %rcx
shrq %rcx
cmpq %rcx, %rax
jbe 0x241e0a
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
movq -0xa0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa0(%rbp)
movq -0xc8(%rbp), %rax
cmpq -0xc0(%rbp), %rax
jne 0x241e80
cmpq $0x0, -0xc0(%rbp)
je 0x241e49
movq -0xc0(%rbp), %rax
shlq %rax
movq %rax, -0x170(%rbp)
jmp 0x241e57
movl $0x2, %eax
movq %rax, -0x170(%rbp)
jmp 0x241e57
movq -0x170(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0xd0(%rbp), %rdi
imulq $0x18, -0xc0(%rbp), %rsi
callq 0x2360
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rax
movq -0xc8(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0xc8(%rbp)
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xe0(%rbp)
movq -0xe0(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x10(%rax)
movq -0x70(%rbp), %rcx
shlq $0x20, %rcx
orq -0x78(%rbp), %rcx
movq -0xe0(%rbp), %rax
movq %rcx, (%rax)
movq -0x90(%rbp), %rcx
shlq $0x20, %rcx
orq -0x98(%rbp), %rcx
movq -0xe0(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x70(%rbp), %rax
cmpq -0x78(%rbp), %rax
jbe 0x241f29
movq -0x78(%rbp), %rcx
shlq $0x20, %rcx
orq -0x70(%rbp), %rcx
movq -0xe0(%rbp), %rax
movq %rcx, (%rax)
movq -0x98(%rbp), %rcx
shlq $0x20, %rcx
orq -0x90(%rbp), %rcx
movq -0xe0(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0xa8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa8(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x241833
movq -0xd8(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
leaq -0xb0(%rbp), %rdx
callq 0x240720
movq -0xd0(%rbp), %rdi
movq -0xd0(%rbp), %rsi
imulq $0x18, -0xc8(%rbp), %rax
addq %rax, %rsi
callq 0x22ee00
movq $0x1, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x20(%rbp), %rax
cmpq -0xc8(%rbp), %rax
ja 0x242544
movq -0x20(%rbp), %rax
cmpq -0xc8(%rbp), %rax
je 0x241fdc
movq -0xd0(%rbp), %rax
imulq $0x18, -0x20(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0xd0(%rbp), %rcx
imulq $0x18, -0x28(%rbp), %rdx
addq %rdx, %rcx
cmpq (%rcx), %rax
je 0x242531
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x242084
movq -0xd0(%rbp), %rax
imulq $0x18, -0x28(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x70(%rbp)
movq -0xd0(%rbp), %rax
imulq $0x18, -0x28(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
shlq $0x20, %rax
movq %rax, -0x78(%rbp)
movq -0xd0(%rbp), %rax
imulq $0x18, -0x28(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
shrq $0x20, %rax
orq -0x78(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpq -0x70(%rbp), %rax
je 0x24206f
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpq -0x78(%rbp), %rax
jne 0x242071
jmp 0x242084
jmp 0x242073
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x241fe4
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq (%rcx), %rax
jb 0x242529
movq -0x28(%rbp), %rax
movq %rax, -0x18(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0xb8(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x242123
movq -0xd0(%rbp), %rax
imulq $0x18, -0x18(%rbp), %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x2420e9
jp 0x2420e9
movq 0x181f08(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
leaq 0x145b7c(%rip), %rsi    # 0x387c5e
movb $0x0, %al
callq 0x22a0
movsd -0xb0(%rbp), %xmm0
movq -0xd0(%rbp), %rax
imulq $0x18, -0x18(%rbp), %rcx
addq %rcx, %rax
divsd 0x10(%rax), %xmm0
addsd -0xb8(%rbp), %xmm0
movsd %xmm0, -0xb8(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x2420a8
movq -0x8(%rbp), %rax
movq 0xd8(%rax), %rdi
callq 0x242830
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x18(%rax)
movq -0xf8(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x10(%rax)
movq -0xf8(%rbp), %rax
movl 0x8(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x0, %ecx
movl %ecx, 0x8(%rax)
movq -0xf8(%rbp), %rax
movl 0x8(%rax), %ecx
andl $0x80000000, %ecx       # imm = 0x80000000
orl $0x0, %ecx
movl %ecx, 0x8(%rax)
movq -0xf8(%rbp), %rax
movl $0x0, (%rax)
movq -0xf8(%rbp), %rax
movl $0x0, 0x4(%rax)
movq -0xd0(%rbp), %rax
imulq $0x18, -0x28(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
shrq $0x20, %rax
movl %eax, %ecx
movq -0xf8(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0xd0(%rbp), %rax
imulq $0x18, -0x28(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, %ecx
movq -0xf8(%rbp), %rax
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
subq -0x28(%rbp), %rax
movl %eax, %edx
movq -0xf8(%rbp), %rax
movl 0x8(%rax), %ecx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl $0x80000000, %ecx       # imm = 0x80000000
orl %edx, %ecx
movl %ecx, 0x8(%rax)
movsd -0xb8(%rbp), %xmm0
movq -0xf8(%rbp), %rax
movsd %xmm0, 0x10(%rax)
movq -0x8(%rbp), %rax
movq 0xd8(%rax), %rdi
callq 0x242830
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x18(%rax)
movq -0xf8(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x10(%rax)
movq -0xf8(%rbp), %rax
movl 0x8(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x0, %ecx
movl %ecx, 0x8(%rax)
movq -0xf8(%rbp), %rax
movl 0x8(%rax), %ecx
andl $0x80000000, %ecx       # imm = 0x80000000
orl $0x0, %ecx
movl %ecx, 0x8(%rax)
movq -0xf8(%rbp), %rax
movl $0x0, (%rax)
movq -0xf8(%rbp), %rax
movl $0x0, 0x4(%rax)
movq -0xd0(%rbp), %rax
imulq $0x18, -0x28(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, %ecx
movq -0xf8(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0xd0(%rbp), %rax
imulq $0x18, -0x28(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
shrq $0x20, %rax
movl %eax, %ecx
movq -0xf8(%rbp), %rax
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
subq -0x28(%rbp), %rax
movl %eax, %edx
movq -0xf8(%rbp), %rax
movl 0x8(%rax), %ecx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl $0x80000000, %ecx       # imm = 0x80000000
orl %edx, %ecx
movl %ecx, 0x8(%rax)
movsd -0xb8(%rbp), %xmm0
movq -0xf8(%rbp), %rax
movsd %xmm0, 0x10(%rax)
movq -0x8(%rbp), %rax
movq 0xd8(%rax), %rax
movq 0x18(%rax), %rax
movq -0xd0(%rbp), %rcx
imulq $0x18, -0x28(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
shrq $0x21, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq -0xd0(%rbp), %rcx
imulq $0x18, -0x28(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
shrq $0x20, %rcx
andq $0x1, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0xf8(%rbp), %rax
ucomisd 0x10(%rax), %xmm0
jb 0x2423b9
movq -0x8(%rbp), %rax
movq 0xd8(%rax), %rax
movq 0x18(%rax), %rax
movq -0xd0(%rbp), %rcx
imulq $0x18, -0x28(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
shrq $0x21, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq -0xd0(%rbp), %rcx
imulq $0x18, -0x28(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
shrq $0x20, %rcx
andq $0x1, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x178(%rbp)
jmp 0x2423cd
movq -0xf8(%rbp), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x178(%rbp)
movsd -0x178(%rbp), %xmm0
movq -0x8(%rbp), %rax
movq 0xd8(%rax), %rax
movq 0x18(%rax), %rax
movq -0xd0(%rbp), %rcx
imulq $0x18, -0x28(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
shrq $0x21, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq -0xd0(%rbp), %rcx
imulq $0x18, -0x28(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
shrq $0x20, %rcx
andq $0x1, %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x8(%rbp), %rax
movq 0xd8(%rax), %rax
movq 0x18(%rax), %rax
movq -0xd0(%rbp), %rcx
imulq $0x18, -0x28(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq -0xd0(%rbp), %rcx
imulq $0x18, -0x28(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
andq $0x1, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0xf8(%rbp), %rax
ucomisd 0x10(%rax), %xmm0
jb 0x2424c6
movq -0x8(%rbp), %rax
movq 0xd8(%rax), %rax
movq 0x18(%rax), %rax
movq -0xd0(%rbp), %rcx
imulq $0x18, -0x28(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq -0xd0(%rbp), %rcx
imulq $0x18, -0x28(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
andq $0x1, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x180(%rbp)
jmp 0x2424da
movq -0xf8(%rbp), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x180(%rbp)
movsd -0x180(%rbp), %xmm0
movq -0x8(%rbp), %rax
movq 0xd8(%rax), %rax
movq 0x18(%rax), %rax
movq -0xd0(%rbp), %rcx
imulq $0x18, -0x28(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq -0xd0(%rbp), %rcx
imulq $0x18, -0x28(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
andq $0x1, %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x242533
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x241f94
movq -0x8(%rbp), %rax
movq 0xd8(%rax), %rdi
callq 0x23fcd0
movq $0x0, -0x108(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0xd8(%rcx), %rcx
movl 0x4(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %ecx, %ecx
cmpq %rcx, %rax
jae 0x24277a
movq -0x8(%rbp), %rax
movq 0xd8(%rax), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0xf8(%rbp)
movq -0x8(%rbp), %rax
movq 0xd8(%rax), %rax
movq 0x18(%rax), %rax
movq -0xf8(%rbp), %rcx
movl 0x4(%rcx), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq -0xf8(%rbp), %rcx
movl 0x4(%rcx), %ecx
andl $0x1, %ecx
movl %ecx, %ecx
movsd (%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
movq 0xd8(%rax), %rax
movq 0x18(%rax), %rax
movq -0xf8(%rbp), %rcx
movl (%rcx), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq -0xf8(%rbp), %rcx
movl (%rcx), %ecx
andl $0x1, %ecx
movl %ecx, %ecx
ucomisd (%rax,%rcx,8), %xmm0
jb 0x24265d
movq -0x8(%rbp), %rax
movq 0xd8(%rax), %rax
movq 0x18(%rax), %rax
movq -0xf8(%rbp), %rcx
movl 0x4(%rcx), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq -0xf8(%rbp), %rcx
movl 0x4(%rcx), %ecx
andl $0x1, %ecx
movl %ecx, %ecx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x188(%rbp)
jmp 0x24269b
movq -0x8(%rbp), %rax
movq 0xd8(%rax), %rax
movq 0x18(%rax), %rax
movq -0xf8(%rbp), %rcx
movl (%rcx), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq -0xf8(%rbp), %rcx
movl (%rcx), %ecx
andl $0x1, %ecx
movl %ecx, %ecx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x188(%rbp)
movsd -0x188(%rbp), %xmm0
movsd %xmm0, -0x100(%rbp)
movq -0xf8(%rbp), %rax
movsd 0x10(%rax), %xmm0
movsd 0x13fb61(%rip), %xmm1   # 0x382220
mulsd -0x100(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jb 0x2426f8
movq -0xf8(%rbp), %rax
movl 0x4(%rax), %edi
movq -0xf8(%rbp), %rax
movl (%rax), %esi
movq -0x8(%rbp), %rax
movq 0xd8(%rax), %rdx
callq 0x23fd50
movsd %xmm0, -0x100(%rbp)
movsd -0x100(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x24271b
jp 0x24271b
movsd 0x13f8ed(%rip), %xmm0   # 0x382000
movsd %xmm0, -0x100(%rbp)
movq -0xf8(%rbp), %rax
movsd 0x10(%rax), %xmm0
divsd -0x100(%rbp), %xmm0
movq -0xf8(%rbp), %rax
movsd %xmm0, 0x18(%rax)
movq -0xf8(%rbp), %rax
movsd 0x18(%rax), %xmm0
movsd 0x13f8b1(%rip), %xmm1   # 0x382000
ucomisd %xmm1, %xmm0
jbe 0x242767
movq -0x108(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x108(%rbp)
jmp 0x242769
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x242567
movq 0x18185f(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0xd8(%rax), %rax
movl 0x14(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq -0x8(%rbp), %rax
movq 0xd8(%rax), %rax
movl 0x4(%rax), %r8d
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movq -0x108(%rbp), %r9
movq -0xa0(%rbp), %r10
movq -0xa8(%rbp), %rax
leaq 0x14be63(%rip), %rsi    # 0x38e62d
leaq 0x14bead(%rip), %rdx    # 0x38e67e
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x22a0
movq -0xd0(%rbp), %rdi
callq 0x2210
movq -0xd8(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2210
movq -0xd8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x2210
movq -0xd8(%rbp), %rdi
callq 0x2210
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
nopw %cs:(%rax,%rax)