// File: /workspace/github_c_makefile_star2_O1/c-zhou[P]oatk/path.c
// Function: make_path_from_str
path_t make_path_from_str(asg_t *asg, char *path_str, char *sid)
{
    int circ;
    uint32_t v, cov;
    uint64_t len, len1;
    double wlen;
    kvec_t(uint32_t) vt;
    char *ptr, *s;

    kv_init(vt);

    while (isspace(*path_str) && *path_str != '\0')
        ++path_str;

    while (*path_str != '\0') {
        ptr = path_str;
        while (!isspace(*ptr) && *ptr != ',' && *ptr !='\0')
            ++ptr;

        if (*(ptr-1) == '+' || *(ptr-1) == '-') {
            s = strdup1(path_str, ptr - path_str - 1);
            v = asg_name2id(asg, s);
            if (v == UINT32_MAX) {
                fprintf(stderr, "[E::%s] sequence does not exist: %s\n", __func__, s);
                exit(EXIT_FAILURE);
            }
            v = (v<<1) | (*(ptr-1)=='-');
            kv_push(uint32_t, vt , v);
            free(s);
        } else {
            fprintf(stderr, "[E::%s] invalid path string: %s\n", __func__, path_str);
            exit(EXIT_FAILURE);
        }

        if (isspace(*ptr) || *ptr == '\0') break;
        path_str = ptr + 1;
    }
    
    if (vt.n == 0) {
        fprintf(stderr, "[E::%s] invalid path string: %s\n", __func__, path_str);
        exit(EXIT_FAILURE);
    }

    size_t i;
    asmg_t *g;
    asmg_arc_t *a;
    g = asg->asmg;
    a = asmg_arc1(g, vt.a[vt.n-1], vt.a[0]);
    circ = !!a;
    len = g->vtx[vt.a[0]>>1].len;
    cov = g->vtx[vt.a[0]>>1].cov;
    wlen = (double) cov * len;
    if (circ) len -= a->ls, wlen -= cov * a->ls;
    for (i = 1; i < vt.n; ++i) {
        len1 = g->vtx[vt.a[i]>>1].len;
        cov = g->vtx[vt.a[i]>>1].cov;
        len += len1;
        wlen += (double) cov * len1;
        a = asmg_arc1(g, vt.a[i-1], vt.a[i]);
        if (!a) {
            fprintf(stderr, "[W::%s] gap introduced as link does not exist: %s%c -> %s%c\n", __func__,
                    asg->seg[vt.a[i-1]>>1].name, "+-"[vt.a[i-1]&1],
                    asg->seg[vt.a[i]>>1].name, "+-"[vt.a[i]&1]);
        } else {
            len -= a->ls;
            wlen -= (double) cov * a->ls;
        }
    }

    path_t path = {sid? strdup1(sid, strlen(sid)) : 0, vt.n, circ, 0, vt.a, len, wlen, .0};
    
    return path;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, 0x18(%rsp)
movq %rdx, %r15
movq %rsi, 0x10(%rsp)
movq %rdi, 0x38(%rsp)
callq 0x34d0
movq (%rax), %rdx
decq %r15
movsbq 0x1(%r15), %rcx
incq %r15
testq %rcx, %rcx
je 0x822a
movzwl (%rdx,%rcx,2), %ecx
andl $0x2000, %ecx           # imm = 0x2000
jne 0x8211
cmpb $0x0, (%r15)
je 0x8374
movq $0x0, 0x8(%rsp)
movq $0x0, 0x20(%rsp)
xorl %r11d, %r11d
movq %rax, 0x40(%rsp)
movq (%rax), %rsi
movsbq (%r15), %rcx
movzwl (%rsi,%rcx,2), %edx
btl $0xd, %edx
movq %r15, %r13
jb 0x8283
movq %r15, %r13
testb %cl, %cl
je 0x8283
movzbl %cl, %ecx
cmpl $0x2c, %ecx
je 0x8283
movsbq 0x1(%r13), %rcx
incq %r13
movzwl (%rsi,%rcx,2), %edx
btl $0xd, %edx
jae 0x8265
movq %r11, %r12
movzbl -0x1(%r13), %ecx
cmpl $0x2d, %ecx
je 0x8299
cmpl $0x2b, %ecx
jne 0x864c
movl %r15d, %ebx
notl %ebx
addl %r13d, %ebx
movl %r13d, %edi
subl %r15d, %edi
callq 0x32f0
movq %rax, %r14
movq %rax, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x32c0
movb $0x0, (%r14,%rbx)
movq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x865c
cmpl $-0x1, %eax
je 0x8644
movl %eax, %ebx
xorl %ebp, %ebp
cmpb $0x2d, -0x1(%r13)
sete %cl
movq 0x20(%rsp), %rax
cmpq %rax, 0x8(%rsp)
movq %r12, %rdi
jne 0x8320
leaq (%rax,%rax), %r12
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %r12
leaq (,%r12,4), %rsi
movb %cl, 0x7(%rsp)
callq 0x3330
movb 0x7(%rsp), %cl
movq %rax, %rdi
movq %r12, 0x20(%rsp)
movb %cl, %bpl
leal (%rbp,%rbx,2), %eax
movq %rdi, %rbx
movq 0x8(%rsp), %rcx
movl %eax, (%rdi,%rcx,4)
incq %rcx
movq %rcx, 0x8(%rsp)
movq %r14, %rdi
callq 0x3060
movsbq (%r13), %rdx
testq %rdx, %rdx
je 0x8382
movq 0x40(%rsp), %rax
movq (%rax), %rcx
movzwl (%rcx,%rdx,2), %ecx
andl $0x2000, %ecx           # imm = 0x2000
jne 0x8382
leaq 0x1(%r13), %r15
cmpb $0x0, 0x1(%r13)
movq %rbx, %r11
jne 0x824e
jmp 0x8385
xorl %r11d, %r11d
movq $0x0, 0x8(%rsp)
jmp 0x8385
movq %rbx, %r11
cmpq $0x0, 0x8(%rsp)
je 0x8654
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rbx
movq 0x8(%rsp), %rax
movl -0x4(%r11,%rax,4), %edx
movl (%r11), %eax
movq 0x38(%rbx), %rcx
movq (%rcx,%rdx,8), %rcx
testq %rcx, %rcx
je 0x83e8
movq 0x30(%rbx), %rsi
movq (%rsi,%rdx,8), %rdx
leaq (%rdx,%rdx,2), %r13
shlq $0x4, %r13
addq 0x28(%rbx), %r13
movq 0x18(%rsp), %r15
cmpq %rax, 0x8(%r13)
jne 0x83da
testb $0x40, 0x23(%r13)
je 0x83f0
addq $0x30, %r13
decq %rcx
jne 0x83cd
xorl %r13d, %r13d
jmp 0x83f0
xorl %r13d, %r13d
movq 0x18(%rsp), %r15
movq 0x10(%rbx), %rdx
shrl %eax
leaq (%rax,%rax,4), %rax
movl 0x20(%rdx,%rax,8), %ecx
andl $0x3fffffff, %ecx       # imm = 0x3FFFFFFF
cvtsi2sd %ecx, %xmm1
movq 0x18(%rdx,%rax,8), %rax
movq %rax, %xmm2
punpckldq 0x11176(%rip), %xmm2 # xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
subpd 0x1117e(%rip), %xmm2    # 0x195a0
movapd %xmm2, %xmm0
unpckhpd %xmm2, %xmm0            # xmm0 = xmm0[1],xmm2[1]
addsd %xmm2, %xmm0
mulsd %xmm1, %xmm0
testq %r13, %r13
je 0x8467
movq 0x18(%r13), %rdx
subq %rdx, %rax
imulq %rdx, %rcx
movq %rcx, %xmm1
punpckldq 0x11141(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x11149(%rip), %xmm1    # 0x195a0
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
subsd %xmm2, %xmm0
cmpq $0x1, 0x8(%rsp)
jne 0x84c2
movq %rax, %rbp
movapd %xmm0, %xmm5
testq %r15, %r15
je 0x85fc
movq %r15, %rdi
movq %r11, %r12
movapd %xmm5, 0x20(%rsp)
callq 0x3130
movq %rax, %r14
leal 0x1(%rax), %edi
callq 0x32f0
movq %rax, %rbx
movl %r14d, %r14d
movq %rax, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x32c0
movapd 0x20(%rsp), %xmm5
movq %r12, %r11
movb $0x0, (%rbx,%r14)
jmp 0x85fe
addq $0x10, 0x10(%rsp)
movq 0x8(%rsp), %rcx
cmpq $0x3, %rcx
movl $0x2, %r12d
cmovaeq %rcx, %r12
movl $0x1, %r14d
movq 0x110a7(%rip), %xmm3    # 0x19590
movapd 0x110af(%rip), %xmm4    # 0x195a0
movl -0x4(%r11,%r14,4), %esi
movl (%r11,%r14,4), %ecx
movl %ecx, %edx
shrl %edx
leaq (%rdx,%rdx,4), %rdi
movq 0x10(%rbx), %r8
movq 0x18(%r8,%rdi,8), %rbp
movq %rbp, %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm4, %xmm1
movq 0x38(%rbx), %r9
movq (%r9,%rsi,8), %r10
testq %r10, %r10
je 0x854f
movq 0x30(%rbx), %r9
movq (%r9,%rsi,8), %r9
leaq (%r9,%r9,2), %r9
shlq $0x4, %r9
addq 0x28(%rbx), %r9
cmpq %rcx, 0x8(%r9)
jne 0x8546
testb $0x40, 0x23(%r9)
je 0x8552
addq $0x30, %r9
decq %r10
jne 0x8539
xorl %r9d, %r9d
movl 0x20(%r8,%rdi,8), %edi
movl $0x3fffffff, %r8d       # imm = 0x3FFFFFFF
andl %r8d, %edi
addq %rax, %rbp
xorps %xmm2, %xmm2
cvtsi2sd %edi, %xmm2
movapd %xmm1, %xmm5
unpckhpd %xmm1, %xmm5            # xmm5 = xmm5[1],xmm1[1]
addsd %xmm1, %xmm5
mulsd %xmm2, %xmm5
addsd %xmm0, %xmm5
testq %r9, %r9
je 0x85c3
movq 0x18(%r9), %rax
subq %rax, %rbp
movq %rax, %xmm0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm4, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd %xmm1, %xmm2
subsd %xmm2, %xmm5
incq %r14
movapd %xmm5, %xmm0
movq %rbp, %rax
cmpq %r12, %r14
jne 0x84f1
jmp 0x8476
movq 0x10(%rsp), %rdi
movq %r12, %r15
movq %r11, %r12
movapd %xmm5, 0x20(%rsp)
callq 0x37a7
movapd 0x20(%rsp), %xmm5
movapd 0x10fb9(%rip), %xmm4    # 0x195a0
movq 0x10fa1(%rip), %xmm3    # 0x19590
movq %r12, %r11
movq %r15, %r12
movq 0x18(%rsp), %r15
jmp 0x85ab
xorl %ebx, %ebx
xorl %ecx, %ecx
testq %r13, %r13
setne %cl
movq 0x38(%rsp), %rax
movq %rbx, (%rax)
movq 0x8(%rsp), %rdx
andl $0x3fffffff, %edx       # imm = 0x3FFFFFFF
shll $0x1e, %ecx
orl %edx, %ecx
movl %ecx, 0x8(%rax)
movq %r11, 0x10(%rax)
movl %ebp, 0x18(%rax)
movsd %xmm5, 0x20(%rax)
movq $0x0, 0x28(%rax)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
callq 0x3751
movq %r15, %rdi
callq 0x377c
movq %r15, %rdi
callq 0x3802