// File: /workspace/github_cpp_makefile_star2_O3/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, (%rsp)
movl %edx, %r13d
movq %rsi, 0x8(%rsp)
movq %rdi, %r15
cmpl $-0x1, %edx
je 0xcda53
testq %rcx, %rcx
sete %al
testq %r8, %r8
sete %dl
orb %al, %dl
je 0xcdb0e
leaq 0x169865(%rip), %rax    # 0x2371eb
movq %rax, 0x10(%rsp)
testq %r15, %r15
je 0xcdadb
movq (%r15), %rcx
testq %rcx, %rcx
je 0xcdadb
movl %r13d, %ebx
xorl %r13d, %r13d
xorl %eax, %eax
xorl %ebp, %ebp
movq 0x10(%r15), %rdx
leaq (,%r13,4), %rsi
addq %r13, %rsi
cmpl $0x0, 0xc(%rdx,%rsi,8)
je 0xcda38
leaq (%rdx,%rsi,8), %r14
movl 0x10(%r14), %r10d
testl %r10d, %r10d
je 0xcda38
xorl %r12d, %r12d
movq 0x18(%r14), %rcx
movq (%rcx,%r12,8), %rcx
shrq $0x21, %rcx
cmpl %ebx, %ecx
je 0xcd9ed
incq %r12
movl %r10d, %ecx
cmpq %rcx, %r12
jb 0xcd9d0
jmp 0xcda35
movq 0x1c75ec(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
movq 0x18(%r15), %rax
movq 0x20(%rax), %rax
movzbl 0x4(%rax,%r13,8), %r11d
leaq 0x1697a0(%rip), %rsi    # 0x2371ac
movq (%rsp), %rdx
movq 0x8(%rsp), %rcx
movl %r12d, %r8d
movl %ebp, %r9d
xorl %eax, %eax
pushq %r10
pushq %r11
callq 0x22b0
addq $0x10, %rsp
movl 0x10(%r14), %r10d
movl $0x1, %eax
jmp 0xcd9e0
movq (%r15), %rcx
incl %ebp
movq %rbp, %r13
cmpq %rbp, %rcx
ja 0xcd9aa
testl %eax, %eax
jne 0xcdafa
jmp 0xcdadb
leaq 0x1c87d6(%rip), %rbx    # 0x296230
movq 0x50(%rbx), %rdx
leaq 0x169733(%rip), %rax    # 0x237198
movq %rax, 0x10(%rsp)
movq %rdx, 0x30(%rsp)
testq %rdx, %rdx
je 0xcdadb
movq %rcx, 0x18(%rsp)
movq %r8, 0x20(%rsp)
movq 0x40(%rbx), %r13
movq 0x8(%rsp), %rdi
callq 0x2090
movq %rax, %r12
movq 0x8(%rbx), %rax
movq %rax, 0x28(%rsp)
movq (%r13), %rbp
movl $0x1, %eax
movl %eax, %r14d
movq (%r13,%r14,8), %rbx
movq %rbx, %rax
subq %rbp, %rax
cmpq %r12, %rax
jne 0xcdacd
addq 0x28(%rsp), %rbp
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x21a0
testl %eax, %eax
je 0xcdb25
leal 0x1(%r14), %eax
movq %rbx, %rbp
cmpq %r14, 0x30(%rsp)
ja 0xcdaa1
movq 0x1c74fe(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
movq 0x10(%rsp), %rsi
movq (%rsp), %rdx
movq 0x8(%rsp), %rcx
xorl %eax, %eax
callq 0x22b0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r13d, %edi
movq %rcx, %rsi
movq %r8, %rdx
movq (%rsp), %rcx
callq 0xa3e7
jmp 0xcd97f
movq 0x1c74b4(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
leal -0x1(%r14), %r13d
leaq 0x16964c(%rip), %rsi    # 0x237186
movq (%rsp), %rdx
movl %r13d, %ecx
movl %r12d, %r8d
movq %rbp, %r9
xorl %eax, %eax
callq 0x22b0
testq %r14, %r14
movq 0x20(%rsp), %r8
movq 0x18(%rsp), %rcx
jne 0xcd96b
jmp 0xcdadb