// File: /workspace/github_cpp_makefile_star2_O3/soccin[P]BIC-RNAseq/tools/MergeFusion/Merger.cpp
// Function: Merger::loadFusionFile(char const*, CALLER_TYPE, bool, bool)
void Merger::loadFusionFile(const char* filename, CALLER_TYPE caller_id, bool normalize_chrom, bool normalize_gene)
{
#ifdef _DEBUG
    cout << "[DEBUG]: Loading " << CALLER_TYPE_STRING[caller_id] << " file: " << filename << endl;
#endif
    
    ifstream input_fs(filename);
    if(!input_fs)
    {
        cerr << "Error: fail to open input file: " << filename << endl;
        exit(1);
    }
    map<StandardFusion, size_t> collapse_star;
    string line;
    if(CALLER_HEADER[caller_id])
    {
        getline(input_fs, line);
#ifdef _DEBUG
        cout << "[DEBUG]: Header line: " << line << endl;
#endif
    }
    while(getline(input_fs, line))
    {
#ifdef _DEBUG
        cout << "[DEBUG]: Data line: " << line << endl;
#endif
        StandardFusion new_fusion_entry(line, caller_id, normalize_chrom, normalize_gene, hugo_map);
        if(caller_id != STAR)   // caller other than star
            fusion_vec.push_back(new_fusion_entry);
        else                    // collapse star entries for each fusion junction
        {
            if(collapse_star.find(new_fusion_entry) == collapse_star.end())
            {
                fusion_vec.push_back(new_fusion_entry);
                collapse_star.insert(make_pair(new_fusion_entry, fusion_vec.size() - 1));
            }
            else
            {
                size_t entry_index = collapse_star[new_fusion_entry];
                fusion_vec[entry_index].breakpoint_coverage ++;
            }
        }
    }
    input_fs.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x538, %rsp            # imm = 0x538
movl %r8d, %ebx
movl %ecx, %r15d
movl %edx, %r14d
movq %rsi, %r13
movq %rdi, -0x30(%rbp)
leaq -0x2b8(%rbp), %r12
movq %r12, %rdi
movl $0x8, %edx
callq 0x3360
movq (%r12), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x298(%rbp,%rax)
jne 0x48cc
leaq -0xa8(%rbp), %rdx
movl $0x0, (%rdx)
xorl %ecx, %ecx
movq %rcx, 0x8(%rdx)
movq %rdx, 0x10(%rdx)
movq %rdx, 0x18(%rdx)
movq %rcx, 0x20(%rdx)
leaq -0x48(%rbp), %rdx
movq %rdx, -0x10(%rdx)
movq %rcx, -0x8(%rdx)
movb $0x0, (%rdx)
movl %r14d, %ecx
leaq 0x86ab(%rip), %rdx      # 0xcd6f
cmpb $0x1, (%rdx,%rcx)
jne 0x46f2
leaq (%rax,%rbp), %rdi
addq $-0x2b8, %rdi           # imm = 0xFD48
movl $0xa, %esi
callq 0x31d0
movsbl %al, %edx
leaq -0x2b8(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x3370
leaq -0x70(%rbp), %r12
movq -0x30(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x60(%rbp)
movzbl %r15b, %eax
movl %eax, -0x38(%rbp)
movzbl %bl, %eax
movl %eax, -0x34(%rbp)
leaq -0x560(%rbp), %r13
leaq -0x2b8(%rbp), %r15
movq %r13, %rbx
movq -0x2b8(%rbp), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x31d0
movsbl %al, %edx
movq %r15, %rdi
leaq -0x58(%rbp), %rsi
callq 0x3370
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
leaq -0x80(%rbp), %r13
jne 0x487d
movq %r12, -0x80(%rbp)
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x41d6
movq %rbx, %rdi
movq %r13, %rsi
movl %r14d, %edx
movl -0x38(%rbp), %ecx
movl -0x34(%rbp), %r8d
movq -0x60(%rbp), %r9
callq 0x8644
movq -0x80(%rbp), %rdi
cmpq %r12, %rdi
je 0x47a2
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x3200
cmpl $0x5, %r14d
movq %rbx, %r13
jne 0x47ef
leaq -0xb0(%rbp), %rdi
movq %r13, %rsi
callq 0x651a
leaq -0xa8(%rbp), %rcx
cmpq %rcx, %rax
je 0x47fd
leaq -0xb0(%rbp), %rdi
movq %r13, %rsi
callq 0x5738
imulq $0x150, (%rax), %rax    # imm = 0x150
movq -0x30(%rbp), %rcx
movq (%rcx), %rcx
incl 0xa8(%rcx,%rax)
jmp 0x4870
movq -0x30(%rbp), %rdi
movq %r13, %rsi
callq 0x56fa
jmp 0x4870
movq -0x30(%rbp), %rdi
movq %r13, %rsi
callq 0x56fa
movl %r14d, %r12d
movq -0x30(%rbp), %rax
movq %r13, %rsi
movq (%rax), %r13
movq 0x8(%rax), %r15
leaq -0x410(%rbp), %r14
movq %r14, %rdi
callq 0x5b4a
subq %r13, %r15
sarq $0x4, %r15
movabsq $-0x30c30c30c30c30c3, %rax # imm = 0xCF3CF3CF3CF3CF3D
imulq %rax, %r15
decq %r15
movq %r15, -0x2c0(%rbp)
leaq -0xb0(%rbp), %rdi
movq %r14, %rsi
callq 0x657e
movq %r14, %rdi
callq 0xa34e
leaq -0x2b8(%rbp), %r15
movl %r12d, %r14d
leaq -0x70(%rbp), %r12
movq %rbx, %r13
movq %r13, %rdi
callq 0xa34e
jmp 0x471d
leaq -0x2b8(%rbp), %rdi
callq 0x3080
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x48a2
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3200
leaq -0xb0(%rbp), %rdi
callq 0x5e48
leaq -0x2b8(%rbp), %rdi
callq 0x3090
addq $0x538, %rsp            # imm = 0x538
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xc71d(%rip), %rdi      # 0x10ff0
leaq 0x7ca6(%rip), %rsi      # 0xc580
movl $0x20, %edx
callq 0x3250
movq 0xc705(%rip), %rdi      # 0x10ff0
movq %r13, %rsi
callq 0x31e0
movq %rax, %rdi
callq 0x3110
movl $0x1, %edi
callq 0x3260
movq %rax, %rbx
jmp 0x4978
jmp 0x4950
movq %rax, %rbx
leaq -0x410(%rbp), %rdi
callq 0xa34e
jmp 0x4926
jmp 0x4923
jmp 0x4923
jmp 0x4923
movq %rax, %rbx
leaq -0x560(%rbp), %rdi
callq 0xa34e
jmp 0x4953
movq %rax, %rbx
movq -0x80(%rbp), %rdi
cmpq %r12, %rdi
je 0x4953
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x3200
jmp 0x4953
jmp 0x4950
movq %rax, %rbx
leaq -0x48(%rbp), %rax
movq -0x58(%rbp), %rdi
cmpq %rax, %rdi
je 0x496c
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3200
leaq -0xb0(%rbp), %rdi
callq 0x5e48
leaq -0x2b8(%rbp), %rdi
callq 0x3090
movq %rbx, %rdi
callq 0x3340