// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Overlaps.cpp
// Function: get_readSeq(ma_ug_t*, asg_t*, kvec_t_u32_warp*, unsigned long*, buf_t*, unsigned int)
uint32_t get_readSeq(ma_ug_t *ug, asg_t *read_g, kvec_t_u32_warp* x_vecs, uint64_t* cBeg, 
buf_t* b_0, uint32_t cId)
{
    ma_utg_t* reads = NULL;
    uint32_t beg, end, i, j, rId, xLen, uId, uOri;
    long long nodeLen, baseLen, max_stop_nodeLen, max_stop_baseLen;
    uint64_t tmp;

    x_vecs->a.n = 0;
    beg = (uint32_t)(cBeg[cId]);
    b_0->b.n = 0;
    get_unitig(ug->g, ug, beg, &end, &nodeLen, &baseLen, &max_stop_nodeLen, &max_stop_baseLen, 1, b_0);
    xLen = cBeg[cId]>>33;
    kv_resize(uint32_t, x_vecs->a, xLen);

    for (i = 0; i < b_0->b.n; i++)
    {
        uId = b_0->b.a[i]>>1;
        uOri = b_0->b.a[i]&(uint32_t)1;
        reads = &(ug->u.a[uId]);
        for (j = 0; j < reads->n; j++)
        {
            if(uOri == 1)
            {
                rId = reads->a[reads->n - j - 1]>>33;
            }
            else
            {
                rId = reads->a[j]>>33;
            }


            tmp = rId<<1;
            if(read_g->seq[rId].c == HAP_LABLE)
            {
                tmp = tmp | 1;
                kv_push(uint32_t, x_vecs->a, tmp);
                continue;
            }
            kv_push(uint32_t, x_vecs->a, tmp);
        }
    }


    if(x_vecs->a.n != xLen) fprintf(stderr, "ERROR: different length\n");
    return xLen;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r8, %r15
movq %rcx, %r13
movq %rdx, %r14
movq %rsi, 0x28(%rsp)
movq %rdi, %rsi
xorl %eax, %eax
movq %rax, (%rdx)
movl %r9d, %ebx
movl (%rcx,%rbx,8), %edx
movq %rax, 0x38(%r8)
movq 0x18(%rdi), %rdi
leaq 0x38(%rsp), %rax
leaq 0x40(%rsp), %r10
leaq 0x34(%rsp), %rcx
leaq 0x50(%rsp), %r8
leaq 0x48(%rsp), %r9
movq %rsi, 0x18(%rsp)
pushq %r15
pushq $0x1
pushq %rax
pushq %r10
callq 0x1053a7
addq $0x20, %rsp
movq (%r13,%rbx,8), %rbx
shrq $0x21, %rbx
cmpq %rbx, 0x8(%r14)
jae 0xebeea
leaq -0x1(%rbx), %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, 0x8(%r14)
movq 0x10(%r14), %rdi
leaq 0x4(,%rcx,4), %rsi
callq 0x2370
movq %rax, 0x10(%r14)
movq %rbx, 0x8(%rsp)
movq 0x38(%r15), %rax
testq %rax, %rax
je 0xec009
xorl %edi, %edi
movq %r15, 0x10(%rsp)
movq 0x48(%r15), %rcx
movl (%rcx,%rdi,4), %r12d
movl %r12d, %ecx
shrl %ecx
movq 0x18(%rsp), %rdx
movq 0x10(%rdx), %rdx
leaq (%rcx,%rcx,4), %rsi
movl 0x10(%rdx,%rsi,8), %ecx
testl %ecx, %ecx
je 0xebffe
movq %rdi, 0x20(%rsp)
leaq (%rdx,%rsi,8), %rbx
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
xorl %ebp, %ebp
addl %r13d, %ecx
testb $0x1, %r12b
movq 0x18(%rbx), %rax
cmoveq %rbp, %rcx
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
leal (%rax,%rax), %r15d
movq 0x28(%rsp), %rcx
movq 0x20(%rcx), %rcx
cmpb $0x2, 0x4(%rcx,%rax,8)
jne 0xebf9f
movq (%r14), %rcx
movq 0x10(%r14), %rax
cmpq 0x8(%r14), %rcx
jne 0xebf99
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r14)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x10(%r14)
movq (%r14), %rcx
orl $0x1, %r15d
jmp 0xebfd3
movq (%r14), %rcx
movq 0x10(%r14), %rax
cmpq 0x8(%r14), %rcx
jne 0xebfd3
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r14)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x10(%r14)
movq (%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r14)
movl %r15d, (%rax,%rcx,4)
incq %rbp
movl 0x10(%rbx), %ecx
decl %r13d
cmpq %rcx, %rbp
jb 0xebf3a
movq 0x10(%rsp), %r15
movq 0x38(%r15), %rax
movq 0x20(%rsp), %rdi
incl %edi
cmpq %rdi, %rax
ja 0xebf03
movq 0x8(%rsp), %rbx
cmpq %rbx, (%r14)
jne 0xec024
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x11387
jmp 0xec013