// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %rbp
movq %r8, 0x8(%rsp)
movq %rcx, %r15
movq %rdx, %rbx
movq %rsi, 0x10(%rsp)
movq %rdi, %r13
movq %rcx, %rdi
callq 0x2090
leaq 0x37(%rax), %rdi
callq 0x2280
movq %rax, %r12
leaq 0x14c472(%rip), %rsi    # 0x22c7db
xorl %r14d, %r14d
movq %rax, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x153227(%rip), %rsi    # 0x2335a7
movq %r12, %rdi
callq 0x2210
testq %rax, %rax
je 0xe04de
movq %rax, %rdi
callq 0x2190
leaq 0x14c453(%rip), %rsi    # 0x22c7f3
xorl %r14d, %r14d
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x1531f0(%rip), %rsi    # 0x2335a7
movq %r12, %rdi
callq 0x2210
testq %rax, %rax
je 0xe04de
movq %rax, %rdi
callq 0x2190
testq %rbx, %rbx
je 0xe040c
leaq 0x14c430(%rip), %rsi    # 0x22c80c
xorl %r14d, %r14d
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x1531b4(%rip), %rsi    # 0x2335a7
movq %r12, %rdi
callq 0x2210
testq %rax, %rax
je 0xe04de
movq %rax, %rdi
callq 0x2190
leaq 0x14c417(%rip), %rsi    # 0x22c82a
xorl %r14d, %r14d
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x15317d(%rip), %rsi    # 0x2335a7
movq %r12, %rdi
callq 0x2210
testq %rax, %rax
je 0xe04de
movq %rax, %rdi
callq 0x2190
testq %r13, %r13
je 0xe047b
leaq 0x14c3f4(%rip), %rsi    # 0x22c843
xorl %r14d, %r14d
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x153141(%rip), %rsi    # 0x2335a7
movq %r12, %rdi
callq 0x2210
testq %rax, %rax
je 0xe04de
movq %rax, %rdi
callq 0x2190
cmpq $0x0, 0x50(%rsp)
je 0xe04b6
leaq 0x14c3d0(%rip), %rsi    # 0x22c85a
xorl %r14d, %r14d
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x153106(%rip), %rsi    # 0x2335a7
movq %r12, %rdi
callq 0x2210
testq %rax, %rax
je 0xe04de
movq %rax, %rdi
callq 0x2190
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
sete %al
movq 0x8(%rsp), %rdx
testq %rdx, %rdx
sete %cl
orb %al, %cl
testq %rbp, %rbp
sete %al
orb %cl, %al
movl $0x1, %r14d
je 0xe04f0
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rsi), %rax
testq %rax, %rax
je 0xe0505
movq (%rax), %rdi
callq 0x2220
movq 0x8(%rsp), %rdx
movq (%rdx), %rax
testq %rax, %rax
je 0xe0515
movq (%rax), %rdi
callq 0x2220
testq %rbx, %rbx
je 0xe0527
movq (%rbx), %rdi
testq %rdi, %rdi
je 0xe0527
callq 0x2220
movq 0x8(%rbp), %rdi
callq 0x2220
testq %r13, %r13
je 0xe0543
movq (%r13), %rdi
testq %rdi, %rdi
je 0xe0543
callq 0x9fcdb
leaq 0x14c1f0(%rip), %rsi    # 0x22c73a
xorl %r14d, %r14d
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
movq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0xbd31
testl %eax, %eax
je 0xe04de
leaq 0x14c1d8(%rip), %rsi    # 0x22c74e
xorl %r14d, %r14d
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
movq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0xbd31
testl %eax, %eax
je 0xe04de
testq %rbx, %rbx
je 0xe05ca
leaq 0x14c1bc(%rip), %rsi    # 0x22c763
xorl %r14d, %r14d
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
movq %rbx, %rdi
movq %r12, %rsi
callq 0xf05d7
testl %eax, %eax
je 0xe04de
leaq 0x14c1ac(%rip), %rsi    # 0x22c77d
xorl %r14d, %r14d
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
movq %rbp, %rdi
movq %r12, %rsi
callq 0xf0822
testl %eax, %eax
je 0xe04de
testq %r13, %r13
je 0xe0623
leaq 0x14c192(%rip), %rsi    # 0x22c792
xorl %r14d, %r14d
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
movq %r13, %rdi
movq %r12, %rsi
callq 0xf0b00
testl %eax, %eax
je 0xe04de
cmpq $0x0, 0x50(%rsp)
je 0xe0660
leaq 0x14c173(%rip), %rsi    # 0x22c7a5
xorl %r14d, %r14d
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x1aabe7(%rip), %rdx    # 0x28b230
movq 0x50(%rsp), %rdi
movq %r12, %rsi
xorl %ecx, %ecx
callq 0x1dc0e1
testl %eax, %eax
je 0xe04de
movq 0x10(%rsp), %rax
movq (%rax), %rax
leaq 0x1aabc1(%rip), %rcx    # 0x28b230
movq %rax, 0x78(%rcx)
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x80(%rcx)
movl $0x1, %r14d
jmp 0xe04de