// File: /workspace/github_cpp_makefile_star2_O3/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:
pushq %r15
pushq %r14
pushq %rbx
subq $0x40, %rsp
leaq 0x28(%rsp), %rdi
movss 0x184c(%rip), %xmm0     # 0x4028
movl $0x4e20, %esi           # imm = 0x4E20
callq 0x23a4
leaq 0x10(%rsp), %rdi
movl $0x4e20, %esi           # imm = 0x4E20
movss 0x1830(%rip), %xmm0     # 0x4028
callq 0x23a4
callq 0x2170
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x254d
movsd %xmm0, 0x8(%rsp)
callq 0x2170
movq %rax, %r14
movq 0x37af(%rip), %rdi      # 0x5fd8
leaq 0x1830(%rip), %rsi      # 0x4060
movl $0xf, %edx
callq 0x2160
movq 0x3797(%rip), %rdi      # 0x5fd8
movsd 0x8(%rsp), %xmm0
callq 0x21b0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20d0
movq 0x375b(%rip), %rdi      # 0x5fd8
leaq 0x17ec(%rip), %rsi      # 0x4070
movl $0x7, %edx
callq 0x2160
subq %rbx, %r14
xorps %xmm0, %xmm0
cvtsi2sd %r14, %xmm0
divsd 0x1777(%rip), %xmm0     # 0x4018
movq 0x3730(%rip), %rdi      # 0x5fd8
callq 0x21b0
movq %rax, %rbx
leaq 0x17c1(%rip), %rsi      # 0x4078
movl $0x8, %edx
movq %rax, %rdi
callq 0x2160
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20d0
callq 0x2170
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x25f0
movsd %xmm0, 0x8(%rsp)
callq 0x2170
movq %rax, %r14
movq 0x36c1(%rip), %rdi      # 0x5fd8
leaq 0x1763(%rip), %rsi      # 0x4081
movl $0x14, %edx
callq 0x2160
movq 0x36a9(%rip), %rdi      # 0x5fd8
movsd 0x8(%rsp), %xmm0
callq 0x21b0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20d0
movq 0x366d(%rip), %rdi      # 0x5fd8
leaq 0x16fe(%rip), %rsi      # 0x4070
movl $0x7, %edx
callq 0x2160
subq %rbx, %r14
xorps %xmm0, %xmm0
cvtsi2sd %r14, %xmm0
divsd 0x1689(%rip), %xmm0     # 0x4018
movq 0x3642(%rip), %rdi      # 0x5fd8
callq 0x21b0
movq %rax, %rbx
leaq 0x16d3(%rip), %rsi      # 0x4078
movl $0x8, %edx
movq %rax, %rdi
callq 0x2160
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20d0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x29f0
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x2a07
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
xorl %eax, %eax
addq $0x40, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
jmp 0x2a36
jmp 0x2a1c
jmp 0x2a1c
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2a36
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x2a4d
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
movq %rbx, %rdi
callq 0x21d0
nop