// File: /workspace/github_cpp_makefile_star2_O3/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 0x20(%rdi), %r12
movq 0x28(%rdi), %rax
movq %rax, %r13
subq %r12, %r13
sarq $0x4, %r13
movq 0x40(%rdi), %rcx
subq 0x38(%rdi), %rcx
shrq $0x4, %rcx
addl %r13d, %ecx
movl %ecx, 0x50(%rdi)
movq 0x58(%rdi), %rdx
cmpq %rdx, 0x60(%rdi)
je 0x1743
movq %rdx, 0x60(%rbx)
leaq 0x58(%rbx), %r14
cmpl %r13d, %ecx
jbe 0x17b9
leaq 0x8(%rsp), %r15
movq 0x40(%rbx), %r12
subq 0x38(%rbx), %r12
shrq $0x4, %r12
addl %ecx, %r12d
leal (%rcx,%rcx), %eax
cmpl %eax, %r12d
jae 0x17a9
movl %r13d, 0x8(%rsp)
movl %r12d, 0xc(%rsp)
movq $0x0, 0x10(%rsp)
movq 0x60(%rbx), %rsi
cmpq 0x68(%rbx), %rsi
je 0x1796
movupd 0x8(%rsp), %xmm0
movupd %xmm0, (%rsi)
addq $0x10, 0x60(%rbx)
jmp 0x17a1
movq %r14, %rdi
movq %r15, %rdx
callq 0x23d4
incl %r12d
movl 0x50(%rbx), %ecx
jmp 0x1760
incl %r13d
cmpl %ecx, %r13d
jb 0x1751
movq 0x20(%rbx), %r12
movq 0x28(%rbx), %rax
cmpq %rax, %r12
je 0x182e
movq 0x40(%rbx), %rcx
xorl %ebp, %ebp
movq 0x38(%rbx), %r13
cmpq %rcx, %r13
je 0x181f
movl 0x50(%rbx), %r15d
movl %ebp, 0x8(%rsp)
movl %r15d, 0xc(%rsp)
movq $0x0, 0x10(%rsp)
movq 0x60(%rbx), %rsi
cmpq 0x68(%rbx), %rsi
je 0x17fe
movupd 0x8(%rsp), %xmm0
movupd %xmm0, (%rsi)
addq $0x10, 0x60(%rbx)
jmp 0x180b
movq %r14, %rdi
leaq 0x8(%rsp), %rdx
callq 0x23d4
incl %r15d
addq $0x10, %r13
cmpq 0x40(%rbx), %r13
jne 0x17d1
movq 0x28(%rbx), %rax
movq %r13, %rcx
incl %ebp
addq $0x10, %r12
cmpq %rax, %r12
jne 0x17c4
movq 0x20(%rbx), %r12
cmpq %rax, %r12
je 0x18c4
xorl %ebp, %ebp
movapd 0x27df(%rip), %xmm1     # 0x4020
movsd 0x27c7(%rip), %xmm2     # 0x4010
leaq 0x8(%rsp), %r15
movq 0x40(%rbx), %rax
subq 0x38(%rbx), %rax
shrq $0x4, %rax
addl 0x50(%rbx), %eax
addl %ebp, %eax
movsd 0x8(%r12), %xmm0
subsd (%r12), %xmm0
andpd %xmm1, %xmm0
mulsd %xmm2, %xmm0
movl %ebp, 0x8(%rsp)
movl %eax, 0xc(%rsp)
movsd %xmm0, 0x10(%rsp)
movq 0x60(%rbx), %rsi
cmpq 0x68(%rbx), %rsi
je 0x189d
movupd 0x8(%rsp), %xmm0
movupd %xmm0, (%rsi)
addq $0x10, 0x60(%rbx)
jmp 0x18b8
movq %r14, %rdi
movq %r15, %rdx
callq 0x23d4
movsd 0x2760(%rip), %xmm2     # 0x4010
movapd 0x2768(%rip), %xmm1     # 0x4020
addq $0x10, %r12
incl %ebp
cmpq 0x28(%rbx), %r12
jne 0x184e
movq 0x38(%rbx), %r12
cmpq 0x40(%rbx), %r12
je 0x1960
movl 0x50(%rbx), %ebp
movapd 0x2743(%rip), %xmm1     # 0x4020
movsd 0x272b(%rip), %xmm2     # 0x4010
leaq 0x8(%rsp), %r15
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 %xmm1, %xmm0
mulsd %xmm2, %xmm0
movl %eax, 0x8(%rsp)
movl %ebp, 0xc(%rsp)
movsd %xmm0, 0x10(%rsp)
movq 0x60(%rbx), %rsi
cmpq 0x68(%rbx), %rsi
je 0x1939
movupd 0x8(%rsp), %xmm0
movupd %xmm0, (%rsi)
addq $0x10, 0x60(%rbx)
jmp 0x1954
movq %r14, %rdi
movq %r15, %rdx
callq 0x23d4
movsd 0x26c4(%rip), %xmm2     # 0x4010
movapd 0x26cc(%rip), %xmm1     # 0x4020
addq $0x10, %r12
incl %ebp
cmpq 0x40(%rbx), %r12
jne 0x18ea
movq 0x58(%rbx), %r14
movq 0x60(%rbx), %rbx
cmpq %rbx, %r14
je 0x199a
movq %rbx, %rax
subq %r14, %rax
sarq $0x4, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2513
movq %r14, %rdi
movq %rbx, %rsi
callq 0x261e
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop