// File: 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
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x128(%rbp)
addq $0x20, %rdi
callq 0x2b10
movq -0x128(%rbp), %rdi
movq %rax, -0x130(%rbp)
addq $0x38, %rdi
callq 0x2b10
movq -0x128(%rbp), %rdi
movq %rax, %rcx
movq -0x130(%rbp), %rax
addq %rcx, %rax
movl %eax, 0x50(%rdi)
addq $0x58, %rdi
callq 0x2b30
movq -0x128(%rbp), %rdi
addq $0x20, %rdi
callq 0x2b10
movl %eax, -0xc(%rbp)
movq -0x128(%rbp), %rcx
movl -0xc(%rbp), %eax
cmpl 0x50(%rcx), %eax
jae 0x191c
movq -0x128(%rbp), %rdi
movl 0x50(%rdi), %eax
movq %rax, -0x138(%rbp)
addq $0x38, %rdi
callq 0x2b10
movq %rax, %rcx
movq -0x138(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x10(%rbp)
movq -0x128(%rbp), %rcx
movl -0x10(%rbp), %eax
movl 0x50(%rcx), %ecx
shll %ecx
cmpl %ecx, %eax
jae 0x190c
movq -0x128(%rbp), %rax
addq $0x58, %rax
movq %rax, -0x140(%rbp)
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
leaq -0x20(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x2b80
movq -0x140(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x2b50
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x18ba
jmp 0x190e
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x187d
movq -0x128(%rbp), %rdi
movl $0x0, -0x24(%rbp)
addq $0x20, %rdi
callq 0x27a0
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x2bb0
movq -0x128(%rbp), %rdi
addq $0x20, %rdi
callq 0x27d0
movq %rax, -0x40(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x2bf0
testb $0x1, %al
jne 0x196e
jmp 0x1aa4
movq -0x128(%rbp), %rdi
movl 0x50(%rdi), %eax
movl %eax, -0x44(%rbp)
addq $0x38, %rdi
callq 0x27a0
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x2bb0
movq -0x128(%rbp), %rdi
addq $0x38, %rdi
callq 0x27d0
movq %rax, -0x60(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x2bf0
testb $0x1, %al
jne 0x19bf
jmp 0x1a84
movq -0x128(%rbp), %rax
addq $0x58, %rax
movq %rax, -0x148(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x150(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x14c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x2c30
movq (%rax), %rcx
movq %rcx, -0x80(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x2c30
movq -0x128(%rbp), %rdi
movq (%rax), %rcx
movq %rcx, -0x90(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x88(%rbp)
movsd -0x80(%rbp), %xmm0
movsd -0x78(%rbp), %xmm1
movsd -0x90(%rbp), %xmm2
movsd -0x88(%rbp), %xmm3
callq 0x1750
movl -0x150(%rbp), %esi
movl -0x14c(%rbp), %edx
leaq -0x70(%rbp), %rdi
callq 0x2b80
movq -0x148(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x2b50
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x2c50
movq %rax, -0x98(%rbp)
jmp 0x1995
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
callq 0x2c50
movq %rax, -0xa0(%rbp)
jmp 0x1944
movq -0x128(%rbp), %rdi
movl $0x0, -0x24(%rbp)
addq $0x20, %rdi
callq 0x27a0
movq %rax, -0xb0(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x2bb0
movq -0x128(%rbp), %rdi
addq $0x20, %rdi
callq 0x27d0
movq %rax, -0xb8(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x2bf0
testb $0x1, %al
jne 0x1b08
jmp 0x1bd4
movq -0x128(%rbp), %rdi
movq %rdi, %rax
addq $0x58, %rax
movq %rax, -0x158(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x160(%rbp)
movl 0x50(%rdi), %eax
movq %rax, -0x168(%rbp)
addq $0x38, %rdi
callq 0x2b10
movq %rax, %rcx
movq -0x168(%rbp), %rax
addq %rcx, %rax
movl -0x24(%rbp), %ecx
addq %rcx, %rax
movl %eax, -0x15c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x2c30
movq -0x128(%rbp), %rdi
movq (%rax), %rcx
movq %rcx, -0xd8(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0xd0(%rbp)
movsd -0xd8(%rbp), %xmm0
movsd -0xd0(%rbp), %xmm1
callq 0x17d0
movl -0x160(%rbp), %esi
movl -0x15c(%rbp), %edx
leaq -0xc8(%rbp), %rdi
callq 0x2b80
movq -0x158(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x2b50
leaq -0xa8(%rbp), %rdi
callq 0x2c90
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1ad5
movq -0x128(%rbp), %rdi
movl 0x50(%rdi), %eax
movl %eax, -0x24(%rbp)
addq $0x38, %rdi
callq 0x27a0
movq %rax, -0xe8(%rbp)
leaq -0xe0(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x2bb0
movq -0x128(%rbp), %rdi
addq $0x38, %rdi
callq 0x27d0
movq %rax, -0xf0(%rbp)
leaq -0xe0(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x2bf0
testb $0x1, %al
jne 0x1c37
jmp 0x1cf8
movq -0x128(%rbp), %rdi
movq %rdi, %rax
addq $0x58, %rax
movq %rax, -0x170(%rbp)
addq $0x20, %rdi
callq 0x2b10
movq -0x128(%rbp), %rdx
movl -0x24(%rbp), %ecx
subl 0x50(%rdx), %ecx
movl %ecx, %ecx
addq %rcx, %rax
movl %eax, -0x178(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x174(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x2c30
movq -0x128(%rbp), %rdi
movq (%rax), %rcx
movq %rcx, -0x110(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x108(%rbp)
movsd -0x110(%rbp), %xmm0
movsd -0x108(%rbp), %xmm1
callq 0x17d0
movl -0x178(%rbp), %esi
movl -0x174(%rbp), %edx
leaq -0x100(%rbp), %rdi
callq 0x2b80
movq -0x170(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x2b50
leaq -0xe0(%rbp), %rdi
callq 0x2c90
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1c04
movq -0x128(%rbp), %rdi
addq $0x58, %rdi
callq 0x2cf0
movq -0x128(%rbp), %rdi
movq %rax, -0x118(%rbp)
addq $0x58, %rdi
callq 0x2d20
movq %rax, -0x120(%rbp)
movq -0x118(%rbp), %rdi
movq -0x120(%rbp), %rsi
callq 0x2cb0
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
nopw %cs:(%rax,%rax)