// File: 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
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movl $0x0, -0x6c(%rbp)
movl $0x0, -0x70(%rbp)
movq -0x28(%rbp), %rax
movl $0x0, (%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl -0x1c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x36c27d
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x1c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
cmpb $0x0, 0x70(%rax)
je 0x36c28a
movq $0x0, -0x8(%rbp)
jmp 0x36c7e7
movq -0x18(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x36c2ff
movq -0x18(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x36c2c4
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
shlq %rax
movq %rax, -0x80(%rbp)
jmp 0x36c2cf
movl $0x2, %eax
movq %rax, -0x80(%rbp)
jmp 0x36c2cf
movq -0x80(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0x1c(%rbp), %edx
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x18(%rbp), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x8(%rsi)
movl %edx, (%rax,%rcx,4)
jmp 0x36c322
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jbe 0x36c7c9
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x8(%rcx), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x4c(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl -0x4c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x36c379
jmp 0x36c322
movq -0x18(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x10(%rbp), %rdi
movl -0x4c(%rbp), %esi
movq -0x18(%rbp), %r8
leaq -0x58(%rbp), %rdx
leaq -0x40(%rbp), %rcx
callq 0x37d8c0
movl %eax, -0x74(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jae 0x36c3f9
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x48(%rcx), %rcx
movl -0x60(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, 0x18(%rax)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x36c3af
cmpl $0x7, -0x74(%rbp)
jne 0x36c40c
movq $0x0, -0x8(%rbp)
jmp 0x36c7e7
movl -0x58(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x10(%rbp), %rdi
movl -0x50(%rbp), %esi
movq -0x18(%rbp), %r8
leaq -0x58(%rbp), %rdx
leaq -0x40(%rbp), %rcx
callq 0x37d8c0
movl %eax, -0x74(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x40(%rbp), %rax
jl 0x36c453
movq -0x48(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x36c45e
movq -0x40(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movl -0x4c(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0x5c(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x5c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
addq $0x10, %rax
movl -0x5c(%rbp), %ecx
andl $0x1, %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x5c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
addq $0x10, %rax
movl -0x5c(%rbp), %ecx
andl $0x1, %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x64(%rbp)
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x54(%rbp), %eax
jae 0x36c603
movq -0x38(%rbp), %rax
movl -0x60(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x36c514
jmp 0x36c5f5
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x38(%rbp), %rcx
movl -0x60(%rbp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x36c550
jmp 0x36c5f5
jmp 0x36c552
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x36c5c4
movq -0x18(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x36c583
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
shlq %rax
movq %rax, -0x90(%rbp)
jmp 0x36c591
movl $0x2, %eax
movq %rax, -0x90(%rbp)
jmp 0x36c591
movq -0x90(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x38(%rbp), %rax
movl -0x60(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x8(%rax), %edx
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x18(%rbp), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x8(%rsi)
movl %edx, (%rax,%rcx,4)
jmp 0x36c5f5
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x36c4ea
movl -0x50(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0x5c(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x5c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
addq $0x10, %rax
movl -0x5c(%rbp), %ecx
andl $0x1, %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x5c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
addq $0x10, %rax
movl -0x5c(%rbp), %ecx
andl $0x1, %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x68(%rbp)
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x54(%rbp), %eax
jae 0x36c791
movq -0x38(%rbp), %rax
movl -0x60(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x36c6a2
jmp 0x36c783
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x38(%rbp), %rcx
movl -0x60(%rbp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x36c6de
jmp 0x36c783
jmp 0x36c6e0
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x36c752
movq -0x18(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x36c711
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
shlq %rax
movq %rax, -0x98(%rbp)
jmp 0x36c71f
movl $0x2, %eax
movq %rax, -0x98(%rbp)
jmp 0x36c71f
movq -0x98(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x38(%rbp), %rax
movl -0x60(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x8(%rax), %edx
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x18(%rbp), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x8(%rsi)
movl %edx, (%rax,%rcx,4)
jmp 0x36c783
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x36c678
cmpl $0x0, -0x64(%rbp)
jbe 0x36c7a6
cmpl $0x0, -0x68(%rbp)
jbe 0x36c7a6
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
cmpl $0x1, -0x64(%rbp)
jbe 0x36c7b5
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
cmpl $0x1, -0x68(%rbp)
jbe 0x36c7c4
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x36c322
cmpl $0x0, -0x6c(%rbp)
jbe 0x36c7df
cmpl $0x1, -0x70(%rbp)
jbe 0x36c7df
movq -0x28(%rbp), %rax
movl $0x1, (%rax)
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)