// File: /workspace/github_cpp_makefile_star2_O1/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), %rax
cmpq %rax, 0x60(%rdi)
je 0x1753
movq %rax, 0x60(%rbx)
leaq 0x58(%rbx), %r14
movl 0x50(%rbx), %eax
cmpl %r12d, %eax
jbe 0x17c6
leaq 0x8(%rsp), %r15
movq 0x40(%rbx), %r13
subq 0x38(%rbx), %r13
shrq $0x4, %r13
addl %eax, %r13d
movl 0x50(%rbx), %eax
addl %eax, %eax
cmpl %eax, %r13d
jae 0x17bb
movl %r12d, 0x8(%rsp)
movl %r13d, 0xc(%rsp)
movq $0x0, 0x10(%rsp)
movq 0x60(%rbx), %rsi
cmpq 0x68(%rbx), %rsi
je 0x17ab
movupd 0x8(%rsp), %xmm0
movupd %xmm0, (%rsi)
addq $0x10, 0x60(%rbx)
jmp 0x17b6
movq %r14, %rdi
movq %r15, %rdx
callq 0x23e8
incl %r13d
jmp 0x1773
incl %r12d
movl 0x50(%rbx), %eax
cmpl %eax, %r12d
jb 0x1764
movq 0x20(%rbx), %r12
cmpq 0x28(%rbx), %r12
je 0x1833
xorl %ebp, %ebp
movq 0x38(%rbx), %r13
cmpq 0x40(%rbx), %r13
je 0x1827
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 0x180d
movupd 0x8(%rsp), %xmm0
movupd %xmm0, (%rsi)
addq $0x10, 0x60(%rbx)
jmp 0x181a
movq %r14, %rdi
leaq 0x8(%rsp), %rdx
callq 0x23e8
incl %r15d
addq $0x10, %r13
cmpq 0x40(%rbx), %r13
jne 0x17e0
incl %ebp
addq $0x10, %r12
cmpq 0x28(%rbx), %r12
jne 0x17d2
movq 0x20(%rbx), %r12
cmpq 0x28(%rbx), %r12
je 0x18ce
xorl %ebp, %ebp
movapd 0x27d5(%rip), %xmm1     # 0x4020
movsd 0x27bd(%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 0x18a7
movupd 0x8(%rsp), %xmm0
movupd %xmm0, (%rsi)
addq $0x10, 0x60(%rbx)
jmp 0x18c2
movq %r14, %rdi
movq %r15, %rdx
callq 0x23e8
movsd 0x2756(%rip), %xmm2     # 0x4010
movapd 0x275e(%rip), %xmm1     # 0x4020
addq $0x10, %r12
incl %ebp
cmpq 0x28(%rbx), %r12
jne 0x1858
movq 0x38(%rbx), %r12
cmpq 0x40(%rbx), %r12
je 0x196a
movl 0x50(%rbx), %ebp
movapd 0x2739(%rip), %xmm1     # 0x4020
movsd 0x2721(%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 0x1943
movupd 0x8(%rsp), %xmm0
movupd %xmm0, (%rsi)
addq $0x10, 0x60(%rbx)
jmp 0x195e
movq %r14, %rdi
movq %r15, %rdx
callq 0x23e8
movsd 0x26ba(%rip), %xmm2     # 0x4010
movapd 0x26c2(%rip), %xmm1     # 0x4020
addq $0x10, %r12
incl %ebp
cmpq 0x40(%rbx), %r12
jne 0x18f4
movq 0x58(%rbx), %r14
movq 0x60(%rbx), %rbx
cmpq %rbx, %r14
je 0x19a4
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 0x2527
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2632
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop