// File: 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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0xa8(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq 0xa8(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
je 0x332687
jmp 0x332528
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x33264f
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0xb0(%rax)
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0xb0(%rax)
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rcx
shrq %rcx
movq -0x18(%rbp), %rax
orq 0xb0(%rax), %rcx
movq %rcx, 0xb0(%rax)
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rcx
shrq $0x2, %rcx
movq -0x18(%rbp), %rax
orq 0xb0(%rax), %rcx
movq %rcx, 0xb0(%rax)
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rcx
shrq $0x4, %rcx
movq -0x18(%rbp), %rax
orq 0xb0(%rax), %rcx
movq %rcx, 0xb0(%rax)
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rcx
shrq $0x8, %rcx
movq -0x18(%rbp), %rax
orq 0xb0(%rax), %rcx
movq %rcx, 0xb0(%rax)
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rcx
shrq $0x10, %rcx
movq -0x18(%rbp), %rax
orq 0xb0(%rax), %rcx
movq %rcx, 0xb0(%rax)
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0xb0(%rax)
movq -0x18(%rbp), %rax
movq 0xb8(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0xb8(%rax)
jmp 0x332651
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0xa8(%rax)
movq -0x18(%rbp), %rax
movq 0xb8(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0xa8(%rax), %rdx
shlq $0x2, %rdx
movl $0xff, %esi
callq 0x2100
cmpq $0x0, -0x30(%rbp)
je 0x332947
movq -0x40(%rbp), %rax
movq -0x20(%rbp), %rcx
movl (%rax,%rcx,4), %eax
shll %eax
movl %eax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movq 0xa8(%rax), %rax
movl %eax, -0x54(%rbp)
movq -0x18(%rbp), %rax
movq 0xa8(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0xb0(%rcx), %rax
jne 0x332731
movq -0x18(%rbp), %rax
cmpq $0x0, 0xb0(%rax)
je 0x3326ea
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rax
shlq %rax
movq %rax, -0x68(%rbp)
jmp 0x3326f5
movl $0x2, %eax
movq %rax, -0x68(%rbp)
jmp 0x3326f5
movq -0x68(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0xb0(%rax)
movq -0x18(%rbp), %rax
movq 0xb8(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0xb8(%rax)
movl -0x50(%rbp), %edx
movq -0x18(%rbp), %rax
movq 0xb8(%rax), %rax
movq -0x18(%rbp), %rsi
movq 0xa8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0xa8(%rsi)
movl %edx, (%rax,%rcx,4)
jmp 0x33275d
movq -0x18(%rbp), %rax
movq 0xa8(%rax), %rax
movl -0x54(%rbp), %ecx
cmpq %rcx, %rax
jbe 0x332911
movq -0x18(%rbp), %rax
movq 0xb8(%rax), %rax
movq -0x18(%rbp), %rdx
movq 0xa8(%rdx), %rcx
movq %rcx, %rsi
addq $-0x1, %rsi
movq %rsi, 0xa8(%rdx)
movl -0x4(%rax,%rcx,4), %eax
movl %eax, -0x50(%rbp)
movq -0x38(%rbp), %rax
movl %eax, %edx
movq -0x18(%rbp), %rax
movq 0xb8(%rax), %rax
movq -0x48(%rbp), %rcx
movl -0x50(%rbp), %esi
shrl %esi
movl %esi, %esi
movl (%rcx,%rsi,4), %ecx
movl %edx, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movl -0x50(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x40(%rcx), %rcx
movl -0x50(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jae 0x33290c
movq -0x18(%rbp), %rax
movq 0xb8(%rax), %rax
movq -0x48(%rbp), %rcx
movq -0x60(%rbp), %rdx
movl -0x58(%rbp), %esi
shlq $0x4, %rsi
addq %rsi, %rdx
movl 0x8(%rdx), %edx
shrl %edx
movl %edx, %edx
movl (%rcx,%rdx,4), %ecx
movl (%rax,%rcx,4), %eax
cmpq -0x38(%rbp), %rax
jne 0x332841
jmp 0x3328fe
jmp 0x332843
movq -0x18(%rbp), %rax
movq 0xa8(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0xb0(%rcx), %rax
jne 0x3328c4
movq -0x18(%rbp), %rax
cmpq $0x0, 0xb0(%rax)
je 0x33287d
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rax
shlq %rax
movq %rax, -0x70(%rbp)
jmp 0x332888
movl $0x2, %eax
movq %rax, -0x70(%rbp)
jmp 0x332888
movq -0x70(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0xb0(%rax)
movq -0x18(%rbp), %rax
movq 0xb8(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0xb8(%rax)
movq -0x60(%rbp), %rax
movl -0x58(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %edx
movq -0x18(%rbp), %rax
movq 0xb8(%rax), %rax
movq -0x18(%rbp), %rsi
movq 0xa8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0xa8(%rsi)
movl %edx, (%rax,%rcx,4)
jmp 0x3328fe
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x332800
jmp 0x33275d
movq -0x18(%rbp), %rax
movq 0xa8(%rax), %rax
movl -0x54(%rbp), %ecx
cmpq %rcx, %rax
jne 0x332926
jmp 0x332945
leaq 0x65353(%rip), %rdi     # 0x397c80
leaq 0x63885(%rip), %rsi     # 0x3961b9
movl $0x173b, %edx           # imm = 0x173B
leaq 0x65355(%rip), %rcx     # 0x397c95
callq 0x2130
jmp 0x332947
movq -0x18(%rbp), %rax
movq 0xb8(%rax), %rax
movq -0x28(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpq -0x38(%rbp), %rax
jne 0x332969
movq $0x1, -0x8(%rbp)
jmp 0x332971
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)