// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: load_ruIndex(R_to_U*, char*)
int load_ruIndex(R_to_U* ruIndex, char* read_file_name)
{
    char* index_name = (char*)malloc(strlen(read_file_name)+15);
    sprintf(index_name, "%s.bin", read_file_name);
    FILE* fp = fopen(index_name, "r");
    if(!fp)
    {
        return 0;
    }
    int f_flag = 0;
    f_flag += fread(&(ruIndex)->len, sizeof((ruIndex)->len), 1, fp);
    (ruIndex)->index = (uint32_t*)malloc(sizeof(uint32_t)*(ruIndex)->len);
    f_flag += fread((ruIndex)->index, sizeof((*((ruIndex)->index))), (ruIndex)->len, fp);

    if(!(asm_opt.ar)) {
        R_INF.trio_flag = (uint8_t*)malloc(sizeof(uint8_t)*(ruIndex)->len);
        f_flag += fread(R_INF.trio_flag, sizeof((*(R_INF.trio_flag))), (ruIndex)->len, fp);
    } else {
        fseek(fp, sizeof((*(R_INF.trio_flag)))*(ruIndex)->len, SEEK_CUR);
    }

    // CALLOC(ruIndex->is_het, ruIndex->len);
    // f_flag += fread(ruIndex->is_het, 1, ruIndex->len, fp);

    f_flag += fread(&(asm_opt.hom_global_coverage_set), sizeof(asm_opt.hom_global_coverage_set), 1, fp);
    f_flag += fread(&(asm_opt.hom_global_coverage), sizeof(asm_opt.hom_global_coverage), 1, fp);

    free(index_name);    
    fflush(fp);
    fclose(fp);

    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x20a0
movq %rax, %rdi
addq $0xf, %rdi
callq 0x2270
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0x233cc2(%rip), %rsi    # 0x38141a
movb $0x0, %al
callq 0x2050
movq -0x20(%rbp), %rdi
leaq 0x242c6c(%rip), %rsi    # 0x3903d6
callq 0x2200
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x14d786
movl $0x0, -0x4(%rbp)
jmp 0x14d8e8
movl $0x0, -0x2c(%rbp)
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rcx
movl $0x8, %esi
movl $0x1, %edx
callq 0x22e0
movq %rax, %rcx
movslq -0x2c(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
shlq $0x2, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
movq -0x28(%rbp), %rcx
movl $0x4, %esi
callq 0x22e0
movq %rax, %rcx
movslq -0x2c(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x2c(%rbp)
leaq 0x276ffb(%rip), %rax    # 0x3c47f8
cmpq $0x0, 0x68(%rax)
jne 0x14d851
movq -0x10(%rbp), %rax
movq (%rax), %rdi
shlq $0x0, %rdi
callq 0x2270
movq %rax, %rcx
leaq 0x277ab2(%rip), %rax    # 0x3c52d0
movq %rcx, 0x28(%rax)
leaq 0x277aa7(%rip), %rax    # 0x3c52d0
movq 0x28(%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
movq -0x28(%rbp), %rcx
movl $0x1, %esi
callq 0x22e0
movq %rax, %rcx
movslq -0x2c(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x2c(%rbp)
jmp 0x14d86a
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
shlq $0x0, %rsi
movl $0x1, %edx
callq 0x21b0
movq -0x28(%rbp), %rcx
leaq 0x276f83(%rip), %rdi    # 0x3c47f8
addq $0x148, %rdi            # imm = 0x148
movl $0x4, %esi
movl $0x1, %edx
callq 0x22e0
movq %rax, %rcx
movslq -0x2c(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x2c(%rbp)
movq -0x28(%rbp), %rcx
leaq 0x276f55(%rip), %rdi    # 0x3c47f8
addq $0x144, %rdi            # imm = 0x144
movl $0x4, %esi
movl $0x1, %edx
callq 0x22e0
movq %rax, %rcx
movslq -0x2c(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x2c(%rbp)
movq -0x20(%rbp), %rdi
callq 0x2210
movq -0x28(%rbp), %rdi
callq 0x21f0
movq -0x28(%rbp), %rdi
callq 0x21a0
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)