// File: 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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movl $0xffffffff, -0x44(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x48(%rbp)
cmpl $-0x1, -0x1c(%rbp)
je 0x115c3e
movl -0x1c(%rbp), %eax
movl %eax, -0x44(%rbp)
jmp 0x115d77
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
leaq 0x2af681(%rip), %rcx    # 0x3c52d0
cmpq 0x50(%rcx), %rax
jae 0x115d75
leaq 0x2af670(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movl -0x3c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
leaq 0x2af659(%rip), %rcx    # 0x3c52d0
movq 0x40(%rcx), %rcx
movl -0x3c(%rbp), %edx
subq (%rcx,%rdx,8), %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rdi
callq 0x20a0
movq %rax, %rcx
movq -0x58(%rbp), %rax
cmpq %rcx, %rax
je 0x115ca0
jmp 0x115d67
movq -0x18(%rbp), %rdi
leaq 0x2af625(%rip), %rax    # 0x3c52d0
movq 0x8(%rax), %rsi
leaq 0x2af61a(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movl -0x3c(%rbp), %ecx
addq (%rax,%rcx,8), %rsi
leaq 0x2af608(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movl -0x3c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
leaq 0x2af5f1(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movl -0x3c(%rbp), %ecx
subq (%rax,%rcx,8), %rdx
callq 0x20b0
cmpl $0x0, %eax
jne 0x115d65
movq 0x2ae2e5(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x38(%rbp), %rdx
movl -0x3c(%rbp), %ecx
leaq 0x2af5c4(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movl -0x3c(%rbp), %esi
addl $0x1, %esi
movl %esi, %esi
movq (%rax,%rsi,8), %rax
leaq 0x2af5ad(%rip), %rsi    # 0x3c52d0
movq 0x40(%rsi), %rsi
movl -0x3c(%rbp), %r8d
subq (%rsi,%r8,8), %rax
movl %eax, %r8d
leaq 0x2af597(%rip), %rax    # 0x3c52d0
movq 0x8(%rax), %r9
leaq 0x2af58c(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movl -0x3c(%rbp), %esi
addq (%rax,%rsi,8), %r9
leaq 0x27201b(%rip), %rsi    # 0x387d71
movb $0x0, %al
callq 0x22a0
movl -0x3c(%rbp), %eax
movl %eax, -0x44(%rbp)
jmp 0x115d75
jmp 0x115d67
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x115c45
jmp 0x115d77
cmpl $-0x1, -0x44(%rbp)
jne 0x115da9
movq 0x2ae25c(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x38(%rbp), %rdx
movq -0x18(%rbp), %rcx
leaq 0x271fed(%rip), %rsi    # 0x387d83
movb $0x0, %al
callq 0x22a0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x115ee2
cmpq $0x0, -0x28(%rbp)
je 0x115dcb
cmpq $0x0, -0x30(%rbp)
je 0x115dcb
movl -0x44(%rbp), %edi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x38(%rbp), %rcx
callq 0x1154e0
cmpq $0x0, -0x10(%rbp)
je 0x115eb5
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x115eb3
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x3c(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jne 0x115e12
jmp 0x115ea5
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
movq -0x50(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x115ea3
movl -0x44(%rbp), %eax
movq -0x50(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl -0x40(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x21, %rcx
cmpq %rcx, %rax
jne 0x115e93
movq 0x2ae199(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x38(%rbp), %rdx
movq -0x18(%rbp), %rcx
movl -0x40(%rbp), %r8d
movl -0x3c(%rbp), %r9d
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movl -0x3c(%rbp), %esi
movzbl 0x4(%rax,%rsi,8), %r10d
movq -0x50(%rbp), %rax
movl 0x10(%rax), %eax
leaq 0x271f1a(%rip), %rsi    # 0x387d97
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x22a0
movl $0x1, -0x48(%rbp)
jmp 0x115e95
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x115e19
jmp 0x115ea5
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x115ddd
jmp 0x115eb5
cmpl $0x0, -0x48(%rbp)
jne 0x115edb
movq 0x2ae11e(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x38(%rbp), %rdx
movq -0x18(%rbp), %rcx
leaq 0x271f02(%rip), %rsi    # 0x387dd6
movb $0x0, %al
callq 0x22a0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)