// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: get_offset_from_contig_by_rId(ma_ug_t*, rIdContig*, unsigned int)
uint32_t get_offset_from_contig_by_rId(ma_ug_t *ug, rIdContig* array, uint32_t query_rId)
{
    uint32_t uId, rId;
    ma_utg_t* reads;
    for (;array->untigI < array->b_0->b.n; array->untigI++)
    {
        uId = array->b_0->b.a[array->untigI]>>1;
        ///if(IsMerge(ug->u, uId)>0) continue;
        reads = &(ug->u.a[uId]);
        for (;array->readI < reads->n; array->readI++, array->offset++)
        {
            rId = reads->a[array->readI]>>33;
            if(rId == query_rId) return array->offset;
        }
        array->readI = 0;
    }


    array->offset = 0;
    for (array->untigI = 0;array->untigI < array->b_0->b.n; array->untigI++)
    {
        uId = array->b_0->b.a[array->untigI]>>1;
        ///if(IsMerge(ug->u, uId)>0) continue;
        reads = &(ug->u.a[uId]);
        for (array->readI = 0;array->readI < reads->n; array->readI++, array->offset++)
        {
            rId = reads->a[array->readI]>>33;
            if(rId == query_rId) return array->offset;
        }
    }

    array->untigI = array->readI = array->offset = 0;
    return (uint32_t)-1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
cmpq 0x38(%rcx), %rax
jae 0x142a53
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x48(%rax), %rax
movq -0x18(%rbp), %rcx
movl 0x8(%rcx), %ecx
movl (%rax,%rcx,4), %eax
shrl %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x20(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x30(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x142a36
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x18(%rbp), %rcx
movl 0xc(%rcx), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jne 0x142a18
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x142b54
jmp 0x142a1a
movq -0x18(%rbp), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
jmp 0x1429d7
movq -0x18(%rbp), %rax
movl $0x0, 0xc(%rax)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
jmp 0x14298f
movq -0x18(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
cmpq 0x38(%rcx), %rax
jae 0x142b2c
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x48(%rax), %rax
movq -0x18(%rbp), %rcx
movl 0x8(%rcx), %ecx
movl (%rax,%rcx,4), %eax
shrl %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x20(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movl $0x0, 0xc(%rax)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x30(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x142b18
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x18(%rbp), %rcx
movl 0xc(%rcx), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jne 0x142afa
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x142b54
jmp 0x142afc
movq -0x18(%rbp), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
jmp 0x142abc
jmp 0x142b1a
movq -0x18(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
jmp 0x142a69
movq -0x18(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0xc(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x8(%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax)