// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Overlaps.cpp
// Function: print_untig_by_read(ma_ug_t*, char const*, unsigned int, ma_hit_t_alloc*, ma_hit_t_alloc*, char const*)
uint32_t print_untig_by_read(ma_ug_t *g, const char* name, uint32_t in, ma_hit_t_alloc* sources, 
ma_hit_t_alloc* reverse_sources, const char* info)
{
	uint32_t i, k, rId = (uint32_t)-1, flag = 0;
    if(in != (uint32_t)-1) 
    {
        rId = in;
    }
    else
    {
        for (i = 0; i < R_INF.total_reads; ++i) 
        {
            if(Get_NAME_LENGTH(R_INF, i) != strlen(name)) continue;
            if(memcmp(name, Get_NAME(R_INF, i), Get_NAME_LENGTH(R_INF, i)) == 0)
            {
                fprintf(stderr, "%s: i: %u, >%.*s\n", info, i, 
                (int)Get_NAME_LENGTH((R_INF), i), Get_NAME((R_INF), i));
                rId = i;
                break;
            }
        }
    }
    
    

    if(rId == (uint32_t)-1)
    {
        fprintf(stderr, "%s: Cannot find %s\n", info, name);
        return (uint32_t)-1;
    }

    if(sources && reverse_sources) print_specfic_read_ovlp(rId, sources, reverse_sources, info); 

    if(g != NULL)
    {
        for (i = 0; i < g->u.n; ++i) 
        {
            ma_utg_t *u = &g->u.a[i];
            if(u->m == 0) continue;
            for (k = 0; k < u->n; k++)
            {
                if(rId == (u->a[k]>>33))
                {
                    fprintf(stderr, "%s: %s is the %u-th read at %u-th unitig (label: %u, occ: %u)\n", 
                    info, name, k, i, g->g->seq[i].c, u->n);
                    flag = 1;
                    ///return i;
                }
            }
        }
    }
	




    if(flag == 0) fprintf(stderr, "%s: %s is not at any unitig\n", info, name);
    return (uint32_t)-1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, %r14
movl %edx, %r12d
movq %rsi, (%rsp)
movq %rdi, %r15
cmpl $-0x1, %edx
je 0x929f3
testq %rcx, %rcx
sete %al
testq %r8, %r8
sete %dl
orb %al, %dl
jne 0x9293c
movl %r12d, %edi
movq %rcx, %rsi
movq %r8, %rdx
movq %r14, %rcx
callq 0x924e3
leaq 0x1567a8(%rip), %rax    # 0x1e90eb
movq %rax, 0x10(%rsp)
testq %r15, %r15
je 0x92a75
movl %r12d, %ebx
xorl %r12d, %r12d
xorl %eax, %eax
movl %r12d, %r12d
cmpq %r12, (%r15)
jbe 0x929d9
movq 0x10(%r15), %r13
imulq $0x28, %r12, %rcx
cmpl $0x0, 0xc(%r13,%rcx)
je 0x929d4
addq %rcx, %r13
xorl %ebp, %ebp
movl 0x10(%r13), %r10d
cmpq %r10, %rbp
jae 0x929d4
movq 0x18(%r13), %rcx
movq (%rcx,%rbp,8), %rcx
shrq $0x21, %rcx
cmpl %ebx, %ecx
je 0x92994
incq %rbp
jmp 0x92976
movq 0x1c0645(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
movq 0x18(%r15), %rax
movq 0x20(%rax), %rax
movzbl 0x4(%rax,%r12,8), %r11d
leaq 0x1566f9(%rip), %rsi    # 0x1e90ac
movq %r14, %rdx
movq (%rsp), %rcx
movl %ebp, %r8d
movl %r12d, %r9d
xorl %eax, %eax
pushq %r10
pushq %r11
callq 0x22b0
addq $0x10, %rsp
pushq $0x1
popq %rax
jmp 0x9298f
incl %r12d
jmp 0x92959
testl %eax, %eax
je 0x92a75
pushq $-0x1
popq %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rcx, 0x18(%rsp)
movq %r8, 0x20(%rsp)
movq %r14, 0x8(%rsp)
leaq 0x1c1827(%rip), %rax    # 0x254230
movq 0x50(%rax), %rcx
movq %rcx, 0x30(%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x28(%rsp)
movq 0x40(%rax), %r14
pushq $0x1
popq %rbx
leaq 0x15666f(%rip), %rax    # 0x1e9098
movq %rax, 0x10(%rsp)
leal -0x1(%rbx), %r12d
cmpq %r12, 0x30(%rsp)
jbe 0x92a70
movl %ebx, %eax
movq (%r14,%rax,8), %r13
movq (%r14,%r12,8), %rbp
subq %rbp, %r13
movq (%rsp), %rdi
callq 0x2090
cmpq %rax, %r13
jne 0x92a6c
addq 0x28(%rsp), %rbp
movq (%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x21a0
testl %eax, %eax
je 0x92a97
incl %ebx
jmp 0x92a2e
movq 0x8(%rsp), %r14
movq 0x1c0564(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
movq 0x10(%rsp), %rsi
movq %r14, %rdx
movq (%rsp), %rcx
xorl %eax, %eax
callq 0x22b0
jmp 0x929e1
movq 0x1c0542(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
leaq 0x1565de(%rip), %rsi    # 0x1e9086
movq 0x8(%rsp), %r14
movq %r14, %rdx
movl %r12d, %ecx
movl %r13d, %r8d
movq %rbp, %r9
xorl %eax, %eax
callq 0x22b0
testl %ebx, %ebx
movq 0x20(%rsp), %r8
movq 0x18(%rsp), %rcx
jne 0x9291b
jmp 0x92a75