// File: /workspace/github_cpp_makefile_star2_O3/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 0x15730e(%rip), %rsi    # 0x2389cb
xorl %r14d, %r14d
movq %rax, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x15e123(%rip), %rsi    # 0x23f7f7
movq %r12, %rdi
callq 0x2210
testq %rax, %rax
je 0xe1832
movq %rax, %rdi
callq 0x2190
leaq 0x1572ef(%rip), %rsi    # 0x2389e3
xorl %r14d, %r14d
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x15e0ec(%rip), %rsi    # 0x23f7f7
movq %r12, %rdi
callq 0x2210
testq %rax, %rax
je 0xe1832
movq %rax, %rdi
callq 0x2190
testq %rbx, %rbx
je 0xe1760
leaq 0x1572cc(%rip), %rsi    # 0x2389fc
xorl %r14d, %r14d
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x15e0b0(%rip), %rsi    # 0x23f7f7
movq %r12, %rdi
callq 0x2210
testq %rax, %rax
je 0xe1832
movq %rax, %rdi
callq 0x2190
leaq 0x1572b3(%rip), %rsi    # 0x238a1a
xorl %r14d, %r14d
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x15e079(%rip), %rsi    # 0x23f7f7
movq %r12, %rdi
callq 0x2210
testq %rax, %rax
je 0xe1832
movq %rax, %rdi
callq 0x2190
testq %r13, %r13
je 0xe17cf
leaq 0x157290(%rip), %rsi    # 0x238a33
xorl %r14d, %r14d
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x15e03d(%rip), %rsi    # 0x23f7f7
movq %r12, %rdi
callq 0x2210
testq %rax, %rax
je 0xe1832
movq %rax, %rdi
callq 0x2190
cmpq $0x0, 0x50(%rsp)
je 0xe180a
leaq 0x15726c(%rip), %rsi    # 0x238a4a
xorl %r14d, %r14d
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x15e002(%rip), %rsi    # 0x23f7f7
movq %r12, %rdi
callq 0x2210
testq %rax, %rax
je 0xe1832
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 0xe1844
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 0xe1859
movq (%rax), %rdi
callq 0x2220
movq 0x8(%rsp), %rdx
movq (%rdx), %rax
testq %rax, %rax
je 0xe1869
movq (%rax), %rdi
callq 0x2220
testq %rbx, %rbx
je 0xe187b
movq (%rbx), %rdi
testq %rdi, %rdi
je 0xe187b
callq 0x2220
movq 0x8(%rbp), %rdi
callq 0x2220
testq %r13, %r13
je 0xe1897
movq (%r13), %rdi
testq %rdi, %rdi
je 0xe1897
callq 0xa0494
leaq 0x15708c(%rip), %rsi    # 0x23892a
xorl %r14d, %r14d
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
movq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0xbcbb
testl %eax, %eax
je 0xe1832
leaq 0x157074(%rip), %rsi    # 0x23893e
xorl %r14d, %r14d
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
movq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0xbcbb
testl %eax, %eax
je 0xe1832
testq %rbx, %rbx
je 0xe191e
leaq 0x157058(%rip), %rsi    # 0x238953
xorl %r14d, %r14d
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
movq %rbx, %rdi
movq %r12, %rsi
callq 0xf242b
testl %eax, %eax
je 0xe1832
leaq 0x157048(%rip), %rsi    # 0x23896d
xorl %r14d, %r14d
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
movq %rbp, %rdi
movq %r12, %rsi
callq 0xf2676
testl %eax, %eax
je 0xe1832
testq %r13, %r13
je 0xe1977
leaq 0x15702e(%rip), %rsi    # 0x238982
xorl %r14d, %r14d
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
movq %r13, %rdi
movq %r12, %rsi
callq 0xf2954
testl %eax, %eax
je 0xe1832
cmpq $0x0, 0x50(%rsp)
je 0xe19b4
leaq 0x15700f(%rip), %rsi    # 0x238995
xorl %r14d, %r14d
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x1b4893(%rip), %rdx    # 0x296230
movq 0x50(%rsp), %rdi
movq %r12, %rsi
xorl %ecx, %ecx
callq 0x1e67fb
testl %eax, %eax
je 0xe1832
movq 0x10(%rsp), %rax
movq (%rax), %rax
leaq 0x1b486d(%rip), %rcx    # 0x296230
movq %rax, 0x78(%rcx)
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x80(%rcx)
movl $0x1, %r14d
jmp 0xe1832