// File: /workspace/github_cpp_makefile_star2_O2/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
andq $0x0, (%rdx)
movq %rsi, 0x28(%rsp)
movq %rdi, %rsi
movl %r9d, %ebx
movl (%rcx,%rbx,8), %edx
andq $0x0, 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, 0x10(%rsp)
pushq %r15
pushq $0x1
pushq %rax
pushq %r10
callq 0xc2ebf
addq $0x20, %rsp
movq (%r13,%rbx,8), %rax
shrq $0x21, %rax
movq %rax, 0x8(%rsp)
cmpq %rax, 0x8(%r14)
jae 0xad00c
movq 0x8(%rsp), %rax
decq %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)
xorl %ecx, %ecx
movq %r15, 0x18(%rsp)
movl %ecx, %ecx
cmpq %rcx, 0x38(%r15)
jbe 0xad10c
movq 0x48(%r15), %rax
movq %rcx, 0x20(%rsp)
movl (%rax,%rcx,4), %r12d
movl %r12d, %eax
shrl %eax
imulq $0x28, %rax, %rbx
movq 0x10(%rsp), %rax
addq 0x10(%rax), %rbx
pushq $-0x1
popq %r13
xorl %ebp, %ebp
movl 0x10(%rbx), %eax
cmpq %rax, %rbp
jae 0xad0fb
addl %r13d, %eax
testb $0x1, %r12b
movq 0x18(%rbx), %rcx
cmoveq %rbp, %rax
movq (%rcx,%rax,8), %rax
shrq $0x21, %rax
leal (%rax,%rax), %r15d
movq 0x28(%rsp), %rcx
movq 0x20(%rcx), %rcx
cmpb $0x2, 0x4(%rcx,%rax,8)
jne 0xad0b3
movq (%r14), %rcx
movq 0x10(%r14), %rax
cmpq 0x8(%r14), %rcx
jne 0xad0ad
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
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 0xad0e5
movq (%r14), %rcx
movq 0x10(%r14), %rax
cmpq 0x8(%r14), %rcx
jne 0xad0e5
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
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
decl %r13d
jmp 0xad044
movq 0x20(%rsp), %rcx
incl %ecx
movq 0x18(%rsp), %r15
jmp 0xad013
movq 0x8(%rsp), %rbx
cmpq %rbx, (%r14)
jne 0xad127
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1a5eb2(%rip), %rax    # 0x252fe0
movq (%rax), %rcx
leaq 0x13d191(%rip), %rdi    # 0x1ea2c9
pushq $0x18
popq %rsi
pushq $0x1
popq %rdx
callq 0x2410
jmp 0xad116