// File: chhylp123[P]hifiasm/gfa_ut.cpp
// Function: dd_path_connect(asg_t*, ul_str_t*)
uint64_t dd_path_connect(asg_t *g, ul_str_t *str)
{
    if(str->cn < 2) return 1;///actually should return 1, doesn't matter
    uint64_t i, v, w, nv, k; asg_arc_t *av;
    v = ((uint32_t)str->a[0]);
    for (i = 1; i < str->cn; i++) {
        w = ((uint32_t)str->a[i]);

        nv = asg_arc_n(g, v); av = asg_arc_a(g, v);
        for (k = 0; k < nv; k++) {
            if(av[k].del) continue;
            if(av[k].v == w) break;
        }
        if(k >= nv) return 0;

        nv = asg_arc_n(g, w^1); av = asg_arc_a(g, w^1);
        for (k = 0; k < nv; k++) {
            if(av[k].del) continue;
            if(av[k].v == (v^1)) break;
        }
        if(k >= nv) return 0;

        v = w;
    }
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpl $0x2, %eax
jge 0x339a4a
movq $0x1, -0x8(%rbp)
jmp 0x339c0e
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movl %eax, %eax
movq %rax, -0x28(%rbp)
movq $0x1, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x18(%rbp), %rcx
movl 0x18(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %ecx, %ecx
cmpq %rcx, %rax
jae 0x339c06
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq -0x28(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x339b24
movq -0x48(%rbp), %rax
imulq $0x18, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x339afd
jmp 0x339b16
movq -0x48(%rbp), %rax
imulq $0x18, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
cmpq -0x30(%rbp), %rax
jne 0x339b14
jmp 0x339b24
jmp 0x339b16
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x339ada
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jb 0x339b3b
movq $0x0, -0x8(%rbp)
jmp 0x339c0e
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x30(%rbp), %rcx
xorq $0x1, %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq -0x30(%rbp), %rdx
xorq $0x1, %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x339bd9
movq -0x48(%rbp), %rax
imulq $0x18, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x339bab
jmp 0x339bcb
movq -0x48(%rbp), %rax
imulq $0x18, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x28(%rbp), %rcx
xorq $0x1, %rcx
cmpq %rcx, %rax
jne 0x339bc9
jmp 0x339bd9
jmp 0x339bcb
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x339b88
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jb 0x339bed
movq $0x0, -0x8(%rbp)
jmp 0x339c0e
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x339a63
movq $0x1, -0x8(%rbp)
movq -0x8(%rbp), %rax
popq %rbp
retq
nopw %cs:(%rax,%rax)