// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: get_arc_support_chain(ul_resolve_t*, unsigned long*, unsigned long, usg_t*)
uint64_t get_arc_support_chain(ul_resolve_t *uidx, uint64_t *a, uint64_t a_n, usg_t *ng)
{
    if(a_n <= 0) return 0;
    uint64_t *hid_a, hid_n; ul_str_idx_t *str_idx = &(uidx->pstr);
    uint64_t z, vz, occ = 0, v, w, ai; ul_str_t *str; int64_t s, s_n;
    v = (ng->a[a[0]>>1].mm<<1)|(a[0]&1);
    hid_a = str_idx->occ.a + str_idx->idx.a[v>>1];
    hid_n = str_idx->idx.a[(v>>1)+1] - str_idx->idx.a[v>>1];

    for (z = occ = 0; z < hid_n; z++) {
        str = &(str_idx->str.a[hid_a[z]>>32]); s_n = str->cn;
        if(s_n < 2) continue;
        vz = (uint32_t)(str->a[(uint32_t)hid_a[z]]);
        assert((v>>1) == (vz>>1)); 

        if(v == vz) {
            for(s = ((uint32_t)hid_a[z]) + 1, ai = 1; s < s_n && ai < a_n; s++, ai++) {
                w = (ng->a[a[ai]>>1].mm<<1)|(a[ai]&1);
                if(((uint32_t)(str->a[s])) != w) break;
            }
            if(ai >= a_n) occ++;
        } else {
            for(s = ((int32_t)((uint32_t)hid_a[z]))-1, ai = 1; s >= 0 && ai < a_n; s--, ai++) {
                w = (ng->a[a[ai]>>1].mm<<1)|(a[ai]&1);
                if(((uint32_t)(str->a[s])) != (w^1)) break;
            }
            if(ai >= a_n) occ++;
        }
    }
    return occ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rdx, %rdx
je 0x1cd097
movq (%rcx), %rcx
movq (%rsi), %rbp
movq %rbp, %rax
shrq %rax
imulq $0x78, %rax, %rax
movl (%rcx,%rax), %r11d
leal (%r11,%r11), %eax
andl $0x1, %ebp
orq %rax, %rbp
movq 0x1a0(%rdi), %rax
andl $0x7fffffff, %r11d      # imm = 0x7FFFFFFF
movq (%rax,%r11,8), %r8
movq 0x8(%rax,%r11,8), %r10
leaq (,%r8,8), %r9
addq 0x1b8(%rdi), %r9
subq %r8, %r10
xorl %eax, %eax
xorl %r14d, %r14d
movq %r10, 0x10(%rsp)
movq %r9, 0x8(%rsp)
cmpq %r10, %r14
je 0x1cd099
movq 0x1d0(%rdi), %rbx
movq (%r9,%r14,8), %r15
movq %r15, %r8
shrq $0x1b, %r8
andq $-0x20, %r8
movl 0x18(%rbx,%r8), %r12d
andl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
cmpl $0x2, %r12d
jb 0x1cd08f
addq %r8, %rbx
movq 0x10(%rbx), %r13
movl %r15d, %r8d
movq (%r13,%r8,8), %r8
movl %r8d, %ebx
shrl %ebx
cmpl %ebx, %r11d
jne 0x1cd0a8
movl %r8d, %r8d
cmpl %r8d, %ebp
jne 0x1cd019
movq %r11, %r10
movq %rbp, %r11
incl %r15d
leaq (%r13,%r15,8), %r13
xorl %ebx, %ebx
leaq 0x1(%rbx), %rbp
leaq (%r15,%rbx), %r9
cmpq %rdx, %rbp
setb %r8b
cmpq %r12, %r9
jae 0x1cd064
cmpq %rdx, %rbp
jae 0x1cd064
movq 0x8(%rsi,%rbx,8), %r8
movq %r8, %r9
shrq %r9
imulq $0x78, %r9, %r9
movl (%rcx,%r9), %r9d
andl $0x1, %r8d
leal (%r8,%r9,2), %r8d
cmpl %r8d, (%r13,%rbx,8)
jne 0x1cd061
movq %rbp, %rbx
jmp 0x1ccfd9
decl %r15d
movslq %r15d, %r15
pushq $0x1
popq %r12
cmpq %rdx, %r12
setb %r8b
testq %r15, %r15
js 0x1cd07f
cmpq %rdx, %r12
jae 0x1cd07f
movq (%rsi,%r12,8), %r8
movq %r8, %r9
shrq %r9
imulq $0x78, %r9, %r9
movl (%rcx,%r9), %r9d
andl $0x1, %r8d
leal (%r8,%r9,2), %r8d
xorl (%r13,%r15,8), %r8d
cmpl $0x1, %r8d
jne 0x1cd07c
decq %r15
incq %r12
jmp 0x1cd023
movb $0x1, %r8b
xorb $0x1, %r8b
movzbl %r8b, %r8d
addq %r8, %rax
movq %r11, %rbp
movq %r10, %r11
movq 0x10(%rsp), %r10
jmp 0x1cd08a
movb $0x1, %r8b
xorb $0x1, %r8b
movzbl %r8b, %r8d
addq %r8, %rax
movq 0x8(%rsp), %r9
incq %r14
jmp 0x1ccf6f
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2cf5f(%rip), %rdi     # 0x1fa00e
leaq 0x2a423(%rip), %rsi     # 0x1f74d9
leaq 0x2ddb0(%rip), %rcx     # 0x1fae6d
movl $0x334f, %edx           # imm = 0x334F
callq 0x2110