// File: /workspace/github_cpp_makefile_star2_O1/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, %r12
movq %rsi, %r15
movq (%rdi), %rax
movq 0x90(%rdi), %r13
movq %rdi, 0x8(%rsp)
movq 0xa8(%rdi), %r14
cmpq %rax, 0xa8(%rsi)
je 0x1f849a
movq %rdx, (%rsp)
cmpq %rax, 0xb0(%r15)
jae 0x1f8472
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0xb0(%r15)
movq 0xb8(%r15), %rdi
leaq 0x4(,%rcx,4), %rsi
callq 0x2370
movq %rax, 0xb8(%r15)
movq 0x8(%rsp), %rax
movq (%rax), %rdx
movq %rdx, 0xa8(%r15)
movq 0xb8(%r15), %rdi
shlq $0x2, %rdx
movl $0xff, %esi
callq 0x20e0
movq (%rsp), %rdx
testq %rbp, %rbp
je 0x1f860c
movq %r12, 0x10(%rsp)
movl (%r13,%rdx,4), %ebp
addl %ebp, %ebp
movq 0xa8(%r15), %r12
movq 0xb0(%r15), %rax
cmpq %rax, %r12
jne 0x1f84f0
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %esi
cmovneq %rcx, %rsi
movq %rsi, 0xb0(%r15)
movq 0xb8(%r15), %rdi
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0xb8(%r15)
movq 0xa8(%r15), %rcx
movq 0xb8(%r15), %rdx
leaq 0x1(%rcx), %rax
movq %rax, 0xa8(%r15)
movl %ebp, (%rdx,%rcx,4)
movl %r12d, %ecx
movq %rcx, (%rsp)
cmpq %rcx, %rax
jbe 0x1f8601
movq 0xb8(%r15), %rcx
leaq -0x1(%rax), %rdx
movq %rdx, 0xa8(%r15)
movl -0x4(%rcx,%rax,4), %eax
movl %eax, %edx
shrl %edx
movl (%r14,%rdx,4), %edx
movl %ebx, (%rcx,%rdx,4)
movq 0x8(%rsp), %rcx
movq 0x40(%rcx), %rcx
movq (%rcx,%rax,8), %rax
testl %eax, %eax
je 0x1f85f0
movq 0x8(%rsp), %rcx
movq 0x28(%rcx), %rcx
movq %rax, %rdx
shrq $0x20, %rdx
movl %eax, %r13d
shlq $0x4, %rdx
leaq (%rcx,%rdx), %r12
addq $0x8, %r12
shlq $0x4, %r13
xorl %ebp, %ebp
movq 0xb8(%r15), %rdi
movl (%r12,%rbp), %eax
shrl %eax
movl (%r14,%rax,4), %eax
movl (%rdi,%rax,4), %eax
cmpq %rbx, %rax
je 0x1f85e7
movq 0xb0(%r15), %rax
cmpq %rax, 0xa8(%r15)
jne 0x1f85c7
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0xb0(%r15)
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0xb8(%r15)
movl (%r12,%rbp), %eax
movq 0xa8(%r15), %rcx
movq 0xb8(%r15), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, 0xa8(%r15)
movl %eax, (%rdx,%rcx,4)
addq $0x10, %rbp
cmpq %rbp, %r13
jne 0x1f8577
movq 0xa8(%r15), %rax
cmpq (%rsp), %rax
ja 0x1f851c
cmpq (%rsp), %rax
movq 0x10(%rsp), %r12
jne 0x1f862e
movq 0xb8(%r15), %rax
movl (%rax,%r12,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 0x426da(%rip), %rdi     # 0x23ad0f
leaq 0x40ce9(%rip), %rsi     # 0x239325
leaq 0x426e1(%rip), %rcx     # 0x23ad24
movl $0x173b, %edx           # imm = 0x173B
callq 0x2110