// File: /workspace/github_c_makefile_star2_O3/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 $0x28, %rsp
movl %r9d, 0x14(%rsp)
movq %r8, %r14
movq %rcx, 0x8(%rsp)
movl %edx, %ebx
movq %rsi, %r13
movq %rdi, %r15
testq %r8, %r8
je 0x165dd
movq $0x0, (%r14)
cmpq $0x0, 0x8(%r14)
je 0x165b5
movq 0x10(%r14), %rax
xorl %ecx, %ecx
jmp 0x165d2
movq $0x2, 0x8(%r14)
movq 0x10(%r14), %rdi
movl $0x10, %esi
callq 0x2350
movq %rax, 0x10(%r14)
movq (%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r14)
movq %r13, (%rax,%rcx,8)
xorl %ebp, %ebp
movq %r15, 0x18(%rsp)
movq 0x10(%r15), %rdi
movq %r13, %rax
shrq %rax
leaq (%rax,%rax,4), %r8
movl $0x1, %eax
testb $0x40, 0x23(%rdi,%r8,8)
jne 0x1676a
movq 0x38(%r15), %rdx
movq (%rdx,%r13,8), %r10
testq %r10, %r10
je 0x1676e
movq %rbx, 0x20(%rsp)
movq 0x28(%r15), %rcx
movq 0x30(%r15), %rsi
movq (%rsi,%r13,8), %r9
leaq (%r9,%r9,2), %r11
shlq $0x4, %r11
leaq (%rcx,%r11), %r9
leaq (%rcx,%r11), %rbx
addq $0x20, %rbx
xorl %r12d, %r12d
xorl %r13d, %r13d
xorl %r15d, %r15d
xorl %r11d, %r11d
testb $0x40, 0x3(%rbx)
jne 0x1665c
incq %r11
movq -0x8(%rbx), %r15
cmpq %r13, %r15
cmovaq %r15, %r13
movq %r12, %r15
incq %r12
addq $0x30, %rbx
cmpq %r12, %r10
jne 0x16645
movq 0x18(%rdi,%r8,8), %rbx
subq %r13, %rbx
cmpq $0x1, %r11
jne 0x1673e
leaq (%r15,%r15,2), %rax
shlq $0x4, %rax
movq 0x8(%r9,%rax), %r13
movq %r13, %rdi
xorq $0x1, %rdi
movq (%rdx,%rdi,8), %rdx
movl $0x3, %eax
testq %rdx, %rdx
je 0x16773
movq (%rsi,%rdi,8), %rsi
leaq (%rsi,%rsi,2), %rsi
shlq $0x4, %rsi
addq %rsi, %rcx
addq $0x20, %rcx
movq %rdx, %rsi
movl (%rcx), %edi
addl %edi, %edi
sarl $0x1f, %edi
movslq %edi, %rdi
addq %rdi, %rsi
addq $0x30, %rcx
decq %rdx
jne 0x166b6
cmpq $0x1, %rsi
movq 0x18(%rsp), %r15
jne 0x16773
testq %r14, %r14
je 0x1671f
movq (%r14), %rcx
movq 0x10(%r14), %rax
cmpq 0x8(%r14), %rcx
jne 0x16714
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r14)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2350
movq %rax, 0x10(%r14)
movq (%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r14)
movq %r13, (%rax,%rcx,8)
addq %rbx, %rbp
movq 0x20(%rsp), %rcx
leal -0x1(%rcx), %eax
cmpl $0x1, %ecx
movl %eax, %ebx
jg 0x165e4
xorl %eax, %eax
movq 0x8(%rsp), %rsi
jmp 0x1677b
testq %r11, %r11
movq 0x8(%rsp), %rsi
je 0x16778
testq %r14, %r14
sete %al
xorl %ecx, %ecx
cmpl $0x0, 0x14(%rsp)
sete %dl
cmoveq %rbx, %rcx
orb %al, %dl
movl $0x2, %eax
je 0x16792
addq %rcx, %rbp
jmp 0x1677b
xorl %ebx, %ebx
jmp 0x16773
movq 0x18(%rdi,%r8,8), %rbx
movq 0x8(%rsp), %rsi
addq %rbx, %rbp
testq %rsi, %rsi
je 0x16783
movq %rbp, (%rsi)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
decq (%r14)
jmp 0x1677b