// File: /workspace/github_cpp_makefile_star2_O1/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 0x10109f
addq $0x20, %rsp
movq (%r13,%rbx,8), %rbx
shrq $0x21, %rbx
cmpq %rbx, 0x8(%r14)
jae 0xea4e8
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)
cmpq $0x0, 0x38(%r15)
je 0xea5e4
xorl %ecx, %ecx
movq %r15, 0x10(%rsp)
movq 0x48(%r15), %rax
movq %rcx, 0x20(%rsp)
movl (%rax,%rcx,4), %esi
movl %esi, %eax
shrl %eax
movq 0x18(%rsp), %rcx
movq 0x10(%rcx), %rcx
leaq (%rax,%rax,4), %rdx
movl 0x10(%rcx,%rdx,8), %eax
testl %eax, %eax
je 0xea5ce
leaq (%rcx,%rdx,8), %rbx
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
xorl %ebp, %ebp
xorl %r15d, %r15d
movl %esi, 0x4(%rsp)
testb $0x1, %sil
jne 0xea54a
movq 0x18(%rbx), %rax
addq %rbp, %rax
jmp 0xea555
addl %r13d, %eax
shlq $0x3, %rax
addq 0x18(%rbx), %rax
movq (%rax), %rax
shrq $0x21, %rax
leal (%rax,%rax), %r12d
movq 0x28(%rsp), %rcx
movq 0x20(%rcx), %rcx
cmpb $0x2, 0x4(%rcx,%rax,8)
jne 0xea574
orl $0x1, %r12d
movq 0x8(%r14), %rax
cmpq %rax, (%r14)
jne 0xea5a6
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%r14)
movq 0x10(%r14), %rdi
shlq $0x2, %rsi
callq 0x2370
movl 0x4(%rsp), %esi
movq %rax, 0x10(%r14)
movq (%r14), %rax
movq 0x10(%r14), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%r14)
movl %r12d, (%rcx,%rax,4)
incq %r15
movl 0x10(%rbx), %eax
addq $0x8, %rbp
decl %r13d
cmpq %rax, %r15
jb 0xea53b
movq 0x20(%rsp), %rcx
incl %ecx
movq 0x10(%rsp), %r15
cmpq %rcx, 0x38(%r15)
ja 0xea4ff
movq 0x8(%rsp), %rbx
cmpq %rbx, (%r14)
jne 0xea5ff
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x11634
jmp 0xea5ee