// File: willprice[P]parallel-cpp-workshop/energy.cpp
// Function: main
int main(int argc, char **argv)
{
    auto group_a = create_random_points(20000);
    auto group_b = create_random_points(20000);

    auto t0 = tbb::tick_count::now();
    auto energy = calculate_energy(group_a, group_b);
    auto t1 = tbb::tick_count::now();

    std::cout << "Total energy = " << energy << std::endl;
    std::cout << "Took = " << (t1-t0).seconds() << " seconds" << std::endl;

    t0 = tbb::tick_count::now();
    energy = mapreduce_energy(group_a, group_b);
    t1 = tbb::tick_count::now();

    std::cout << "Map/Reduce energy = " << energy << std::endl;
    std::cout << "Took = " << (t1-t0).seconds() << " seconds" << std::endl;

    return 0;    
}

// Assembly:
subq $0x138, %rsp            # imm = 0x138
movl $0x0, 0x134(%rsp)
movl %edi, 0x130(%rsp)
movq %rsi, 0x128(%rsp)
leaq 0x110(%rsp), %rdi
movl $0x4e20, %esi           # imm = 0x4E20
movl %esi, 0xa8(%rsp)
movss 0x473b(%rip), %xmm0     # 0x7028
movss %xmm0, 0xac(%rsp)
callq 0x2440
movl 0xa8(%rsp), %esi
movss 0xac(%rsp), %xmm0
leaq 0xf8(%rsp), %rdi
callq 0x2440
jmp 0x291a
callq 0x4620
movq %rax, 0xa0(%rsp)
jmp 0x2929
movq 0xa0(%rsp), %rax
movq %rax, 0xe0(%rsp)
leaq 0x110(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0x26a0
movsd %xmm0, 0x98(%rsp)
jmp 0x2959
movsd 0x98(%rsp), %xmm0
movsd %xmm0, 0xd8(%rsp)
callq 0x4620
movq %rax, 0x90(%rsp)
jmp 0x297a
movq 0x90(%rsp), %rax
movq %rax, 0xd0(%rsp)
movq 0x8647(%rip), %rdi      # 0xafd8
leaq 0x46d8(%rip), %rsi      # 0x7070
callq 0x20f0
movq %rax, 0x88(%rsp)
jmp 0x29a7
movq 0x88(%rsp), %rdi
movsd 0xd8(%rsp), %xmm0
callq 0x2210
movq %rax, 0x80(%rsp)
jmp 0x29c7
movq 0x80(%rsp), %rdi
movq 0x85f2(%rip), %rsi      # 0xafc8
callq 0x2130
jmp 0x29dd
movq 0x85f4(%rip), %rdi      # 0xafd8
leaq 0x4695(%rip), %rsi      # 0x7080
callq 0x20f0
movq %rax, 0x78(%rsp)
jmp 0x29f7
leaq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x4650
movq %rax, 0x70(%rsp)
jmp 0x2a13
movq 0x70(%rsp), %rax
movq %rax, 0xc8(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x4690
movsd %xmm0, 0x68(%rsp)
jmp 0x2a35
movsd 0x68(%rsp), %xmm0
movq 0x78(%rsp), %rdi
callq 0x2210
movq %rax, 0x60(%rsp)
jmp 0x2a4c
movq 0x60(%rsp), %rdi
leaq 0x4630(%rip), %rsi      # 0x7088
callq 0x20f0
movq %rax, 0x58(%rsp)
jmp 0x2a64
movq 0x58(%rsp), %rdi
movq 0x8558(%rip), %rsi      # 0xafc8
callq 0x2130
jmp 0x2a77
callq 0x4620
movq %rax, 0x50(%rsp)
jmp 0x2a83
movq 0x50(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq 0xc0(%rsp), %rax
movq %rax, 0xe0(%rsp)
leaq 0x110(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0x27a0
movsd %xmm0, 0x48(%rsp)
jmp 0x2abd
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0xd8(%rsp)
callq 0x4620
movq %rax, 0x40(%rsp)
jmp 0x2ad8
movq 0x40(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0xd0(%rsp)
movq 0x84dc(%rip), %rdi      # 0xafd8
leaq 0x458e(%rip), %rsi      # 0x7091
callq 0x20f0
movq %rax, 0x38(%rsp)
jmp 0x2b0f
movq 0x38(%rsp), %rdi
movsd 0xd8(%rsp), %xmm0
callq 0x2210
movq %rax, 0x30(%rsp)
jmp 0x2b29
movq 0x30(%rsp), %rdi
movq 0x8493(%rip), %rsi      # 0xafc8
callq 0x2130
jmp 0x2b3c
movq 0x8495(%rip), %rdi      # 0xafd8
leaq 0x4536(%rip), %rsi      # 0x7080
callq 0x20f0
movq %rax, 0x28(%rsp)
jmp 0x2b56
leaq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x4650
movq %rax, 0x20(%rsp)
jmp 0x2b72
movq 0x20(%rsp), %rax
movq %rax, 0xb0(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x4690
movsd %xmm0, 0x18(%rsp)
jmp 0x2b94
movsd 0x18(%rsp), %xmm0
movq 0x28(%rsp), %rdi
callq 0x2210
movq %rax, 0x10(%rsp)
jmp 0x2bab
movq 0x10(%rsp), %rdi
leaq 0x44d1(%rip), %rsi      # 0x7088
callq 0x20f0
movq %rax, 0x8(%rsp)
jmp 0x2bc3
movq 0x8(%rsp), %rdi
movq 0x83f9(%rip), %rsi      # 0xafc8
callq 0x2130
jmp 0x2bd6
movl $0x0, 0x134(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x43f0
leaq 0x110(%rsp), %rdi
callq 0x43f0
movl 0x134(%rsp), %eax
addq $0x138, %rsp            # imm = 0x138
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
jmp 0x2c41
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x43f0
leaq 0x110(%rsp), %rdi
callq 0x43f0
movq 0xf0(%rsp), %rdi
callq 0x21c0
nopl (%rax,%rax)