// File: kelvinabrokwa[P]bottleneck/./CBottleneckDistance.cpp
// Function: CBottleneckDistance::LoadGeneratorsFromFile(char const*, std::vector<Generator, std::allocator<Generator>>&, double)
void CBottleneckDistance::LoadGeneratorsFromFile(
        const char* fileName, std::vector<Generator> &generators, double maxLevel)
{

    Generator gen;

    // erase generators
    generators.clear();

    // Open the file
    std::ifstream infile(fileName,  std::ifstream::in);

    //Test if the file was sucssefuly opened
    if (!infile) {
        std::cout
            << " Unable to open input file "
            << fileName
            << ". I'll work with an empty persistence diagram!"
            << std::endl;
        return;
    }

    // Read the generators from the file
    while (!infile.eof()) {
        // reads one line of the file
        infile >> gen.birth;

        // Just in case that files ends in a strange way
        if (infile.eof())
            break;
        infile >> gen.death;

        // Encorporate Vidits standard that the generator which lives till the end dies at -1
        if (gen.birth == -1)
            gen.birth = maxLevel;
        if (gen.death == -1)
            gen.death = maxLevel;

        // Test if generator should be included (length of life spam plus birth)
        if (NeglectShortGenerators && (gen.death - gen.birth <= NeglectSize))
            continue;
        if (NeglectLastGenerators && (gen.birth >=  NeglectBornAfter))
            continue;

        generators.push_back(gen);
    }

    // Close the file
    infile.close();

    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x280, %rsp            # imm = 0x280
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movsd %xmm0, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x258(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2a80
movq -0x10(%rbp), %rsi
leaq -0x238(%rbp), %rdi
movl $0x8, %edx
callq 0x1170
movq -0x238(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x238(%rbp,%rax), %rdi
callq 0x1080
movb %al, -0x249(%rbp)
jmp 0x1535
movb -0x249(%rbp), %al
testb $0x1, %al
jne 0x1544
jmp 0x15dc
movq 0xea8d(%rip), %rdi      # 0xffd8
leaq 0x8ae2(%rip), %rsi      # 0xa034
callq 0x10e0
movq %rax, -0x260(%rbp)
jmp 0x1560
movq -0x260(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x10e0
movq %rax, -0x268(%rbp)
jmp 0x1579
movq -0x268(%rbp), %rdi
leaq 0x8ac9(%rip), %rsi      # 0xa050
callq 0x10e0
movq %rax, -0x270(%rbp)
jmp 0x1595
movq -0x270(%rbp), %rdi
movq 0xea25(%rip), %rsi      # 0xffc8
callq 0x1110
jmp 0x15aa
movl $0x1, -0x248(%rbp)
jmp 0x1721
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x1040
jmp 0x1736
jmp 0x15de
movq -0x238(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x238(%rbp,%rax), %rdi
callq 0x1180
movb %al, -0x271(%rbp)
jmp 0x15fe
movb -0x271(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x160f
jmp 0x1709
leaq -0x238(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x10c0
jmp 0x1621
movq -0x238(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x238(%rbp,%rax), %rdi
callq 0x1180
movb %al, -0x272(%rbp)
jmp 0x1641
movb -0x272(%rbp), %al
testb $0x1, %al
jne 0x164d
jmp 0x1652
jmp 0x1709
leaq -0x28(%rbp), %rsi
leaq -0x238(%rbp), %rdi
callq 0x10c0
jmp 0x1664
movsd -0x30(%rbp), %xmm0
movsd 0x8997(%rip), %xmm1     # 0xa008
ucomisd %xmm1, %xmm0
jne 0x1683
jp 0x1683
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x28(%rbp), %xmm0
movsd 0x8978(%rip), %xmm1     # 0xa008
ucomisd %xmm1, %xmm0
jne 0x16a2
jp 0x16a2
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movq -0x258(%rbp), %rax
testb $0x1, 0x8(%rax)
je 0x16d0
movq -0x258(%rbp), %rax
movsd -0x28(%rbp), %xmm1
subsd -0x30(%rbp), %xmm1
movsd 0x10(%rax), %xmm0
ucomisd %xmm1, %xmm0
jb 0x16d0
jmp 0x15de
movq -0x258(%rbp), %rax
testb $0x1, 0x9(%rax)
je 0x16f5
movq -0x258(%rbp), %rax
movsd -0x30(%rbp), %xmm0
ucomisd 0x18(%rax), %xmm0
jb 0x16f5
jmp 0x15de
movq -0x18(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x2aa0
jmp 0x1704
jmp 0x15de
leaq -0x238(%rbp), %rdi
callq 0x1030
jmp 0x1717
movl $0x1, -0x248(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x1040
addq $0x280, %rsp            # imm = 0x280
popq %rbp
retq
movq -0x240(%rbp), %rdi
callq 0x1160
nopw %cs:(%rax,%rax)