// File: /workspace/github_cpp_makefile_star2_O2/kelvinabrokwa[P]bottleneck/./CBottleneckDistance.cpp
// Function: CBottleneckDistance::PrepareEdges()
void CBottleneckDistance::PrepareEdges()
{
    // Set the number of generators
    Max_Size = Generators1.size() + Generators2.size();

    // Clear edges
    Edges.clear();

    //	std::cout << "Max_size = " << Max_Size                      << "\n";
    //	std::cout << "n gen 1  = " << Generators1.size()            << "\n";
    //	std::cout << "n diag 1 = " << Max_Size - Generators1.size() << "\n";
    //	std::cout << "n gen 2  = " << Generators2.size()            << "\n";
    //	std::cout << "n diag 2 = " << Max_Size -Generators2.size()  << "\n";

    // Connect all diagonal points to each other
    for (unsigned int i = Generators1.size(); i < Max_Size; i++)
        for (unsigned int j = Max_Size + Generators2.size(); j < 2 * Max_Size; j++)
            Edges.push_back(Edge(i, j, 0));

    //  int number_of_pure_diag_edges = Edges.size();
    //  std::cout << "Number of pure diag edges = " << number_of_pure_diag_edges <<"\n";

    // Edges between real points
    unsigned int i = 0;
    for (std::vector<Generator>::const_iterator cur1 = Generators1.begin(); cur1 != Generators1.end(); cur1++) {
        unsigned int j = Max_Size;
        for (std::vector<Generator>::const_iterator cur2 = Generators2.begin(); cur2 != Generators2.end(); cur2++) {
            Edges.push_back(Edge(i, j, InfDistanceOfTwoGenerators(*cur1, *cur2)));
            j++;
        }
        i++;
    }

    //	 int number_of_real_points_edges = Edges.size() - number_of_pure_diag_edges;
    //	 int sum2 = Edges.size();
    //	 std::cout << "Number of real edges = " << number_of_real_points_edges <<"\n";

    // Edges between real points and their corresponding diagonal points
    i = 0;
    for (std::vector<Generator>::const_iterator cur1 = Generators1.begin(); cur1 != Generators1.end(); ++cur1, ++i)
        Edges.push_back( Edge(i, Max_Size + Generators2.size() + i, InfDistanceOfGeneratorFromDiagonal(*cur1)));

    //	int nn = Edges.size() - sum2;
    //	std::cout << "nn = " << nn <<"\n";

    i = Max_Size;
    for (std::vector<Generator>::const_iterator cur2 = Generators2.begin(); cur2 != Generators2.end(); ++cur2, ++i)
        Edges.push_back( Edge( Generators1.size() + (i - Max_Size), i, InfDistanceOfGeneratorFromDiagonal(*cur2)));

    std::sort(Edges.begin(), Edges.end());

    //	std::cout << "N edges " << Edges.size() << "\n";
    //	for( i = 0; i < Edges.size(); ++i)
    //		std::cout
    //		    << i
    //		    << " -------- "
    //		    << Edges[i].vertex_1
    //		    << " "
    //		    << Edges[i].vertex_2
    //		    << " "
    //		    << Edges[i].weight
    //		    << std::endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x28(%rdi), %r12
movq 0x40(%rdi), %rax
subq 0x20(%rdi), %r12
sarq $0x4, %r12
subq 0x38(%rdi), %rax
shrq $0x4, %rax
addl %r12d, %eax
movl %eax, 0x50(%rdi)
movq 0x58(%rdi), %rcx
cmpq %rcx, 0x60(%rdi)
je 0x1589
movq %rcx, 0x60(%rbx)
leaq 0x58(%rbx), %r14
movq %rsp, %r15
cmpl %eax, %r12d
jae 0x15d3
movq 0x40(%rbx), %r13
subq 0x38(%rbx), %r13
shrq $0x4, %r13
addl %eax, %r13d
leal (%rax,%rax), %ecx
cmpl %ecx, %r13d
jae 0x15ce
movl %r12d, (%rsp)
movl %r13d, 0x4(%rsp)
andq $0x0, 0x8(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x206a
incl %r13d
movl 0x50(%rbx), %eax
jmp 0x15a4
incl %r12d
jmp 0x1590
movq 0x20(%rbx), %rax
xorl %ebp, %ebp
movq %rsp, %r15
cmpq 0x28(%rbx), %rax
je 0x1624
movq %rax, 0x10(%rsp)
movl 0x50(%rbx), %r13d
movq 0x38(%rbx), %r12
cmpq 0x40(%rbx), %r12
je 0x1617
movl %ebp, (%rsp)
movl %r13d, 0x4(%rsp)
andq $0x0, 0x8(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x206a
incl %r13d
addq $0x10, %r12
jmp 0x15ef
incl %ebp
movq 0x10(%rsp), %rax
addq $0x10, %rax
jmp 0x15dc
movq 0x20(%rbx), %r13
xorl %ebp, %ebp
movq %rsp, %r15
cmpq %rax, %r13
je 0x1683
movq 0x40(%rbx), %rax
subq 0x38(%rbx), %rax
shrq $0x4, %rax
addl 0x50(%rbx), %eax
addl %ebp, %eax
movsd 0x8(%r13), %xmm0
subsd (%r13), %xmm0
andpd 0x29c9(%rip), %xmm0     # 0x4020
mulsd 0x29b1(%rip), %xmm0     # 0x4010
movl %ebp, (%rsp)
movl %eax, 0x4(%rsp)
movsd %xmm0, 0x8(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x206a
addq $0x10, %r13
incl %ebp
movq 0x28(%rbx), %rax
jmp 0x162d
movl 0x50(%rbx), %ebp
movq 0x38(%rbx), %r12
movq %rsp, %r15
cmpq 0x40(%rbx), %r12
je 0x16e1
movq 0x28(%rbx), %rax
subq 0x20(%rbx), %rax
shrq $0x4, %rax
subl 0x50(%rbx), %eax
addl %ebp, %eax
movsd 0x8(%r12), %xmm0
subsd (%r12), %xmm0
andpd 0x2967(%rip), %xmm0     # 0x4020
mulsd 0x294f(%rip), %xmm0     # 0x4010
movl %eax, (%rsp)
movl %ebp, 0x4(%rsp)
movsd %xmm0, 0x8(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x206a
addq $0x10, %r12
incl %ebp
jmp 0x168d
movq 0x58(%rbx), %rdi
movq 0x60(%rbx), %rsi
callq 0x21e9
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop