// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: load_debug_graph(asg_t**, ma_hit_t_alloc**, ma_sub_t**, char*, ma_hit_t_alloc**, R_to_U*, all_ul_t*)
int load_debug_graph(asg_t** sg, ma_hit_t_alloc** sources, ma_sub_t** coverage_cut, 
char* output_file_name, ma_hit_t_alloc** reverse_sources, R_to_U* ruIndex, all_ul_t *ul_r_inf)
{
    FILE* fp = NULL;
    char* gfa_name = (char*)malloc(strlen(output_file_name)+55);
    sprintf(gfa_name, "%s.all.debug.source.bin", output_file_name);
    fp = fopen(gfa_name, "r"); if(!fp) return 0; fclose(fp);
    sprintf(gfa_name, "%s.all.debug.reverse.bin", output_file_name);
    fp = fopen(gfa_name, "r"); if(!fp) return 0; fclose(fp);
    if(coverage_cut) {
        sprintf(gfa_name, "%s.all.debug.coverage_cut.bin", output_file_name);
        fp = fopen(gfa_name, "r"); if(!fp) return 0; fclose(fp);
    }
    sprintf(gfa_name, "%s.all.debug.ruIndex.bin", output_file_name);
    fp = fopen(gfa_name, "r"); if(!fp) return 0; fclose(fp);
    if(sg) {
        sprintf(gfa_name, "%s.all.debug.asg_t.bin", output_file_name);
        fp = fopen(gfa_name, "r"); if(!fp) return 0; fclose(fp);
    }
    if(ul_r_inf) {
        sprintf(gfa_name, "%s.all.debug.ul.rinfor.ul.ovlp.bin", output_file_name);
        fp = fopen(gfa_name, "r"); if(!fp) return 0; fclose(fp);
    }
    
    if((sources == NULL) || (reverse_sources == NULL) || (ruIndex == NULL))
    {
        return 1;
    }

    if((*sources)!=NULL)
    {
        destory_ma_hit_t_alloc((*sources));
    }

    if((*reverse_sources)!=NULL)
    {
        destory_ma_hit_t_alloc((*reverse_sources));
    }

    if(coverage_cut && (*coverage_cut)!=NULL)
    {
        free((*coverage_cut));
    }

    if((ruIndex)!=NULL)
    {
        destory_R_to_U((ruIndex));
    }

    if(sg && (*sg)!=NULL)
    {
        asg_destroy(*sg);
    }

    

    sprintf(gfa_name, "%s.all.debug.source", output_file_name);
    if(!load_debug_ma_hit_ts(sources, gfa_name))
    {
        return 0;
    }

    sprintf(gfa_name, "%s.all.debug.reverse", output_file_name);
    if(!load_debug_ma_hit_ts(reverse_sources, gfa_name))
    {
        return 0;
    }

    if(coverage_cut) {
        sprintf(gfa_name, "%s.all.debug.coverage_cut", output_file_name);
        if(!load_coverage_cut(coverage_cut, gfa_name))
        {
            return 0;
        }
    }

    sprintf(gfa_name, "%s.all.debug.ruIndex", output_file_name);
    if(!load_ruIndex(ruIndex, gfa_name))
    {
        return 0;
    }

    if(sg) {
        sprintf(gfa_name, "%s.all.debug.asg_t", output_file_name);
        if(!load_asg_t(sg, gfa_name))
        {
            return 0;
        }
    }
    

    if(ul_r_inf) {
        sprintf(gfa_name, "%s.all.debug.ul.rinfor", output_file_name);
        if(!load_all_ul_t(ul_r_inf, gfa_name, &R_INF, NULL)) return 0;
    }

    R_INF.paf = (*sources); R_INF.reverse_paf = (*reverse_sources);

    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x28(%rbp), %rdi
callq 0x20a0
movq %rax, %rdi
addq $0x37, %rdi
callq 0x2270
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x255d62(%rip), %rsi    # 0x3895f6
movb $0x0, %al
callq 0x2050
movq -0x48(%rbp), %rdi
leaq 0x25cb30(%rip), %rsi    # 0x3903d6
callq 0x2200
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x1338c2
movl $0x0, -0x4(%rbp)
jmp 0x133c5b
movq -0x40(%rbp), %rdi
callq 0x21a0
movq -0x48(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x255d34(%rip), %rsi    # 0x38960e
movb $0x0, %al
callq 0x2050
movq -0x48(%rbp), %rdi
leaq 0x25caea(%rip), %rsi    # 0x3903d6
callq 0x2200
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x133908
movl $0x0, -0x4(%rbp)
jmp 0x133c5b
movq -0x40(%rbp), %rdi
callq 0x21a0
cmpq $0x0, -0x20(%rbp)
je 0x13395e
movq -0x48(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x255d00(%rip), %rsi    # 0x389627
movb $0x0, %al
callq 0x2050
movq -0x48(%rbp), %rdi
leaq 0x25ca9d(%rip), %rsi    # 0x3903d6
callq 0x2200
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x133955
movl $0x0, -0x4(%rbp)
jmp 0x133c5b
movq -0x40(%rbp), %rdi
callq 0x21a0
movq -0x48(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x255cd8(%rip), %rsi    # 0x389645
movb $0x0, %al
callq 0x2050
movq -0x48(%rbp), %rdi
leaq 0x25ca57(%rip), %rsi    # 0x3903d6
callq 0x2200
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x13399b
movl $0x0, -0x4(%rbp)
jmp 0x133c5b
movq -0x40(%rbp), %rdi
callq 0x21a0
cmpq $0x0, -0x10(%rbp)
je 0x1339f1
movq -0x48(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x255ca4(%rip), %rsi    # 0x38965e
movb $0x0, %al
callq 0x2050
movq -0x48(%rbp), %rdi
leaq 0x25ca0a(%rip), %rsi    # 0x3903d6
callq 0x2200
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x1339e8
movl $0x0, -0x4(%rbp)
jmp 0x133c5b
movq -0x40(%rbp), %rdi
callq 0x21a0
cmpq $0x0, 0x10(%rbp)
je 0x133a3e
movq -0x48(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x255c6e(%rip), %rsi    # 0x389675
movb $0x0, %al
callq 0x2050
movq -0x48(%rbp), %rdi
leaq 0x25c9bd(%rip), %rsi    # 0x3903d6
callq 0x2200
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x133a35
movl $0x0, -0x4(%rbp)
jmp 0x133c5b
movq -0x40(%rbp), %rdi
callq 0x21a0
cmpq $0x0, -0x18(%rbp)
je 0x133a53
cmpq $0x0, -0x30(%rbp)
je 0x133a53
cmpq $0x0, -0x38(%rbp)
jne 0x133a5f
movl $0x1, -0x4(%rbp)
jmp 0x133c5b
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
je 0x133a75
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0xce190
movq -0x30(%rbp), %rax
cmpq $0x0, (%rax)
je 0x133a8b
movq -0x30(%rbp), %rax
movq (%rax), %rdi
callq 0xce190
cmpq $0x0, -0x20(%rbp)
je 0x133aa8
movq -0x20(%rbp), %rax
cmpq $0x0, (%rax)
je 0x133aa8
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x2210
cmpq $0x0, -0x38(%rbp)
je 0x133ab8
movq -0x38(%rbp), %rdi
callq 0x14e020
cmpq $0x0, -0x10(%rbp)
je 0x133ad5
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x133ad5
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0xcd170
movq -0x48(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x255a71(%rip), %rsi    # 0x389555
movb $0x0, %al
callq 0x2050
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x1328a0
cmpl $0x0, %eax
jne 0x133b09
movl $0x0, -0x4(%rbp)
jmp 0x133c5b
movq -0x48(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x255a51(%rip), %rsi    # 0x389569
movb $0x0, %al
callq 0x2050
movq -0x30(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x1328a0
cmpl $0x0, %eax
jne 0x133b3d
movl $0x0, -0x4(%rbp)
jmp 0x133c5b
cmpq $0x0, -0x20(%rbp)
je 0x133b7a
movq -0x48(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x255a2b(%rip), %rsi    # 0x38957e
movb $0x0, %al
callq 0x2050
movq -0x20(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x14d470
cmpl $0x0, %eax
jne 0x133b78
movl $0x0, -0x4(%rbp)
jmp 0x133c5b
jmp 0x133b7a
movq -0x48(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x255a0f(%rip), %rsi    # 0x389598
movb $0x0, %al
callq 0x2050
movq -0x38(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x14d720
cmpl $0x0, %eax
jne 0x133bae
movl $0x0, -0x4(%rbp)
jmp 0x133c5b
cmpq $0x0, -0x10(%rbp)
je 0x133be8
movq -0x48(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x2559e9(%rip), %rsi    # 0x3895ad
movb $0x0, %al
callq 0x2050
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x14db00
cmpl $0x0, %eax
jne 0x133be6
movl $0x0, -0x4(%rbp)
jmp 0x133c5b
jmp 0x133be8
cmpq $0x0, 0x10(%rbp)
je 0x133c2d
movq -0x48(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x2559c2(%rip), %rsi    # 0x3895c0
movb $0x0, %al
callq 0x2050
movq 0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
leaq 0x2916bc(%rip), %rdx    # 0x3c52d0
xorl %eax, %eax
movl %eax, %ecx
callq 0x2fd8d0
cmpl $0x0, %eax
jne 0x133c2b
movl $0x0, -0x4(%rbp)
jmp 0x133c5b
jmp 0x133c2d
movq -0x18(%rbp), %rax
movq (%rax), %rcx
leaq 0x291695(%rip), %rax    # 0x3c52d0
movq %rcx, 0x78(%rax)
movq -0x30(%rbp), %rax
movq (%rax), %rcx
leaq 0x291683(%rip), %rax    # 0x3c52d0
movq %rcx, 0x80(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)