// File: /workspace/github_cpp_makefile_star2_O1/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, -0x2c(%rbp)
movl %ecx, %r15d
movl %edx, %ebx
movq %rsi, %r13
movq %rdi, %r14
leaq -0x2b8(%rbp), %r12
movq %r12, %rdi
movl $0x8, %edx
callq 0x3360
movq (%r12), %rax
movq -0x18(%rax), %rcx
testb $0x5, -0x298(%rbp,%rcx)
jne 0x48c1
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 %ebx, %ecx
leaq 0x869d(%rip), %rdx      # 0xcd6f
cmpb $0x1, (%rdx,%rcx)
leaq -0x2b8(%rbp), %r13
jne 0x4703
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x31d0
movsbl %al, %edx
leaq -0x2b8(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x3370
leaq 0x18(%r14), %rax
movq %rax, -0x80(%rbp)
movzbl %r15b, %eax
movl %eax, -0x34(%rbp)
movzbl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
leaq -0x560(%rbp), %r12
movl %ebx, -0x30(%rbp)
movq -0x2b8(%rbp), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x31d0
movsbl %al, %edx
movq %r13, %rdi
leaq -0x58(%rbp), %rsi
callq 0x3370
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
leaq -0x78(%rbp), %r15
jne 0x4872
leaq -0x68(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x41f8
movq %r12, %rdi
movq %r15, %rsi
movl %ebx, %edx
movl -0x34(%rbp), %ecx
movl -0x2c(%rbp), %r8d
movq -0x80(%rbp), %r9
callq 0x862c
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x47ac
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x3200
cmpl $0x5, %ebx
jne 0x47ee
leaq -0xb0(%rbp), %rdi
movq %r12, %rsi
callq 0x64b8
leaq -0xa8(%rbp), %rcx
cmpq %rcx, %rax
je 0x47fb
leaq -0xb0(%rbp), %rdi
movq %r12, %rsi
callq 0x56f0
imulq $0x150, (%rax), %rax    # imm = 0x150
movq (%r14), %rcx
incl 0xa8(%rcx,%rax)
jmp 0x4865
movq %r14, %rdi
movq %r12, %rsi
callq 0x56b2
jmp 0x4865
movq %r14, %rdi
movq %r12, %rsi
callq 0x56b2
movq %r12, %rsi
movq (%r14), %r13
movq %r14, %rbx
movq 0x8(%r14), %r15
leaq -0x410(%rbp), %r14
movq %r14, %rdi
callq 0x5afa
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 0x6520
movq %r14, %rdi
callq 0xa332
leaq -0x2b8(%rbp), %r13
movq %rbx, %r14
movl -0x30(%rbp), %ebx
movq %r12, %rdi
callq 0xa332
jmp 0x4723
leaq -0x2b8(%rbp), %rdi
callq 0x3080
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x4897
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3200
leaq -0xb0(%rbp), %rdi
callq 0x5df8
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 0xc728(%rip), %rdi      # 0x10ff0
leaq 0x7cb1(%rip), %rsi      # 0xc580
movl $0x20, %edx
callq 0x3250
movq 0xc710(%rip), %rdi      # 0x10ff0
movq %r13, %rsi
callq 0x31e0
movq %rax, %rdi
callq 0x3110
movl $0x1, %edi
callq 0x3260
movq %rax, %rbx
jmp 0x4971
jmp 0x4949
movq %rax, %rbx
leaq -0x410(%rbp), %rdi
callq 0xa332
jmp 0x491b
jmp 0x4918
jmp 0x4918
jmp 0x4918
movq %rax, %rbx
leaq -0x560(%rbp), %rdi
callq 0xa332
jmp 0x494c
movq %rax, %rbx
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x494c
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x3200
jmp 0x494c
jmp 0x4949
movq %rax, %rbx
leaq -0x48(%rbp), %rax
movq -0x58(%rbp), %rdi
cmpq %rax, %rdi
je 0x4965
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3200
leaq -0xb0(%rbp), %rdi
callq 0x5df8
leaq -0x2b8(%rbp), %rdi
callq 0x3090
movq %rbx, %rdi
callq 0x3340
nop