// File: /workspace/github_cpp_makefile_star2_O3/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 0x21bb27
movq (%rcx), %rcx
movq (%rsi), %r8
movq %r8, %rax
shrq %rax
imulq $0x78, %rax, %rax
movl (%rcx,%rax), %eax
movq 0x1a0(%rdi), %r11
movl %eax, %r9d
andl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
movq (%r11,%r9,8), %r10
movq %r9, 0x10(%rsp)
movq 0x8(%r11,%r9,8), %r11
subq %r10, %r11
jne 0x21bb2e
xorl %eax, %eax
jmp 0x21bcda
addl %eax, %eax
andl $0x1, %r8d
orq %rax, %r8
shlq $0x3, %r10
addq 0x1b8(%rdi), %r10
movq 0x1d0(%rdi), %rdi
cmpq $0x1, %rdx
setne 0x7(%rsp)
leaq -0x2(%rdx), %rax
movq %rax, 0x8(%rsp)
xorl %r15d, %r15d
xorl %eax, %eax
movq (%r10,%r15,8), %r13
movq %r13, %rbx
shrq $0x1b, %rbx
andq $-0x20, %rbx
movl 0x18(%rdi,%rbx), %ebp
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
cmpl $0x2, %ebp
jb 0x21bcce
addq %rdi, %rbx
movq 0x10(%rbx), %r12
movl %r13d, %ebx
movq (%r12,%rbx,8), %rbx
movl %ebx, %r14d
shrl %r14d
cmpl %r14d, 0x10(%rsp)
jne 0x21bce9
movl %ebx, %ebx
movq %r8, %r9
cmpl %ebx, %r8d
jne 0x21bc1a
cmpq $0x1, %rdx
sete %bl
incl %r13d
cmpq %rbp, %r13
setae %r14b
orb %bl, %r14b
movb 0x7(%rsp), %bl
jne 0x21bcc1
incq %r13
movl $0x2, %r14d
movq -0x8(%rsi,%r14,8), %r8
movq %r8, %rbx
shrq %rbx
imulq $0x78, %rbx, %rbx
movl (%rcx,%rbx), %ebx
andl $0x1, %r8d
leal (%r8,%rbx,2), %r8d
cmpl %r8d, -0x8(%r12,%r13,8)
jne 0x21bcbf
cmpq %rdx, %r14
setb %bl
cmpq %rbp, %r13
jae 0x21bcc1
incq %r13
leaq 0x1(%r14), %r8
cmpq %rdx, %r14
movq %r8, %r14
jb 0x21bbd2
jmp 0x21bcc1
cmpq $0x1, %rdx
sete %r8b
decl %r13d
movslq %r13d, %rbp
testq %rbp, %rbp
sets %bl
orb %r8b, %bl
movb 0x7(%rsp), %bl
jne 0x21bcc1
movq 0x8(%rsp), %r8
cmpq %rbp, %r8
movq %rbp, %r13
cmovbq %r8, %r13
movq 0x8(%rsi), %r8
movq %r8, %rbx
shrq %rbx
imulq $0x78, %rbx, %rbx
movl (%rcx,%rbx), %ebx
andl $0x1, %r8d
leal (%r8,%rbx,2), %r8d
xorl (%r12,%rbp,8), %r8d
movb $0x1, %bl
cmpl $0x1, %r8d
jne 0x21bcc1
negq %r13
leaq (%r12,%rbp,8), %r12
addq $-0x8, %r12
movl $0x2, %ebx
movq %rbx, %r14
leaq (%rbx,%r13), %r8
cmpq $0x2, %r8
je 0x21bcb7
movq (%rsi,%r14,8), %r8
movq %r8, %rbx
shrq %rbx
imulq $0x78, %rbx, %rbx
movl (%rcx,%rbx), %ebx
andl $0x1, %r8d
leal (%r8,%rbx,2), %r8d
xorl (%r12), %r8d
leaq 0x1(%r14), %rbx
addq $-0x8, %r12
cmpl $0x1, %r8d
je 0x21bc7f
cmpq %rdx, %r14
setb %bl
jmp 0x21bcc1
movb $0x1, %bl
xorb $0x1, %bl
movzbl %bl, %r8d
addq %r8, %rax
movq %r9, %r8
incq %r15
cmpq %r11, %r15
jne 0x21bb60
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2c35f(%rip), %rdi     # 0x24804f
leaq 0x29912(%rip), %rsi     # 0x245609
leaq 0x2d1b0(%rip), %rcx     # 0x248eae
movl $0x334f, %edx           # imm = 0x334F
callq 0x2110