// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: suffix_gorder_check(poa_g_t*, integer_t*, unsigned long, unsigned long, long, unsigned long)
int64_t suffix_gorder_check(poa_g_t *g, integer_t *buf, uint64_t gk_0, uint64_t gk_1, int64_t update_vis, uint64_t set_flag)
{
    uint32_t *g_idx = g->srt_b.res.a, *n2gidx = g->srt_b.res2nid.a, a_n, v, init_n, k; 
    poa_arc_t *a;
    if(buf->vis.n != g->seq.n) {
        kv_resize(uint32_t, buf->vis, g->seq.n); buf->vis.n = g->seq.n;
        memset(buf->vis.a, -1, sizeof((*buf->vis.a))*buf->vis.n);
    }

    if(update_vis) {
        v = g_idx[gk_0]<<1; init_n = buf->vis.n;
        kv_push(uint32_t, buf->vis, v); 
        while (buf->vis.n > init_n) {
            v = buf->vis.a[--buf->vis.n];
            buf->vis.a[n2gidx[v>>1]] = set_flag;
            a_n = poa_arc_n(g, v); a = poa_arc_a(g, v);
            for (k = 0; k < a_n; k++) {
                if(buf->vis.a[n2gidx[a[k].v>>1]] == set_flag) continue;
                kv_push(uint32_t, buf->vis, a[k].v);
            }
        }
        assert(buf->vis.n == init_n);
    }

    if(buf->vis.a[gk_1] == set_flag) return 1;
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %rbx
movq %r8, %rbp
movq %rcx, 0x8(%rsp)
movq %rdx, %r13
movq %rsi, %r15
movq (%rdi), %rdx
movq 0x90(%rdi), %r12
movq %rdi, (%rsp)
movq 0xa8(%rdi), %r14
cmpq %rdx, 0xa8(%rsi)
je 0x1b7cef
cmpq %rdx, 0xb0(%r15)
jae 0x1b7cd3
decq %rdx
movq %rdx, %rax
shrq %rax
orq %rdx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x10, %rax
orq %rcx, %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xb0(%r15)
movq 0xb8(%r15), %rdi
leaq 0x4(,%rax,4), %rsi
callq 0x2370
movq %rax, %rdi
movq %rax, 0xb8(%r15)
movq (%rsp), %rax
movq (%rax), %rdx
jmp 0x1b7cda
movq 0xb8(%r15), %rdi
movq %rdx, 0xa8(%r15)
shlq $0x2, %rdx
movl $0xff, %esi
callq 0x20e0
testq %rbp, %rbp
je 0x1b7d3f
movl (%r12,%r13,4), %ebp
addl %ebp, %ebp
movq 0xa8(%r15), %r12
pushq $0x2
popq %rax
cmpq 0xb0(%r15), %r12
jne 0x1b7d4b
leaq (%r12,%r12), %rsi
testq %r12, %r12
cmoveq %rax, %rsi
movq %rsi, 0xb0(%r15)
movq 0xb8(%r15), %rdi
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0xb8(%r15)
movq 0xa8(%r15), %rdx
jmp 0x1b7d55
movq 0xb8(%r15), %rax
jmp 0x1b7e2a
movq 0xb8(%r15), %rax
movq %r12, %rdx
leaq 0x1(%rdx), %rcx
movq %rcx, 0xa8(%r15)
movl %ebp, (%rax,%rdx,4)
movl %r12d, %edx
movq %rdx, 0x10(%rsp)
cmpq 0x10(%rsp), %rcx
jbe 0x1b7e28
leaq -0x1(%rcx), %rdx
movq %rdx, 0xa8(%r15)
movl -0x4(%rax,%rcx,4), %ecx
movl %ecx, %esi
shrl %esi
movl (%r14,%rsi,4), %esi
movl %ebx, (%rax,%rsi,4)
movq (%rsp), %rdi
movq 0x28(%rdi), %rsi
movq 0x40(%rdi), %rdi
movq (%rdi,%rcx,8), %rcx
movl %ecx, %ebp
shlq $0x4, %rbp
shrq $0x1c, %rcx
andq $-0x10, %rcx
leaq (%rsi,%rcx), %r12
addq $0x8, %r12
xorl %r13d, %r13d
movq %rdx, %rcx
cmpq %r13, %rbp
je 0x1b7d6b
movl (%r12,%r13), %edx
movl %edx, %esi
shrl %esi
movl (%r14,%rsi,4), %esi
movl (%rax,%rsi,4), %esi
cmpq %rbx, %rsi
je 0x1b7e22
cmpq 0xb0(%r15), %rcx
jne 0x1b7e11
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0xb0(%r15)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0xb8(%r15)
movl (%r12,%r13), %edx
movq 0xa8(%r15), %rcx
leaq 0x1(%rcx), %rsi
movq %rsi, 0xa8(%r15)
movl %edx, (%rax,%rcx,4)
movq %rsi, %rcx
addq $0x10, %r13
jmp 0x1b7dbc
jne 0x1b7e49
movq 0x8(%rsp), %rcx
movl (%rax,%rcx,4), %ecx
xorl %eax, %eax
cmpq %rbx, %rcx
sete %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x410ff(%rip), %rdi     # 0x1f8f4f
leaq 0x3f682(%rip), %rsi     # 0x1f74d9
leaq 0x41106(%rip), %rcx     # 0x1f8f64
movl $0x173b, %edx           # imm = 0x173B
callq 0x2110