// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: dfs_usg_t_dis(usg_t*, buf_t*, unsigned int, unsigned int*)
uint64_t dfs_usg_t_dis(usg_t *g, buf_t *b, uint32_t x, uint32_t *p_bub)
{
    uint64_t len = 0; usg_arc_t *av = NULL; int64_t baseLen, uLen;
    uint32_t c_v, e_v, nv, convex, v, i, kv_0, kv_1, flag_0 = 0, flag_1 = 0, op;
    
    (*p_bub) = 0;
    if(b->a[x>>1].s || g->a[x>>1].del) return 0;
    b->S.n = 0;
    kv_push(uint32_t, b->S, x);

    while (b->S.n > 0) {
        b->S.n--;
        c_v = b->S.a[b->S.n];
        if(b->a[c_v>>1].s) continue;

        b->b.n = 0; //uint32_t gen_usg_tig(usg_t *g, uint32_t sid, uint32_t *eid, int64_t *baseLen, buf_t* b)
        op = gen_usg_tig(g, c_v, &convex, &baseLen, b);
        uLen = baseLen;
        for(i = 0; i < b->b.n; i++) b->a[b->b.a[i]>>1].s = 1;
        if(op == LOOP) return 0;


        e_v = convex^1;
        b->b.n = 0;
        op = gen_usg_tig(g, e_v, &convex, &baseLen, b);
        uLen = MAX(uLen, baseLen);

        len += uLen;

        
        v = c_v^1;
        nv = usg_arc_n(g, v); av = usg_arc_a(g, v);
        for (i = kv_0 = 0; i < nv; i++) {
            if(av[i].del) continue;
            kv_0++;
            if(b->a[av[i].v>>1].s) continue;
            kv_push(uint32_t, b->S, av[i].v);
        }

        v = e_v^1;
        nv = usg_arc_n(g, v); av = usg_arc_a(g, v);
        for (i = kv_1 = 0; i < nv; i++) {
            if(av[i].del) continue;
            kv_1++;
            if(b->a[av[i].v>>1].s) continue;
            kv_push(uint32_t, b->S, av[i].v);
        }

        if(kv_0 > 0 && kv_1 > 0) flag_0++;
        if(kv_0 > 1) flag_1++;
        if(kv_1 > 1) flag_1++;
    }

    if(flag_0 > 0 && flag_1 > 1) (*p_bub) = 1;
    return len;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %r15
movl %edx, %ebx
movl $0x0, (%rcx)
movq (%rsi), %rcx
movl %edx, %eax
shrl %eax
leaq (%rax,%rax,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rax, %rdx
cmpl $0x0, 0x18(%rcx,%rdx)
js 0x2252b1
movq %rdi, %r13
movq (%rdi), %rcx
imulq $0x78, %rax, %rax
cmpb $0x0, 0x70(%rcx,%rax)
je 0x2252c5
xorl %ebp, %ebp
movq %rbp, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %r14
movq $0x0, 0x8(%rsi)
cmpq $0x0, 0x10(%rsi)
je 0x2252e4
movq 0x18(%r14), %rax
movl %ebx, (%rax)
movl $0x1, %ecx
jmp 0x225311
movq $0x2, 0x10(%r14)
movq 0x18(%r14), %rdi
movl $0x8, %esi
callq 0x2370
movq %rax, 0x18(%r14)
movq 0x8(%r14), %rdx
movq %rdx, %rcx
incq %rcx
movq %rcx, 0x8(%r14)
movl %ebx, (%rax,%rdx,4)
je 0x2252b1
movq %r15, 0x28(%rsp)
xorl %edi, %edi
xorl %r8d, %r8d
xorl %ebp, %ebp
movq %r13, 0x20(%rsp)
movq %rcx, %rax
decq %rcx
movq %rcx, 0x8(%r14)
movq (%r14), %rdx
movq 0x18(%r14), %rsi
movl -0x4(%rsi,%rax,4), %ebx
movl %ebx, %r15d
shrl %r15d
leaq (%r15,%r15,8), %rax
leaq (%rax,%rax,2), %rax
addq %r15, %rax
cmpl $0x0, 0x18(%rdx,%rax)
js 0x2255a6
movl %r8d, 0x18(%rsp)
movl %edi, 0x1c(%rsp)
movq $0x0, 0x38(%r14)
movq %r13, %rdi
movl %ebx, %esi
leaq 0xc(%rsp), %rdx
leaq 0x10(%rsp), %rcx
movq %r14, %r8
callq 0x22d40b
movq 0x10(%rsp), %r12
cmpq $0x0, 0x38(%r14)
je 0x2253b7
movl $0x1, %ecx
xorl %edx, %edx
movq (%r14), %rsi
movq 0x48(%r14), %rdi
movl (%rdi,%rdx,4), %edx
shrl %edx
leaq (%rdx,%rdx,8), %rdi
leaq (%rdi,%rdi,2), %rdi
addq %rdx, %rdi
orl $0x80000000, 0x18(%rsi,%rdi) # imm = 0x80000000
movl %ecx, %edx
incl %ecx
cmpq %rdx, 0x38(%r14)
ja 0x22538e
cmpl $0x7, %eax
je 0x2252b1
movq %rbp, 0x40(%rsp)
movl 0xc(%rsp), %ebp
movl %ebp, %esi
xorl $0x1, %esi
movq $0x0, 0x38(%r14)
movq %r13, %rdi
leaq 0xc(%rsp), %rdx
leaq 0x10(%rsp), %rcx
movq %r14, %r8
callq 0x22d40b
movq 0x10(%rsp), %rax
cmpq %rax, %r12
cmovgq %r12, %rax
movq %rax, 0x38(%rsp)
movq (%r13), %rax
notl %ebx
andl $0x1, %ebx
imulq $0x78, %r15, %rcx
addq %rax, %rcx
leaq (%rbx,%rbx,2), %rdx
movl 0x10(%rcx,%rdx,8), %r13d
xorl %ebx, %ebx
movl $0x0, %r15d
testq %r13, %r13
je 0x2254be
movq %rbp, 0x30(%rsp)
movq 0x20(%rcx,%rdx,8), %r12
shlq $0x5, %r13
xorl %ebp, %ebp
xorl %r15d, %r15d
cmpl $0x0, 0xc(%r12,%rbp)
js 0x2254a8
incl %r15d
movq (%r14), %rax
movl 0x8(%r12,%rbp), %ecx
movl %ecx, %edx
shrl %edx
leaq (%rdx,%rdx,8), %rsi
leaq (%rsi,%rsi,2), %rsi
addq %rdx, %rsi
cmpl $0x0, 0x18(%rax,%rsi)
js 0x2254a8
movq 0x8(%r14), %rdx
movq 0x18(%r14), %rax
cmpq 0x10(%r14), %rdx
jne 0x22549d
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x10(%r14)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x18(%r14)
movl 0x8(%r12,%rbp), %ecx
movq 0x8(%r14), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%r14)
movl %ecx, (%rax,%rdx,4)
addq $0x20, %rbp
cmpq %rbp, %r13
jne 0x225439
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rsp), %rbp
movl %ebp, %ecx
shrl %ecx
andl $0x1, %ebp
imulq $0x78, %rcx, %rcx
addq %rax, %rcx
leaq (,%rbp,2), %rax
addq %rbp, %rax
movl 0x10(%rcx,%rax,8), %r13d
testq %r13, %r13
je 0x22556a
movq 0x20(%rcx,%rax,8), %rbp
shlq $0x5, %r13
xorl %r12d, %r12d
xorl %ebx, %ebx
cmpl $0x0, 0xc(%rbp,%r12)
js 0x225561
incl %ebx
movq (%r14), %rax
movl 0x8(%rbp,%r12), %ecx
movl %ecx, %edx
shrl %edx
leaq (%rdx,%rdx,8), %rsi
leaq (%rsi,%rsi,2), %rsi
addq %rdx, %rsi
cmpl $0x0, 0x18(%rax,%rsi)
js 0x225561
movq 0x8(%r14), %rdx
movq 0x18(%r14), %rax
cmpq 0x10(%r14), %rdx
jne 0x225556
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x10(%r14)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x18(%r14)
movl 0x8(%rbp,%r12), %ecx
movq 0x8(%r14), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%r14)
movl %ecx, (%rax,%rdx,4)
addq $0x20, %r12
cmpq %r12, %r13
jne 0x2254f3
movq 0x40(%rsp), %rbp
addq 0x38(%rsp), %rbp
testl %r15d, %r15d
setne %al
testl %ebx, %ebx
setne %cl
andb %al, %cl
movzbl %cl, %eax
movl 0x18(%rsp), %r8d
addl %eax, %r8d
cmpl $0x2, %r15d
movl 0x1c(%rsp), %edi
sbbl $-0x1, %edi
cmpl $0x2, %ebx
sbbl $-0x1, %edi
movq 0x8(%r14), %rcx
movq 0x20(%rsp), %r13
testq %rcx, %rcx
jne 0x225322
testl %r8d, %r8d
je 0x2252b3
cmpl $0x2, %edi
jb 0x2252b3
movq 0x28(%rsp), %rax
movl $0x1, (%rax)
jmp 0x2252b3