// File: /workspace/github_cpp_makefile_star2_O1/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, 0x8(%rsp)
movl %edx, %r12d
movq %rsi, 0x10(%rsp)
movq %rdi, %r15
cmpl $-0x1, %edx
jne 0xcc71c
leaq 0x1bebb3(%rip), %rbx    # 0x28b230
movq 0x50(%rbx), %rax
movq %rax, (%rsp)
testq %rax, %rax
je 0xcc716
movq %rcx, 0x18(%rsp)
movq %r8, 0x20(%rsp)
movq 0x40(%rbx), %r14
movq 0x10(%rsp), %rdi
callq 0x2090
movq %rax, %rcx
movq 0x8(%rbx), %rax
movq %rax, 0x28(%rsp)
xorl %eax, %eax
xorl %r12d, %r12d
movq %r14, 0x30(%rsp)
leal 0x1(%r12), %ebp
movq (%r14,%rbp,8), %r13
movq (%r14,%rax,8), %rbx
subq %rbx, %r13
cmpq %rcx, %r13
jne 0xcc6f9
addq 0x28(%rsp), %rbx
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %rcx, %r14
callq 0x21a0
movq %r14, %rcx
movq 0x30(%rsp), %r14
testl %eax, %eax
je 0xcc855
movl %ebp, %eax
movl %ebp, %r12d
cmpq %rax, (%rsp)
ja 0xcc6bc
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movq 0x20(%rsp), %r8
movq 0x18(%rsp), %rcx
jmp 0xcc71c
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
cmpl $-0x1, %r12d
je 0xcc7ff
testq %rcx, %rcx
sete %al
testq %r8, %r8
sete %dl
orb %al, %dl
je 0xcc83d
leaq 0x15e8ba(%rip), %rax    # 0x22affb
movq %rax, (%rsp)
testq %r15, %r15
je 0xcc80a
cmpq $0x0, (%r15)
je 0xcc80a
movl %r12d, %ebx
xorl %r13d, %r13d
xorl %eax, %eax
xorl %ebp, %ebp
movq 0x10(%r15), %rcx
leaq (,%r13,4), %rdx
addq %r13, %rdx
cmpl $0x0, 0xc(%rcx,%rdx,8)
je 0xcc7eb
leaq (%rcx,%rdx,8), %r14
movl 0x10(%r14), %r10d
testl %r10d, %r10d
je 0xcc7eb
xorl %r12d, %r12d
movq 0x18(%r14), %rcx
movq (%rcx,%r12,8), %rcx
shrq $0x21, %rcx
cmpl %ebx, %ecx
je 0xcc7a6
incq %r12
movl 0x10(%r14), %r10d
cmpq %r10, %r12
jb 0xcc788
jmp 0xcc7eb
movq 0x1bd833(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
movq 0x18(%r15), %rax
movq 0x20(%rax), %rax
movzbl 0x4(%rax,%r13,8), %r11d
leaq 0x15e7f7(%rip), %rsi    # 0x22afbc
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rcx
movl %r12d, %r8d
movl %ebp, %r9d
xorl %eax, %eax
pushq %r10
pushq %r11
callq 0x22b0
addq $0x10, %rsp
movl $0x1, %eax
jmp 0xcc798
incl %ebp
movq %rbp, %r13
cmpq %rbp, (%r15)
ja 0xcc762
testl %eax, %eax
jne 0xcc829
jmp 0xcc80a
leaq 0x15e7a2(%rip), %rax    # 0x22afa8
movq %rax, (%rsp)
movq 0x1bd7cf(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq 0x10(%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 %r12d, %edi
movq %rcx, %rsi
movq %r8, %rdx
movq 0x8(%rsp), %rcx
callq 0xa426
jmp 0xcc73a
movq 0x1bd784(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
leaq 0x15e730(%rip), %rsi    # 0x22af96
movq 0x8(%rsp), %rdx
movl %r12d, %ecx
movl %r13d, %r8d
movq %rbx, %r9
xorl %eax, %eax
callq 0x22b0
jmp 0xcc70a