// File: /workspace/github_c_makefile_star2_O2/c-zhou[P]oatk/graph.c
// Function: asmg_uext
static inline int32_t asmg_uext(asmg_t *g, uint64_t v, int32_t max_ext, uint64_t *ne, uint64_t *le, u64_v_t *a, int tip_only)
{
    // the extension of circular unitigs will be bounded by max_ext
    // and the return value will be ASMG_VT_MERGEABLE
    int32_t vt;
    uint64_t nv, nw, l, w, n_ext, l_ext;
    l = n_ext = l_ext = 0;
    if (a) a->n = 0;
    if (a) kv_push(uint64_t, *a, v);
    do {
        nv = asmg_arc_n2(g, v, &w, &l);
        if (nv == 0) {
            vt = ASMG_VT_TIP;
        } else if (nv > 1) {
            vt = ASMG_VT_MULTI_OUT;
        } else {
            nw = asmg_arc_n1(g, w^1);
            vt = nw == 1? ASMG_VT_MERGEABLE : ASMG_VT_MULTI_NEI;
        }
        l_ext += l;
        if (vt != ASMG_VT_MERGEABLE) break;
        ++n_ext;
        if (a) kv_push(uint64_t, *a, w);
        v = w;
    } while (--max_ext > 0);
    if (tip_only && vt == ASMG_VT_MULTI_OUT) {
        // for tip extenstion
        l_ext -= l;
        if (a) (*a).n--;
    }
    if (ne) *ne = n_ext;
    if (le) *le = l_ext;
    return vt;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r9d, 0xc(%rsp)
movq %r8, %r15
movq %rcx, 0x10(%rsp)
movl %edx, %r12d
movq %rsi, %rbp
movq %rdi, %r13
testq %r8, %r8
je 0x12918
andq $0x0, (%r15)
cmpq $0x0, 0x8(%r15)
je 0x128f2
movq 0x10(%r15), %rax
xorl %ecx, %ecx
jmp 0x1290d
movq $0x2, 0x8(%r15)
movq 0x10(%r15), %rdi
pushq $0x10
popq %rsi
callq 0x2350
movq %rax, 0x10(%r15)
movq (%r15), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r15)
movq %rbp, (%rax,%rcx,8)
xorl %ebx, %ebx
movq 0x10(%r13), %rax
movq %rbp, %rcx
shrq %rcx
imulq $0x28, %rcx, %rcx
movb $0x1, %sil
testb $0x40, 0x23(%rax,%rcx)
jne 0x12a23
movq 0x38(%r13), %rdx
movq (%rdx,%rbp,8), %rdi
movq 0x28(%r13), %rsi
movq 0x30(%r13), %rdx
imulq $0x30, (%rdx,%rbp,8), %r8
leaq (%rsi,%r8), %rdx
addq %rsi, %r8
addq $0x20, %r8
xorl %esi, %esi
xorl %r10d, %r10d
xorl %r9d, %r9d
xorl %r11d, %r11d
cmpq %r11, %rdi
je 0x12987
testb $0x40, 0x3(%r8)
jne 0x1297e
incq %rsi
movq -0x8(%r8), %r10
cmpq %r9, %r10
cmovaq %r10, %r9
movq %r11, %r10
incq %r11
addq $0x30, %r8
jmp 0x12961
movq 0x18(%rax,%rcx), %r14
subq %r9, %r14
cmpq $0x1, %rsi
jne 0x12a12
imulq $0x30, %r10, %rax
movq 0x8(%rdx,%rax), %rbp
movq %rbp, %rsi
xorq $0x1, %rsi
movq %r13, %rdi
callq 0x12e42
cmpq $0x1, %rax
jne 0x12a3b
testq %r15, %r15
je 0x129f9
movq (%r15), %rcx
movq 0x10(%r15), %rax
cmpq 0x8(%r15), %rcx
jne 0x129ee
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r15)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2350
movq %rax, 0x10(%r15)
movq (%r15), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r15)
movq %rbp, (%rax,%rcx,8)
addq %r14, %rbx
leal -0x1(%r12), %eax
cmpl $0x1, %r12d
movl %eax, %r12d
jg 0x1291a
xorl %eax, %eax
jmp 0x12a72
testq %rsi, %rsi
movl 0xc(%rsp), %edx
jne 0x12a32
pushq $0x2
popq %rax
pushq $0x1
popq %rdi
jmp 0x12a45
xorl %r14d, %r14d
movl 0xc(%rsp), %edx
pushq $0x2
popq %rax
pushq $0x1
popq %rdi
jmp 0x12a48
xorl %esi, %esi
pushq $0x2
popq %rax
movl %eax, %edi
jmp 0x12a48
pushq $0x3
popq %rdi
movl 0xc(%rsp), %edx
pushq $0x2
popq %rax
movb $0x1, %sil
testq %r15, %r15
sete %cl
testl %edx, %edx
sete %dl
orb %sil, %dl
orb %dl, %cl
xorl %esi, %esi
testb %dl, %dl
cmovnel %edi, %eax
cmovneq %r14, %rsi
testb %cl, %cl
je 0x12a6c
addq %rsi, %rbx
jmp 0x12a72
decq (%r15)
pushq $0x2
popq %rax
movq 0x10(%rsp), %rcx
testq %rcx, %rcx
je 0x12a7f
movq %rbx, (%rcx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq