// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %r15
movq 0xc8(%rdi), %r12
movq 0xd8(%rdi), %rdi
leaq 0x70(%r15), %rax
movq %rax, 0x58(%rsp)
callq 0x17b748
pushq $0x1
popq %rdi
pushq $0x28
popq %rsi
callq 0x2120
movq %rax, 0xd8(%r15)
cmpq $0x0, (%r12)
je 0x1ff19
movq %rax, %rdi
xorl %r14d, %r14d
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
xorl %ebx, %ebx
movl %ebx, %esi
xorl %edx, %edx
callq 0x17b776
movq 0xd8(%r15), %rdi
movq 0x18(%rdi), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax,%r14)
movq 0x10(%r12), %rcx
movl (%rcx,%r14), %edx
shrl %edx
andl $0x3fffffff, %edx       # imm = 0x3FFFFFFF
cvtsi2sd %edx, %xmm0
movsd %xmm0, 0x10(%rax,%r14)
movl (%rcx,%r14), %ecx
andl %ebp, %ecx
movl %ecx, %edx
shrl %edx
subl %edx, %ecx
cvtsi2sd %ecx, %xmm0
movsd %xmm0, 0x18(%rax,%r14)
incq %rbx
addq $0x28, %r14
cmpq (%r12), %rbx
jb 0x1febd
movq 0x58(%rsp), %rbx
movq %rbx, %rdi
movq %r12, 0x60(%rsp)
movq %r12, %rsi
callq 0x17ba60
movq %rax, 0x50(%rsp)
movq (%rbx), %rax
xorl %r12d, %r12d
movl $0x0, %ecx
movq %rcx, 0x10(%rsp)
movl $0x0, %r11d
movl $0x0, %r9d
movl $0x0, %edi
testq %rax, %rax
movq %r15, 0x40(%rsp)
je 0x20196
pushq $0x18
popq %rbp
xorl %ebx, %ebx
movl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
xorl %edi, %edi
xorl %r9d, %r9d
xorl %r11d, %r11d
movq $0x0, 0x10(%rsp)
xorl %r12d, %r12d
movq 0x80(%r15), %rsi
cmpq $0x0, -0x8(%rsi,%rbp)
je 0x20186
movq -0x18(%rsi,%rbp), %r8
leaq (%r8,%r8), %r10
movb 0xb8(%r15), %dl
xorl %ecx, %ecx
subb %dl, %cl
shrq %cl, %r10
movq -0x10(%rsi,%rbp), %rdx
leaq (%rdx,%rdx), %r13
shrq %cl, %r13
cmpq %r13, %r10
je 0x20186
movq %r10, 0x20(%rsp)
movq %rdi, 0x48(%rsp)
movq %r12, %rdi
movq 0xc0(%r15), %rax
movq %rax, %r10
andq %r8, %r10
testq %r8, %r8
movq %r9, 0x38(%rsp)
js 0x1fff8
movq (%rsi,%rbp), %rcx
movq %rcx, %rsi
shrq $0x20, %rsi
leaq (%r10,%rsi), %r12
decq %r12
jmp 0x20014
leaq 0x1(%r10), %r8
movq (%rsi,%rbp), %rcx
movq %rcx, %rsi
shrq $0x20, %rsi
subq %rsi, %r8
movl $0x0, %r12d
cmovaeq %r8, %r12
movq 0x60(%rsp), %rsi
movq 0x10(%rsi), %rsi
imulq $0x28, 0x20(%rsp), %r8
movl (%rsi,%r8), %r8d
andq %r14, %r8
cmpq %r12, %r10
movq %r12, %r9
cmovbq %r10, %r9
cmovaq %r10, %r12
leaq -0x1(%r8), %r10
cmpq %r10, %r9
cmovaeq %r10, %r9
cmpq %r10, %r12
cmovaeq %r10, %r12
addq %r9, %r12
shrq %r12
shrl %r8d
xorl %r10d, %r10d
cmpq %r8, %r12
seta %r8b
andq %rdx, %rax
testq %rdx, %rdx
js 0x20070
movl %ecx, %ecx
leaq (%rax,%rcx), %r15
decq %r15
jmp 0x20083
leaq 0x1(%rax), %rdx
movl %ecx, %ecx
subq %rcx, %rdx
movl $0x0, %r15d
cmovaeq %rdx, %r15
imulq $0x28, %r13, %rcx
movl (%rsi,%rcx), %ecx
andq %r14, %rcx
cmpq %r15, %rax
movq %r15, %rdx
cmovbq %rax, %rdx
cmovaq %rax, %r15
leaq -0x1(%rcx), %rax
cmpq %rax, %rdx
cmovaeq %rax, %rdx
cmpq %rax, %r15
cmovaeq %rax, %r15
addq %rdx, %r15
shrq %r15
shrl %ecx
xorl %r14d, %r14d
cmpq %rcx, %r15
seta %dl
cmpq 0x10(%rsp), %r11
jne 0x20103
leaq (%r11,%r11), %rcx
testq %r11, %r11
pushq $0x2
popq %rax
cmoveq %rax, %rcx
movq %rcx, 0x10(%rsp)
imulq $0x18, %rcx, %rsi
movq %r11, 0x18(%rsp)
movb %r8b, 0xf(%rsp)
movb %dl, 0xe(%rsp)
callq 0x2370
movb 0xe(%rsp), %dl
movb 0xf(%rsp), %r8b
xorl %r10d, %r10d
movq 0x18(%rsp), %r11
movq %rax, %rdi
movq 0x38(%rsp), %r9
movq 0x20(%rsp), %rax
movb %r8b, %r10b
leaq (%r10,%rax,2), %rcx
movb %dl, %r14b
leaq (%r14,%r13,2), %rdx
imulq $0x18, %r11, %rax
andq $0x0, 0x10(%rdi,%rax)
movq %rcx, %rsi
shlq $0x20, %rsi
orq %rdx, %rsi
movq %rsi, (%rdi,%rax)
movq %r12, %rsi
shlq $0x20, %rsi
orq %r15, %rsi
movq %rdi, %r8
movq %rsi, 0x8(%rdi,%rax)
cmpq %rdx, %rcx
jbe 0x20162
addq %r8, %rax
shlq $0x20, %rdx
orq %rcx, %rdx
movq %rdx, (%rax)
shlq $0x20, %r15
orq %r12, %r15
movq %r15, 0x8(%rax)
incq %r9
incq %r11
movq 0x48(%rsp), %rdi
incq %rdi
movq 0x58(%rsp), %rax
movq (%rax), %rax
movq %r8, %r12
movq 0x40(%rsp), %r15
movl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
incq %rbx
addq $0x20, %rbp
cmpq %rax, %rbx
jb 0x1ff81
movq %r11, 0x18(%rsp)
movq %rdi, 0x48(%rsp)
movq %r9, 0x38(%rsp)
leaq 0x70(%rsp), %rdi
movq %r11, 0x8(%rdi)
movq 0x10(%rsp), %rax
movq %rax, 0x10(%rdi)
movq %r12, (%rdi)
leaq 0x68(%rsp), %rdx
movq 0x50(%rsp), %rsi
callq 0x17bd89
imulq $0x18, 0x18(%rsp), %rsi
addq %r12, %rsi
movq %r12, %rdi
callq 0x1733eb
movq 0x18(%rsp), %r9
testq %r9, %r9
je 0x204a2
leaq 0x10(%r12), %rax
movq %rax, 0x10(%rsp)
xorl %ebx, %ebx
xorpd %xmm2, %xmm2
movl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
pushq $0x1
popq %rbp
cmpq %r9, %rbp
je 0x2021c
imulq $0x18, %rbp, %rax
movq (%r12,%rax), %rax
imulq $0x18, %rbx, %rcx
cmpq (%r12,%rcx), %rax
je 0x20496
movq (%r15), %rax
testq %rax, %rax
je 0x20257
imulq $0x18, %rbx, %rcx
movq (%r12,%rcx), %rcx
movq 0x10(%r15), %rdx
movq %rcx, %rsi
rolq $0x20, %rsi
xorl %edi, %edi
movq (%rdx,%rdi,8), %r8
cmpq %rcx, %r8
je 0x20493
cmpq %rsi, %r8
je 0x20493
incq %rdi
cmpq %rdi, %rax
jne 0x20239
xorpd %xmm3, %xmm3
cmpq %rbx, %rbp
jbe 0x202c8
imulq $0x18, %rbx, %r14
addq 0x10(%rsp), %r14
movq %rbx, %r15
movsd (%r14), %xmm0
ucomisd %xmm2, %xmm0
jne 0x20279
jnp 0x20295
movsd 0x68(%rsp), %xmm1
divsd %xmm0, %xmm1
addsd %xmm1, %xmm3
incq %r15
addq $0x18, %r14
cmpq %r15, %rbp
jne 0x2026c
jmp 0x202c8
movq 0x274d44(%rip), %rax    # 0x294fe0
movq (%rax), %rcx
leaq 0x216dcd(%rip), %rdi    # 0x237073
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
movapd %xmm3, 0x20(%rsp)
callq 0x2410
movapd 0x20(%rsp), %xmm3
xorpd %xmm2, %xmm2
movsd (%r14), %xmm0
jmp 0x20279
movq 0x40(%rsp), %rax
movq 0xd8(%rax), %r14
movl 0x4(%r14), %edx
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl (%r14), %ecx
movapd %xmm3, 0x20(%rsp)
jne 0x2031e
leal (%rcx,%rcx), %esi
testl %ecx, %ecx
pushq $0x10
popq %rax
cmovel %eax, %esi
movl %esi, (%r14)
movq 0x8(%r14), %rdi
shlq $0x5, %rsi
callq 0x2370
movapd 0x20(%rsp), %xmm3
movq %rax, 0x8(%r14)
movl 0x4(%r14), %edx
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
jmp 0x20322
movq 0x8(%r14), %rax
leal 0x1(%rdx), %esi
andl %r13d, %esi
andl $0x80000000, %edx       # imm = 0x80000000
orl %esi, %edx
movl %edx, 0x4(%r14)
movl %ecx, %ecx
shlq $0x5, %rcx
andl $0x0, 0x8(%rax,%rcx)
imulq $0x18, %rbx, %r14
xorpd %xmm0, %xmm0
movupd %xmm0, 0x10(%rax,%rcx)
movq (%r12,%r14), %rdx
movq %rdx, %rsi
shrq $0x20, %rsi
movl %esi, 0x4(%rax,%rcx)
movl %edx, (%rax,%rcx)
movl %ebp, %r15d
subl %ebx, %r15d
andl %r13d, %r15d
movl %r15d, 0x8(%rax,%rcx)
movsd %xmm3, 0x10(%rax,%rcx)
movq 0x40(%rsp), %rax
movq 0xd8(%rax), %rbx
movl 0x4(%rbx), %edx
movl %edx, %ecx
andl %r13d, %ecx
cmpl (%rbx), %ecx
jne 0x203bc
leal (%rcx,%rcx), %esi
testl %ecx, %ecx
pushq $0x10
popq %rax
cmovel %eax, %esi
movl %esi, (%rbx)
movq 0x8(%rbx), %rdi
shlq $0x5, %rsi
callq 0x2370
movapd 0x20(%rsp), %xmm3
movq %rax, 0x8(%rbx)
movl 0x4(%rbx), %edx
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
jmp 0x203c0
movq 0x8(%rbx), %rax
movq 0x18(%rsp), %r9
leal 0x1(%rdx), %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andl $0x80000000, %edx       # imm = 0x80000000
orl %esi, %edx
movl %edx, 0x4(%rbx)
movl %ecx, %ecx
shlq $0x5, %rcx
andl $0x0, 0x8(%rax,%rcx)
addq %r12, %r14
xorpd %xmm0, %xmm0
movupd %xmm0, 0x10(%rax,%rcx)
movq (%r14), %rdx
movl %edx, 0x4(%rax,%rcx)
shrq $0x20, %rdx
movl %edx, (%rax,%rcx)
movl %r15d, 0x8(%rax,%rcx)
movsd %xmm3, 0x10(%rax,%rcx)
movq 0x40(%rsp), %r15
movq 0xd8(%r15), %rdx
movq 0x18(%rdx), %rsi
movq (%r14), %rdx
movq %rdx, %rdi
shrq $0x21, %rdi
imulq $0x28, %rdi, %rdi
addq %rsi, %rdi
movq %rdx, %r8
shrq $0x20, %r8
andl $0x1, %r8d
movsd (%rdi,%r8,8), %xmm0
movapd %xmm3, %xmm1
cmplesd %xmm0, %xmm1
andpd %xmm1, %xmm0
andnpd %xmm3, %xmm1
orpd %xmm0, %xmm1
movlpd %xmm1, (%rdi,%r8,8)
movl %edx, %edi
shrl %edi
imulq $0x28, %rdi, %rdi
addq %rsi, %rdi
andl $0x1, %edx
movsd (%rdi,%rdx,8), %xmm0
movsd 0x10(%rax,%rcx), %xmm1
movapd %xmm1, %xmm2
cmplesd %xmm0, %xmm2
andpd %xmm2, %xmm0
andnpd %xmm1, %xmm2
orpd %xmm0, %xmm2
movlpd %xmm2, (%rdi,%rdx,8)
movq %rbp, %rbx
xorpd %xmm2, %xmm2
jmp 0x20496
movq %rbp, %rbx
incq %rbp
cmpq %r9, %rbp
jbe 0x20201
movq %r12, %rbp
movq 0xd8(%r15), %rdi
callq 0x17b968
movq 0xd8(%r15), %r12
testl $0x7fffffff, 0x4(%r12)  # imm = 0x7FFFFFFF
jne 0x204ce
xorl %r15d, %r15d
xorl %r8d, %r8d
jmp 0x205bb
movq 0x8(%r12), %rbx
movq 0x18(%r12), %r14
xorl %r15d, %r15d
movsd 0x2110b5(%rip), %xmm3   # 0x231598
xorpd %xmm4, %xmm4
movsd 0x210e21(%rip), %xmm5   # 0x231310
xorl %r13d, %r13d
movl (%rbx), %esi
movl 0x4(%rbx), %edi
movl %edi, %eax
shrl %eax
imulq $0x28, %rax, %rax
addq %r14, %rax
movl %edi, %ecx
andl $0x1, %ecx
movsd (%rax,%rcx,8), %xmm1
movl %esi, %eax
shrl %eax
imulq $0x28, %rax, %rax
addq %r14, %rax
movl %esi, %ecx
andl $0x1, %ecx
movsd (%rax,%rcx,8), %xmm2
movapd %xmm2, %xmm0
cmplesd %xmm1, %xmm0
andpd %xmm0, %xmm1
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
movsd 0x10(%rbx), %xmm6
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
ucomisd %xmm1, %xmm6
jb 0x20571
movq %r12, %rdx
movsd %xmm6, 0x20(%rsp)
callq 0x17b9a0
movsd 0x20(%rsp), %xmm6
movsd 0x210dab(%rip), %xmm5   # 0x231310
xorpd %xmm4, %xmm4
movsd 0x211027(%rip), %xmm3   # 0x231598
movapd %xmm0, %xmm1
cmpeqsd %xmm4, %xmm1
movapd %xmm1, %xmm2
andpd %xmm5, %xmm2
andnpd %xmm0, %xmm1
orpd %xmm2, %xmm1
divsd %xmm1, %xmm6
movsd %xmm6, 0x18(%rbx)
xorl %eax, %eax
ucomisd %xmm5, %xmm6
seta %al
addq %rax, %r15
incq %r13
movl 0x4(%r12), %r8d
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
addq $0x20, %rbx
cmpq %r8, %r13
jb 0x204f2
movq 0x274a1e(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl 0x14(%r12), %ecx
leaq 0x21d407(%rip), %rsi    # 0x23d9dd
leaq 0x21d451(%rip), %rdx    # 0x23da2e
movq %r15, %r9
xorl %eax, %eax
pushq 0x48(%rsp)
pushq 0x40(%rsp)
callq 0x22b0
popq %rcx
popq %rdx
movq %rbp, %rdi
callq 0x2220
movq 0x50(%rsp), %rbx
movq 0x10(%rbx), %rdi
callq 0x2220
movq 0x18(%rbx), %rdi
callq 0x2220
movq %rbx, %rdi
callq 0x2220
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq