// File: /workspace/github_c_makefile_star2_O2/c-zhou[P]oatk/path.c
// Function: graph_path_finder
void graph_path_finder(asg_t *asg, kh_u32_t *seg_dups, path_v *paths, int max_path, double sub_circ_minf, int is_pltd)
{
    uint64_t i, j, s, n_leaf;
    int circ, exceed_limit;
    asmg_t *g;
    llnode *root, *next_node, *node, **leaves;
    kvec_t(llnodep) leaf_node, root_node;

    g = asg->asmg;
    
    // find source vertex
    s = find_source_vtx(g, 1);

    if (s == UINT64_MAX) return;

    kv_init(root_node);
    kv_init(leaf_node);

    root = new_node(s << 1);
    kv_push(llnodep, root_node, root);

    n_leaf = 0;
    exceed_limit = 0;
    leaves = graph_path_extension(g, root, seg_dups, max_path, &n_leaf, &exceed_limit);
    // for linear paths do extension from the other direction of root node
    // no - should do this even if the path is circular
    // n_leaf will be zero if path number exceeds limit
    for (i = 0; i < n_leaf; ++i) {
        node = leaves[i];
        // circ = asmg_arc1(g, node->v, s << 1) != 0;
        // if (circ) {
        //     kv_push(llnodep, leaf_node, node);
        //     continue;
        // }
        
        // make a new path tracing back from leaf to root
        root = new_node(node->v^1);
        kv_push(llnodep, root_node, root);
        while (node->prev != NULL) {
            next_node = new_node(node->prev->v^1);
            next_node->prev = root;
            add_next(root, next_node);
            root = next_node;
            node = node->prev;
        }

        assert(root->v == (s<<1 | 1)); // should be always ended with seq s
        uint64_t n = 0;
        exceed_limit = 0;
        llnode **tmp_nodes = graph_path_extension(g, root, seg_dups, max_path, &n, &exceed_limit);
        
        for (j = 0; j < n; ++j)
            kv_push(llnodep, leaf_node, tmp_nodes[j]);
        free(tmp_nodes);

        if (exceed_limit || leaf_node.n > max_path) {
            exceed_limit = 1;
            break;
        }
    }
    free(leaves);

    if (exceed_limit) {
        fprintf(stderr, "[W::%s] path exploration exceeds limit %d\n", __func__, max_path);
        fprintf(stderr, "[W::%s] consider an larger value of '-N'\n", __func__);
        goto final_clean;
    }

#ifdef DEBUG_PATH_FINDER
    fprintf(stderr, "[DEBUG_PATH_FINDER::%s] number leaf nodes: %lu\n", __func__, leaf_node.n);
#endif

    for (i = 0; i < leaf_node.n; ++i) {
        kvec_t(uint32_t) path;
        kv_init(path);
        node = leaf_node.a[i];
        path.n = 0;
        while (node != NULL) {
            kv_push(uint32_t, path, node->v);
            node = node->prev;
        }
        rev_array(path.a, path.n);

        circ = asmg_arc1(g, path.a[path.n-1], path.a[0]) != 0;

#ifdef DEBUG_PATH_FINDER
        uint64_t n = path.n;
        fprintf(stderr, "[DEBUG_PATH_FINDER::%s] Path %lu [%s] (%lu): %s%c", __func__, i, 
                circ? "circle" : "linear", n, asg->seg[path.a[0]>>1].name, "+-"[path.a[0]&1]);
        for (j = 1; j < n; ++j)
            fprintf(stderr, ",%s%c", asg->seg[path.a[j]>>1].name, "+-"[path.a[j]&1]);
        fprintf(stderr, "\n");
#endif

        // calculate sequence length
        asmg_arc_t *a;
        uint64_t l, l1, *l_seg;
        uint32_t *l_beg, *l_end;
        double cov, wl;
        
        MYMALLOC(l_seg, path.n);
        l_seg[0] = g->vtx[path.a[0]>>1].len;
        l = l_seg[0];
        cov = g->vtx[path.a[0]>>1].cov;
        wl = cov * l;
        for (j = 1; j < path.n; ++j) {
            a = asmg_arc1(g, path.a[j-1], path.a[j]);
            assert(!!a);
            l_seg[j-1] = l_seg[j-1] << 32 | a->ls;
            l_seg[j] = g->vtx[path.a[j]>>1].len;
            l1 = l_seg[j] - a->ls;
            cov = g->vtx[path.a[j]>>1].cov;
            l += l1;
            wl += cov * l1;
        }
        l_seg[path.n-1] <<= 32;
        
        l_beg = l_end = 0;
        if (circ) {
            a = asmg_arc1(g, path.a[path.n-1], path.a[0]);
            assert(!!a);
            l1 = a->ls;
            cov = g->vtx[path.a[0]>>1].cov;
            l -= l1;
            wl -= cov * l1;
        } else {
            MYMALLOC(l_beg, path.n);
            MYMALLOC(l_end, path.n);
            l_beg[0] = 0;
            for (j = 1; j < path.n; ++j)
                l_beg[j] = l_beg[j-1] + (l_seg[j-1] >> 32) - (uint32_t) l_seg[j-1];
            for (j = 0; j < path.n; ++j) 
                l_end[j] = l - l_beg[j] - (l_seg[j] >> 32);
            assert(l_end[path.n-1] == 0);
        }
        
        // replace copied vertices with originals
        khint32_t k32;
        for (j = 0; j < path.n; ++j) {
            k32 = kh_u32_get(seg_dups, path.a[j]>>1);
            if (k32 < kh_end(seg_dups))
                path.a[j] = kh_val(seg_dups, k32)<<1 | (path.a[j]&1);
        }

        path_t p = {0, path.n, circ, 0, path.a, l, wl, .0};
        kv_push(path_t, *paths, p);
        
        if (!circ) {
            // for linear paths add longest circular subpaths if at least sub_circ_minf sequences covered
            double drop, max_drop, min_drop;
            int beg, end, beg1, end1, n;
            
            uint64_t L = is_pltd? MIN(l, COMMON_AVG_PLTD_SIZE) : l;
            max_drop = l - (double) L * sub_circ_minf;
            n = path.n;
            beg1 = end1 = -1;
            min_drop = FLT_MAX;
            for (beg = 0; beg < n; ++beg) {
                if (l_beg[beg] > max_drop || l_beg[beg] >= min_drop)
                    break;
                for (end = n - 1; end >= beg; --end) {
                    drop = l_beg[beg] + l_end[end];
                    if (drop > max_drop || drop >= min_drop)
                        break;
                    // check if the path [beg, end] is a circular
                    a = asmg_arc1(g, path.a[end], path.a[beg]);
                    if (a) {
                        beg1 = beg;
                        end1 = end;
                        min_drop = drop;
                        break; // only need the longest subpath
                    }
                }
            }

            if (beg1 >= 0) {
                // circular subpath found
                // add subpath
                uint32_t *v;
                n = end1 - beg1 + 1;
                MYMALLOC(v, n);
                memcpy(v, &path.a[beg1], sizeof(uint32_t) * n);
                wl = (l_seg[beg1] >> 32) * g->vtx[path.a[beg1]>>1].cov;
                for (beg = beg1 + 1; beg <= end1; ++beg)
                    wl += ((l_seg[beg] >> 32) - (uint32_t) l_seg[beg-1]) * g->vtx[path.a[beg]>>1].cov;
                l -= l_beg[beg1] + l_end[end1];
                a = asmg_arc1(g, v[n-1], v[0]);
                l -= a->ls;
                wl -= a->ls * g->vtx[v[0]>>1].cov;
                path_t p1 = {0, n, 1, 0, v, l, wl, .0};
                kv_push(path_t, *paths, p1);
            }
        }
        
        free(l_seg);
        free(l_beg);
        free(l_end);
    }

final_clean:
    for (i = 0; i < root_node.n; ++i)
        llnode_destroy(root_node.a[i]);

    kv_destroy(root_node);
    kv_destroy(leaf_node);

    return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movl %r8d, 0xac(%rsp)
movsd %xmm0, 0xc0(%rsp)
movl %ecx, 0x18(%rsp)
movq %rdx, %r15
movq %rsi, 0xa0(%rsp)
movq 0x20(%rdi), %r12
movq (%r12), %rdi
leaq (%rdi,%rdi), %rbx
shlq $0x3, %rdi
callq 0x32f0
movq %rax, %r14
movq %r12, 0x8(%rsp)
movq %r12, %rdi
movq %rax, %rsi
callq 0x12a56
movl %eax, %ebp
movslq %eax, %rdi
pushq $0x8
popq %rsi
callq 0x3240
movq %rax, %r13
xorl %eax, %eax
cmpq %rax, %rbx
je 0x60b7
movslq (%r14,%rax,4), %rcx
testq %rcx, %rcx
js 0x60b2
testb $0x1, %al
jne 0x608a
movq %rax, %rdx
xorq $0x1, %rdx
cmpl (%r14,%rdx,4), %ecx
je 0x60b2
movq 0x8(%rsp), %rdx
movq 0x10(%rdx), %rdx
movq %rax, %rsi
shrq %rsi
imulq $0x28, %rsi, %rsi
movl 0x20(%rdx,%rsi), %edi
andl $0x3fffffff, %edi       # imm = 0x3FFFFFFF
imulq 0x18(%rdx,%rsi), %rdi
addq %rdi, (%r13,%rcx,8)
incq %rax
jmp 0x606b
xorl %ecx, %ecx
testl %ebp, %ebp
cmovlel %ecx, %ebp
pushq $-0x1
popq %rax
xorl %edx, %edx
cmpq %rcx, %rbp
je 0x60dc
movq (%r13,%rcx,8), %rsi
cmpq %rsi, %rdx
cmovbl %ecx, %eax
cmovbeq %rsi, %rdx
incq %rcx
jmp 0x60c3
movq %r15, 0xb0(%rsp)
pushq $-0x1
popq %r12
testl %eax, %eax
js 0x6133
xorl %ecx, %ecx
xorl %edx, %edx
cmpq %rdx, %rbx
je 0x6130
cmpl %eax, (%r14,%rdx,4)
jne 0x612b
movq 0x8(%rsp), %rsi
movq 0x10(%rsi), %rsi
movq %rdx, %rdi
shrq %rdi
imulq $0x28, %rdi, %rdi
movl 0x20(%rsi,%rdi), %r8d
andl $0x3fffffff, %r8d       # imm = 0x3FFFFFFF
imulq 0x18(%rsi,%rdi), %r8
cmpq %r8, %rcx
cmovbeq %r8, %rcx
cmovbq %rdx, %r12
incq %rdx
jmp 0x60f0
shrq %r12
movq %r14, %rdi
callq 0x3060
movq %r13, %rdi
callq 0x3060
cmpq $-0x1, %r12
je 0x6355
leaq (%r12,%r12), %rdi
callq 0x6bbe
movq %rax, %r14
pushq $0x10
popq %rdi
callq 0x32f0
movq %rax, 0x58(%rsp)
movq %r14, (%rax)
leaq 0xd0(%rsp), %r15
andq $0x0, (%r15)
leaq 0x4(%rsp), %r9
andl $0x0, (%r9)
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movq 0xa0(%rsp), %rdx
movl 0x18(%rsp), %ebx
movl %ebx, %ecx
movq %r15, %r8
callq 0x6bfa
movq %rax, 0x10(%rsp)
movq (%r15), %rax
movq %rax, 0x38(%rsp)
leaq 0x1(,%r12,2), %rax
movq %rax, 0x30(%rsp)
movslq %ebx, %rax
movq %rax, 0x70(%rsp)
pushq $0x2
popq %r14
pushq $0x1
popq %rax
movq %rax, 0x88(%rsp)
movq $0x0, 0x98(%rsp)
movq %r14, 0x40(%rsp)
xorl %r13d, %r13d
xorl %eax, %eax
xorl %ecx, %ecx
movq %rax, 0x60(%rsp)
cmpq 0x38(%rsp), %rcx
je 0x6367
movq 0x10(%rsp), %rax
movq %rcx, 0x20(%rsp)
movq (%rax,%rcx,8), %rbx
movl (%rbx), %edi
xorl $0x1, %edi
callq 0x6bbe
movq %rax, %rbp
movq 0x88(%rsp), %r15
cmpq 0x40(%rsp), %r15
jne 0x6243
leaq (%r15,%r15), %rax
testq %r15, %r15
cmoveq %r14, %rax
movq %rax, 0x40(%rsp)
leaq (,%rax,8), %rsi
movq 0x58(%rsp), %rdi
callq 0x3330
jmp 0x6248
movq 0x58(%rsp), %rax
movq %rax, 0x58(%rsp)
movq %rbp, (%rax,%r15,8)
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x627f
movl (%rax), %edi
xorl $0x1, %edi
callq 0x6bbe
movq %rax, %r15
movq %rbp, 0x8(%rax)
movq %rbp, %rdi
movq %rax, %rsi
callq 0x6f8d
movq 0x8(%rbx), %rbx
movq %r15, %rbp
jmp 0x6251
movl (%rbp), %eax
cmpq %rax, 0x30(%rsp)
jne 0x6b80
andq $0x0, 0xb8(%rsp)
incq 0x88(%rsp)
andl $0x0, 0x4(%rsp)
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
movq 0xa0(%rsp), %rdx
movl 0x18(%rsp), %ecx
leaq 0xb8(%rsp), %r8
leaq 0x4(%rsp), %r9
callq 0x6bfa
movq %rax, %r15
movq 0xb8(%rsp), %rbx
xorl %ebp, %ebp
movq 0x60(%rsp), %rdi
movq 0x98(%rsp), %r12
cmpq %rbx, %rbp
je 0x6318
cmpq %r13, %r12
jne 0x6308
leaq (%r12,%r12), %r13
testq %r12, %r12
cmoveq %r14, %r13
leaq (,%r13,8), %rsi
callq 0x3330
movq %rax, %rdi
movq (%r15,%rbp,8), %rax
movq %rax, (%rdi,%r12,8)
incq %r12
incq %rbp
jmp 0x62e3
movq %r12, 0x98(%rsp)
movq %rdi, 0x60(%rsp)
movq %r15, %rdi
callq 0x3060
cmpl $0x0, 0x4(%rsp)
jne 0x6371
movq 0x70(%rsp), %rax
cmpq %rax, 0x98(%rsp)
ja 0x6371
movq 0x20(%rsp), %rcx
incq %rcx
movq 0x60(%rsp), %rax
jmp 0x61e5
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x0, 0x4(%rsp)
sete %bl
jmp 0x637b
movl $0x1, 0x4(%rsp)
xorl %ebx, %ebx
movq 0x10(%rsp), %rdi
callq 0x3060
testb %bl, %bl
movq 0x58(%rsp), %r15
movq 0x88(%rsp), %r12
je 0x6ad0
xorl %ecx, %ecx
cmpq 0x98(%rsp), %rcx
movq 0x60(%rsp), %rax
je 0x6b0a
movq %rcx, 0xc8(%rsp)
leaq (%rax,%rcx,8), %r15
xorl %r12d, %r12d
xorl %ecx, %ecx
xorl %ebx, %ebx
xorl %r14d, %r14d
xorl %ebp, %ebp
xorl %r13d, %r13d
movq (%r15), %r15
testq %r15, %r15
je 0x641a
cmpq %rbp, %r14
jne 0x63fd
testq %r14, %r14
movq %r12, %rbp
pushq $0x2
popq %rax
cmoveq %rax, %rbp
leaq (,%rbp,4), %rsi
movq %r13, %rdi
movq %rcx, %r13
callq 0x3330
movq %r13, %rcx
movq %rax, %r13
movl (%r15), %eax
movl %eax, (%r13,%r14,4)
incq %r14
addq $0x8, %r15
addq $0x8, %rbx
addq $0x4, %rcx
addq $0x2, %r12
jmp 0x63ca
movq %rcx, 0x90(%rsp)
movq %r13, %rdi
movl %r14d, %esi
callq 0x7019
movl -0x4(%r13,%r14,4), %esi
movl (%r13), %ebp
movq 0x8(%rsp), %r15
movq %r15, %rdi
movq %rsi, 0x18(%rsp)
movq %rbp, %rdx
callq 0x703e
movq %rax, 0x40(%rsp)
movq %rbx, %rdi
callq 0x32f0
movq 0x10(%r15), %r12
movl %ebp, %ecx
shrl %ecx
imulq $0x28, %rcx, %rcx
movq 0x18(%r12,%rcx), %rbx
movq %rax, 0x10(%rsp)
movq %rbx, (%rax)
movl 0x20(%r12,%rcx), %eax
movl $0x3fffffff, %ecx       # imm = 0x3FFFFFFF
andl %ecx, %eax
cvtsi2sd %eax, %xmm2
movq %rbx, %xmm0
punpckldq 0x10102(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1010a(%rip), %xmm0    # 0x165a0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd %xmm2, 0x70(%rsp)
mulsd %xmm2, %xmm1
movapd %xmm1, 0x20(%rsp)
movq %rbp, 0x30(%rsp)
movl %ebp, %r15d
movq %rbx, 0x38(%rsp)
pushq $0x1
popq %rbp
cmpq %r14, %rbp
jae 0x6568
movl %r15d, %esi
movl (%r13,%rbp,4), %r15d
movq 0x8(%rsp), %rdi
movq %r15, %rdx
callq 0x703e
testq %rax, %rax
je 0x6b42
shlq $0x20, %rbx
movq 0x18(%rax), %rax
orq %rax, %rbx
movq 0x10(%rsp), %rdx
movq %rbx, -0x8(%rdx,%rbp,8)
movl %r15d, %ecx
shrl %ecx
imulq $0x28, %rcx, %rcx
movq 0x18(%r12,%rcx), %rbx
movq %rbx, (%rdx,%rbp,8)
movq %rbx, %rdx
subq %rax, %rdx
movl 0x20(%r12,%rcx), %eax
movl $0x3fffffff, %ecx       # imm = 0x3FFFFFFF
andl %ecx, %eax
cvtsi2sd %eax, %xmm0
addq %rdx, 0x38(%rsp)
movq %rdx, %xmm1
punpckldq 0x10058(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x10060(%rip), %xmm1    # 0x165a0
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
mulsd %xmm0, %xmm2
movapd 0x20(%rsp), %xmm0
addsd %xmm2, %xmm0
movapd %xmm0, 0x20(%rsp)
incq %rbp
jmp 0x64c2
movq 0x10(%rsp), %rax
shlq $0x20, -0x8(%rax,%r14,8)
cmpq $0x0, 0x40(%rsp)
je 0x65f1
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x30(%rsp), %rdx
callq 0x703e
testq %rax, %rax
movq 0x38(%rsp), %rcx
je 0x6b61
movq 0x18(%rax), %rax
subq %rax, %rcx
movq %rcx, 0x38(%rsp)
movq %rax, %xmm0
punpckldq 0xffda(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xffe2(%rip), %xmm0     # 0x165a0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x70(%rsp), %xmm2
mulsd %xmm1, %xmm2
movapd 0x20(%rsp), %xmm0
subsd %xmm2, %xmm0
movapd %xmm0, 0x20(%rsp)
xorl %ebp, %ebp
movq $0x0, 0x30(%rsp)
jmp 0x6670
movq 0x90(%rsp), %r15
movq %r15, %rdi
callq 0x32f0
movq %rax, %rbx
movq %r15, %rdi
callq 0x32f0
andl $0x0, (%rbx)
movq %rax, %rbp
xorl %ecx, %ecx
pushq $0x1
popq %rax
movq 0x38(%rsp), %rsi
cmpq %r14, %rax
jae 0x663f
movl %ecx, %edx
movq 0x10(%rsp), %rcx
movq -0x8(%rcx,%rax,8), %rcx
subq %rcx, %rdx
shrq $0x20, %rcx
addq %rdx, %rcx
movl %ecx, (%rbx,%rax,4)
incq %rax
jmp 0x661c
xorl %eax, %eax
cmpq %rax, %r14
je 0x665f
movq 0x10(%rsp), %rcx
movl 0x4(%rcx,%rax,8), %ecx
addl (%rbx,%rax,4), %ecx
movl %esi, %edx
subl %ecx, %edx
movl %edx, (%rbp,%rax,4)
incq %rax
jmp 0x6641
movq %rbx, 0x30(%rsp)
cmpl $0x0, -0x4(%rbp,%r14,4)
jne 0x6b9f
xorl %ebx, %ebx
cmpq %rbx, %r14
je 0x66c5
movl (%r13,%rbx,4), %r15d
movl %r15d, %esi
shrl %esi
movq 0xa0(%rsp), %r12
movq %r12, %rdi
callq 0x706e
movq 0x10(%r12), %rdx
testq %rdx, %rdx
je 0x66c0
movq 0xa0(%rsp), %rcx
movb (%rcx), %cl
movl %eax, %esi
shrl %cl, %esi
testl %esi, %esi
jne 0x66c0
movl %eax, %eax
movl 0x4(%rdx,%rax,8), %eax
andl $0x1, %r15d
leal (%r15,%rax,2), %eax
movl %eax, (%r13,%rbx,4)
incq %rbx
jmp 0x6672
xorl %ebx, %ebx
cmpq $0x0, 0x40(%rsp)
setne %r15b
movq 0xb0(%rsp), %r12
movq (%r12), %rcx
movq 0x10(%r12), %rax
cmpq 0x8(%r12), %rcx
jne 0x6711
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rdx
movq %rdx, 0x8(%r12)
imulq $0x30, %rdx, %rsi
movq %rax, %rdi
callq 0x3330
movq %rax, 0x10(%r12)
movq (%r12), %rcx
movl %r14d, %edx
andl $0x3fffffff, %edx       # imm = 0x3FFFFFFF
movb %r15b, %bl
shll $0x1e, %ebx
orl %edx, %ebx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r12)
imulq $0x30, %rcx, %rcx
andq $0x0, (%rax,%rcx)
andq $0x0, 0x28(%rax,%rcx)
movl %ebx, 0x8(%rax,%rcx)
movq %r13, 0x10(%rax,%rcx)
movq 0x38(%rsp), %rdx
movl %edx, 0x18(%rax,%rcx)
movapd 0x20(%rsp), %xmm0
movsd %xmm0, 0x20(%rax,%rcx)
cmpq $0x0, 0x40(%rsp)
jne 0x6a97
movl $0x27100, %eax          # imm = 0x27100
cmpq %rax, %rdx
cmovbq %rdx, %rax
cmpl $0x0, 0xac(%rsp)
cmoveq %rdx, %rax
movq %rdx, %xmm0
movq 0xfe08(%rip), %xmm1     # 0x16590
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0xfe0c(%rip), %xmm2     # 0x165a0
subpd %xmm2, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
movq %rax, %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
subpd %xmm2, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0xc0(%rsp), %xmm1
subsd %xmm1, %xmm3
movapd %xmm3, 0x40(%rsp)
movslq %r14d, %rax
testl %eax, %eax
movl $0x0, %r12d
movq %rax, 0x70(%rsp)
cmovgl %eax, %r12d
xorl %r14d, %r14d
movsd 0xfd29(%rip), %xmm0     # 0x16518
movsd %xmm0, 0x20(%rsp)
pushq $-0x1
popq %rax
movl %eax, 0x90(%rsp)
movl %eax, 0x6c(%rsp)
cmpq %r12, %r14
je 0x689b
movq 0x30(%rsp), %rax
movl (%rax,%r14,4), %ebx
cvtsi2sd %rbx, %xmm0
ucomisd 0x40(%rsp), %xmm0
ja 0x689b
ucomisd 0x20(%rsp), %xmm0
jae 0x689b
movq 0x70(%rsp), %r15
cmpq %r14, %r15
jle 0x6887
movl -0x4(%rbp,%r15,4), %eax
addl %ebx, %eax
cvtsi2sd %rax, %xmm0
ucomisd 0x40(%rsp), %xmm0
ja 0x6887
ucomisd 0x20(%rsp), %xmm0
jae 0x6887
movsd %xmm0, 0x18(%rsp)
movl -0x4(%r13,%r15,4), %esi
movl (%r13,%r14,4), %edx
movq 0x8(%rsp), %rdi
callq 0x703e
decq %r15
testq %rax, %rax
je 0x682f
movl %r14d, 0x90(%rsp)
movl %r15d, 0x6c(%rsp)
movsd 0x18(%rsp), %xmm0
jmp 0x688d
movsd 0x20(%rsp), %xmm0
incq %r14
movsd %xmm0, 0x20(%rsp)
jmp 0x6803
movl 0x90(%rsp), %r14d
testl %r14d, %r14d
movq 0xb0(%rsp), %r12
js 0x6a97
movl 0x6c(%rsp), %ebx
movl %ebx, %eax
subl %r14d, %eax
movslq %eax, %rcx
incl %eax
movl %eax, 0x40(%rsp)
movq %rcx, 0x70(%rsp)
leaq 0x4(,%rcx,4), %r15
movq %r15, %rdi
callq 0x32f0
movl %r14d, %r14d
leaq (%r13,%r14,4), %r13
movq %rax, 0x20(%rsp)
movq %rax, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x32c0
movq 0x10(%rsp), %rsi
movq (%rsi,%r14,8), %rdx
movq %rdx, %rax
shrq $0x20, %rax
movq 0x8(%rsp), %rcx
movq 0x10(%rcx), %r15
movl (%r13), %ecx
shrl %ecx
imulq $0x28, %rcx, %rcx
movl 0x20(%r15,%rcx), %ecx
andl $0x3fffffff, %ecx       # imm = 0x3FFFFFFF
imulq %rax, %rcx
cvtsi2sd %rcx, %xmm2
leaq (%rsi,%r14,8), %rax
addq $0x8, %rax
xorl %ecx, %ecx
leal (%r14,%rcx), %esi
cmpl %esi, %ebx
jle 0x6993
movq (%rax,%rcx,8), %rsi
movl %edx, %edi
movq %rsi, %rdx
shrq $0x20, %rsi
subq %rdi, %rsi
movl 0x4(%r13,%rcx,4), %edi
shrl %edi
imulq $0x28, %rdi, %rdi
movl 0x20(%r15,%rdi), %edi
andl $0x3fffffff, %edi       # imm = 0x3FFFFFFF
imulq %rsi, %rdi
movq %rdi, %xmm0
punpckldq 0xfc1a(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xfc22(%rip), %xmm0     # 0x165a0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
addsd %xmm1, %xmm2
incq %rcx
jmp 0x6937
movsd %xmm2, 0x18(%rsp)
movslq %ebx, %rax
movl (%rbp,%rax,4), %ebx
movq 0x30(%rsp), %rax
addl (%rax,%r14,4), %ebx
movq 0x20(%rsp), %rax
movq 0x70(%rsp), %rcx
movl (%rax,%rcx,4), %esi
movl (%rax), %r14d
movq 0x8(%rsp), %rdi
movq %r14, %rdx
callq 0x703e
movq %r12, %r13
movq 0x18(%rax), %r12
shrl %r14d
imulq $0x28, %r14, %rax
movl 0x20(%r15,%rax), %eax
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
imulq %r12, %rax
movq %rax, %xmm1
punpckldq 0xfba1(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xfba9(%rip), %xmm1     # 0x165a0
movq (%r13), %rcx
movq 0x10(%r13), %rax
cmpq 0x8(%r13), %rcx
jne 0x6a37
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rdx
movq %rdx, 0x8(%r13)
imulq $0x30, %rdx, %rsi
movq %rax, %rdi
movapd %xmm1, 0x70(%rsp)
callq 0x3330
movapd 0x70(%rsp), %xmm1
movq %rax, 0x10(%r13)
movq (%r13), %rcx
movl 0x40(%rsp), %edi
addl %ebx, %r12d
movq 0x38(%rsp), %rsi
subl %r12d, %esi
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movsd 0x18(%rsp), %xmm1
subsd %xmm0, %xmm1
andl $0x3fffffff, %edi       # imm = 0x3FFFFFFF
leaq 0x1(%rcx), %rdx
movq %rdx, (%r13)
imulq $0x30, %rcx, %rcx
andq $0x0, (%rax,%rcx)
orl $0x40000000, %edi       # imm = 0x40000000
movl %edi, 0x8(%rax,%rcx)
movq 0x20(%rsp), %rdx
movq %rdx, 0x10(%rax,%rcx)
movl %esi, 0x18(%rax,%rcx)
movsd %xmm1, 0x20(%rax,%rcx)
andq $0x0, 0x28(%rax,%rcx)
movq 0x10(%rsp), %rdi
callq 0x3060
movq 0x30(%rsp), %rdi
callq 0x3060
movq %rbp, %rdi
callq 0x3060
movq 0xc8(%rsp), %rcx
incq %rcx
movq 0x58(%rsp), %r15
movq 0x88(%rsp), %r12
jmp 0x639c
movq 0x16521(%rip), %rbx     # 0x1cff8
movq (%rbx), %rdi
leaq 0xfc75(%rip), %rsi      # 0x16756
leaq 0xfc99(%rip), %r14      # 0x16781
movq %r14, %rdx
movl 0x18(%rsp), %ecx
xorl %eax, %eax
callq 0x3290
movq (%rbx), %rdi
leaq 0xfc93(%rip), %rsi      # 0x16793
movq %r14, %rdx
xorl %eax, %eax
callq 0x3290
xorl %ebx, %ebx
cmpq %rbx, %r12
je 0x6b1f
movq (%r15,%rbx,8), %rdi
callq 0x70e8
incq %rbx
jmp 0x6b0c
movq %r15, %rdi
callq 0x3060
movq 0x60(%rsp), %rdi
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3060
leaq 0xfc74(%rip), %rdi      # 0x167bd
leaq 0xfb45(%rip), %rsi      # 0x16695
leaq 0xfbb7(%rip), %rcx      # 0x1670e
movl $0x515, %edx            # imm = 0x515
callq 0x3190
leaq 0xfc55(%rip), %rdi      # 0x167bd
leaq 0xfb26(%rip), %rsi      # 0x16695
leaq 0xfb98(%rip), %rcx      # 0x1670e
movl $0x522, %edx            # imm = 0x522
callq 0x3190
leaq 0xfb71(%rip), %rdi      # 0x166f8
leaq 0xfb07(%rip), %rsi      # 0x16695
leaq 0xfb79(%rip), %rcx      # 0x1670e
movl $0x4d8, %edx            # imm = 0x4D8
callq 0x3190
leaq 0xfc1b(%rip), %rdi      # 0x167c1
leaq 0xfae8(%rip), %rsi      # 0x16695
leaq 0xfb5a(%rip), %rcx      # 0x1670e
movl $0x52f, %edx            # imm = 0x52F
callq 0x3190