// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: build_string_graph_without_clean(int, ma_hit_t_alloc*, ma_hit_t_alloc*, unsigned long, unsigned long*, long long, long long, long long, long long, float, float, char*, long long, int, int)
void build_string_graph_without_clean(
int min_dp, ma_hit_t_alloc* sources, ma_hit_t_alloc* reverse_sources, 
uint64_t n_read, uint64_t* readLen, long long mini_overlap_length, 
long long max_hang_length, long long clean_round, long long gap_fuzz,
float min_ovlp_drop_ratio, float max_ovlp_drop_ratio, char* output_file_name, 
long long bubble_dist, int read_graph, int write)
{
    R_to_U ruIndex;
    init_R_to_U(&ruIndex, n_read);
    asg_t *sg = NULL; uint8_t *cmk = NULL;
    ma_sub_t* coverage_cut = NULL;
    init_aux_table();
    ///actually min_thres = asm_opt.max_short_tip + 1 there are asm_opt.max_short_tip reads
    min_thres = asm_opt.max_short_tip + 1;
    if (asm_opt.flag & HA_F_VERBOSE_GFA)
    {
        if(load_debug_graph(/**NULL**/&sg, &sources, /**NULL**/&coverage_cut, output_file_name, &reverse_sources, &ruIndex, &UL_INF))
        {
            fprintf(stderr, "debug gfa has been loaded\n");
            
            clean_graph(min_dp, sources, reverse_sources, n_read, readLen, mini_overlap_length, 
            max_hang_length, clean_round, gap_fuzz, min_ovlp_drop_ratio, max_ovlp_drop_ratio, 
            output_file_name, bubble_dist, read_graph, &ruIndex, &sg, &coverage_cut, cmk, 1);
            asg_destroy(sg);
            free(coverage_cut);
            destory_R_to_U(&ruIndex);
            return;
        }
    }
    if (asm_opt.write_index_to_disk && write)
    {
        write_all_data_to_disk(sources, reverse_sources, 
        &R_INF, output_file_name);
    }
    ///debug_info_of_specfic_read("m64011_190830_220126/31720629/ccs", sources, reverse_sources, -1, "beg");

    if (!(asm_opt.flag & HA_F_BAN_ASSEMBLY))
    {
        // if(asm_opt.is_ont) handle_chemical_r(asm_opt.thread_num, R_INF.total_reads);
        if(asm_opt.is_ont) {
            uint64_t i = 0, j = 0;
            memset(ruIndex.index, -1, sizeof(uint32_t)*(ruIndex.len));
            for (i = 0; i < n_read; i++) {
                for (j = 0; j < sources[i].length; j++) sources[i].buffer[j].del = 0;
                for (j = 0; j < reverse_sources[i].length; j++) reverse_sources[i].buffer[j].del = 0;
            }
            if(asm_opt.is_ont) cmk = gen_chemical_arc_rf(asm_opt.thread_num, R_INF.total_reads);
        }
        try_rescue_overlaps(sources, reverse_sources, n_read, 4, asm_opt.is_ont); 
        
        clean_graph(min_dp, sources, reverse_sources, n_read, readLen, mini_overlap_length, 
        max_hang_length, clean_round, gap_fuzz, min_ovlp_drop_ratio, max_ovlp_drop_ratio, 
        output_file_name, bubble_dist, read_graph, &ruIndex, &sg, &coverage_cut, cmk, 0);
        
        asg_destroy(sg);
        free(coverage_cut);
    }

    destory_R_to_U(&ruIndex); free(cmk);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movl 0x40(%rbp), %eax
movl 0x38(%rbp), %eax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movl %edi, -0x2c(%rbp)
movq %rsi, -0x38(%rbp)
movq %rdx, -0x40(%rbp)
movq %rcx, -0x48(%rbp)
movq %r8, -0x50(%rbp)
movq %r9, -0x58(%rbp)
movss %xmm0, -0x5c(%rbp)
movss %xmm1, -0x60(%rbp)
movq -0x48(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x1508c0
movq $0x0, -0x80(%rbp)
movq $0x0, -0x88(%rbp)
movq $0x0, -0x90(%rbp)
callq 0x9690
leaq 0x25e9d2(%rip), %rax    # 0x3c47f8
movl 0x11c(%rax), %eax
addl $0x1, %eax
cltq
movq %rax, 0x25f688(%rip)    # 0x3c54c0
leaq 0x25e9b9(%rip), %rax    # 0x3c47f8
movl (%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x165f67
movq 0x28(%rbp), %rcx
leaq -0x80(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x90(%rbp), %rdx
leaq -0x40(%rbp), %r8
leaq -0x78(%rbp), %r9
leaq 0x25f549(%rip), %rax    # 0x3c53b8
movq %rax, (%rsp)
callq 0x133840
cmpl $0x0, %eax
je 0x165f65
movq 0x25e158(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
leaq 0x223e5c(%rip), %rsi    # 0x389cee
movb $0x0, %al
callq 0x22a0
movl -0x2c(%rbp), %edi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x48(%rbp), %rcx
movq -0x50(%rbp), %r8
movq -0x58(%rbp), %r9
movq 0x10(%rbp), %rax
movq 0x18(%rbp), %r10
movq %r10, -0xb0(%rbp)
movq 0x20(%rbp), %r13
movss -0x5c(%rbp), %xmm0
movss -0x60(%rbp), %xmm1
movq 0x28(%rbp), %r12
movq 0x30(%rbp), %r15
movl 0x38(%rbp), %r14d
movq -0x88(%rbp), %r10
movq %r10, -0xa8(%rbp)
leaq -0x78(%rbp), %rbx
leaq -0x80(%rbp), %r11
leaq -0x90(%rbp), %r10
movq %rax, (%rsp)
movq -0xb0(%rbp), %rax
movq %rax, 0x8(%rsp)
movq -0xa8(%rbp), %rax
movq %r13, 0x10(%rsp)
movq %r12, 0x18(%rsp)
movq %r15, 0x20(%rsp)
movl %r14d, 0x28(%rsp)
movq %rbx, 0x30(%rsp)
movq %r11, 0x38(%rsp)
movq %r10, 0x40(%rsp)
movq %rax, 0x48(%rsp)
movl $0x1, 0x50(%rsp)
callq 0x164f00
movq -0x80(%rbp), %rdi
callq 0xcd170
movq -0x90(%rbp), %rdi
callq 0x2210
leaq -0x78(%rbp), %rdi
callq 0x14e020
jmp 0x166241
jmp 0x165f67
leaq 0x25e88a(%rip), %rax    # 0x3c47f8
cmpl $0x0, 0xf4(%rax)
je 0x165f95
cmpl $0x0, 0x40(%rbp)
je 0x165f95
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq 0x28(%rbp), %rcx
leaq 0x25f340(%rip), %rdx    # 0x3c52d0
callq 0x1334c0
leaq 0x25e85c(%rip), %rax    # 0x3c47f8
movl (%rax), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
jne 0x16622c
leaq 0x25e845(%rip), %rax    # 0x3c47f8
cmpq $0x0, 0x2a8(%rax)
je 0x166137
movq $0x0, -0x98(%rbp)
movq $0x0, -0xa0(%rbp)
movq -0x70(%rbp), %rdi
movq -0x78(%rbp), %rdx
shlq $0x2, %rdx
movl $0xff, %esi
callq 0x2100
movq $0x0, -0x98(%rbp)
movq -0x98(%rbp), %rax
cmpq -0x48(%rbp), %rax
jae 0x166102
movq $0x0, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq -0x38(%rbp), %rcx
imulq $0x18, -0x98(%rbp), %rdx
addq %rdx, %rcx
movl 0xc(%rcx), %ecx
cmpq %rcx, %rax
jae 0x166079
movq -0x38(%rbp), %rax
imulq $0x18, -0x98(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
imulq $0x28, -0xa0(%rbp), %rcx
addq %rcx, %rax
movabsq $0x7fffffffffffffff, %rcx # imm = 0x7FFFFFFFFFFFFFFF
andq 0x18(%rax), %rcx
orq $0x0, %rcx
movq %rcx, 0x18(%rax)
movq -0xa0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa0(%rbp)
jmp 0x166014
movq $0x0, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq -0x40(%rbp), %rcx
imulq $0x18, -0x98(%rbp), %rdx
addq %rdx, %rcx
movl 0xc(%rcx), %ecx
cmpq %rcx, %rax
jae 0x1660e9
movq -0x40(%rbp), %rax
imulq $0x18, -0x98(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
imulq $0x28, -0xa0(%rbp), %rcx
addq %rcx, %rax
movabsq $0x7fffffffffffffff, %rcx # imm = 0x7FFFFFFFFFFFFFFF
andq 0x18(%rax), %rcx
orq $0x0, %rcx
movq %rcx, 0x18(%rax)
movq -0xa0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa0(%rbp)
jmp 0x166084
jmp 0x1660eb
movq -0x98(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x98(%rbp)
jmp 0x165ff8
leaq 0x25e6ef(%rip), %rax    # 0x3c47f8
cmpq $0x0, 0x2a8(%rax)
je 0x166135
leaq 0x25e6de(%rip), %rax    # 0x3c47f8
movslq 0x7c(%rax), %rdi
leaq 0x25f1ab(%rip), %rax    # 0x3c52d0
movq 0x50(%rax), %rsi
callq 0x26b7d0
movq %rax, -0x88(%rbp)
jmp 0x166137
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x48(%rbp), %rdx
leaq 0x25e6ae(%rip), %rax    # 0x3c47f8
movq 0x2a8(%rax), %rax
movl %eax, %r8d
movl $0x4, %ecx
callq 0x14fe60
movl -0x2c(%rbp), %edi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x48(%rbp), %rcx
movq -0x50(%rbp), %r8
movq -0x58(%rbp), %r9
movq 0x10(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq 0x18(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq 0x20(%rbp), %r13
movss -0x5c(%rbp), %xmm0
movss -0x60(%rbp), %xmm1
movq 0x28(%rbp), %r12
movq 0x30(%rbp), %r15
movl 0x38(%rbp), %r14d
movq -0x88(%rbp), %rax
movq %rax, -0xb8(%rbp)
leaq -0x78(%rbp), %rbx
leaq -0x80(%rbp), %r11
leaq -0x90(%rbp), %r10
xorl %eax, %eax
movq -0xc8(%rbp), %rax
movq %rax, (%rsp)
movq -0xc0(%rbp), %rax
movq %rax, 0x8(%rsp)
movq -0xb8(%rbp), %rax
movq %r13, 0x10(%rsp)
movq %r12, 0x18(%rsp)
movq %r15, 0x20(%rsp)
movl %r14d, 0x28(%rsp)
movq %rbx, 0x30(%rsp)
movq %r11, 0x38(%rsp)
movq %r10, 0x40(%rsp)
movq %rax, 0x48(%rsp)
movl $0x0, 0x50(%rsp)
callq 0x164f00
movq -0x80(%rbp), %rdi
callq 0xcd170
movq -0x90(%rbp), %rdi
callq 0x2210
leaq -0x78(%rbp), %rdi
callq 0x14e020
movq -0x88(%rbp), %rdi
callq 0x2210
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopw %cs:(%rax,%rax)