// File: /workspace/github_cpp_makefile_star2_O1/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 $0x28, %rsp
testq %rdx, %rdx
je 0x210719
movq (%rcx), %rcx
movq (%rsi), %r14
movq %r14, %rax
shrq %rax
imulq $0x78, %rax, %rax
movl (%rcx,%rax), %eax
movq 0x1a0(%rdi), %r8
movl %eax, %r9d
andl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
movq (%r8,%r9,8), %r10
movq %r9, 0x20(%rsp)
movq 0x8(%r8,%r9,8), %r11
subq %r10, %r11
jne 0x210720
xorl %eax, %eax
jmp 0x210913
addl %eax, %eax
andl $0x1, %r14d
orq %rax, %r14
shlq $0x3, %r10
addq 0x1b8(%rdi), %r10
movq 0x1d0(%rdi), %rdi
cmpq $0x1, %rdx
setne 0xf(%rsp)
leaq -0x2(%rdx), %rax
movq %rax, 0x18(%rsp)
xorl %r15d, %r15d
xorl %eax, %eax
movq %r14, 0x10(%rsp)
movq (%r10,%r15,8), %r12
movq %r12, %r8
shrq $0x1b, %r8
andq $-0x20, %r8
movl 0x18(%rdi,%r8), %r13d
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
cmpl $0x2, %r13d
jb 0x210907
addq %rdi, %r8
movq 0x10(%r8), %rbp
movl %r12d, %r8d
movq (%rbp,%r8,8), %r8
movl %r8d, %r9d
shrl %r9d
cmpl %r9d, 0x20(%rsp)
jne 0x210922
movl %r8d, %r8d
cmpl %r8d, %r14d
jne 0x210848
cmpq $0x1, %rdx
sete %r8b
incl %r12d
cmpq %r13, %r12
setae %r9b
orb %r8b, %r9b
movb 0xf(%rsp), %bl
jne 0x210834
movq 0x8(%rsi), %r8
movq %r8, %r9
shrq %r9
imulq $0x78, %r9, %r9
movl (%rcx,%r9), %r9d
andl $0x1, %r8d
leal (%r8,%r9,2), %r8d
movb 0xf(%rsp), %bl
cmpl %r8d, (%rbp,%r12,8)
jne 0x210834
leaq 0x8(%rbp,%r12,8), %rbp
incq %r12
xorl %r8d, %r8d
leaq (%r12,%r8), %r14
leaq 0x2(%r8), %r9
cmpq %rdx, %r9
setb %bl
cmpq %r13, %r14
jae 0x210834
cmpq %rdx, %r9
jae 0x210834
movq 0x10(%rsi,%r8,8), %r14
movq %r14, %r9
shrq %r9
imulq $0x78, %r9, %r9
movl (%rcx,%r9), %r9d
andl $0x1, %r14d
leal (%r14,%r9,2), %r9d
leaq 0x1(%r8), %r14
cmpl %r9d, (%rbp,%r8,8)
movq %r14, %r8
je 0x2107f3
xorb $0x1, %bl
movzbl %bl, %r8d
addq %r8, %rax
movq 0x10(%rsp), %r14
jmp 0x210907
cmpq $0x1, %rdx
sete %r8b
decl %r12d
movslq %r12d, %rbx
testq %rbx, %rbx
sets %r9b
orb %r8b, %r9b
movb 0xf(%rsp), %r8b
jne 0x2108fc
movq 0x18(%rsp), %r8
cmpq %rbx, %r8
movq %rbx, %r12
cmovbq %r8, %r12
movq 0x8(%rsi), %r8
movq %r8, %r9
shrq %r9
imulq $0x78, %r9, %r9
movl (%rcx,%r9), %r9d
andl $0x1, %r8d
leal (%r8,%r9,2), %r9d
xorl (%rbp,%rbx,8), %r9d
movb 0xf(%rsp), %r8b
cmpl $0x1, %r9d
jne 0x2108fc
negq %r12
leaq -0x8(,%rbx,8), %rbx
addq %rbp, %rbx
movl $0x2, %r13d
movq %r13, %r8
leaq (%r12,%r13), %r9
cmpq $0x2, %r9
je 0x2108f0
movq (%rsi,%r8,8), %r9
movq %r9, %r14
shrq %r14
imulq $0x78, %r14, %r14
movl (%rcx,%r14), %r14d
andl $0x1, %r9d
leal (%r9,%r14,2), %r9d
xorl (%rbx), %r9d
leaq 0x1(%r8), %r13
addq $-0x8, %rbx
cmpl $0x1, %r9d
je 0x2108b8
cmpq %rdx, %r8
setb %r8b
movq 0x10(%rsp), %r14
xorb $0x1, %r8b
movzbl %r8b, %r8d
addq %r8, %rax
incq %r15
cmpq %r11, %r15
jne 0x210757
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2b442(%rip), %rdi     # 0x23bd6b
leaq 0x289f5(%rip), %rsi     # 0x239325
leaq 0x2c293(%rip), %rcx     # 0x23cbca
movl $0x334f, %edx           # imm = 0x334F
callq 0x2110