// File: /workspace/github_cpp_makefile_star2_O1/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 0x17d7(%rip), %xmm0     # 0x4028
movl $0x4e20, %esi           # imm = 0x4E20
callq 0x23bd
leaq 0x10(%rsp), %rdi
movl $0x4e20, %esi           # imm = 0x4E20
movss 0x17bb(%rip), %xmm0     # 0x4028
callq 0x23bd
callq 0x2170
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x2574
movsd %xmm0, 0x8(%rsp)
callq 0x2170
movq %rax, %r14
movq 0x373a(%rip), %rdi      # 0x5fd8
leaq 0x17bb(%rip), %rsi      # 0x4060
movl $0xf, %edx
callq 0x2160
movq 0x3722(%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 0x36e6(%rip), %rdi      # 0x5fd8
leaq 0x1777(%rip), %rsi      # 0x4070
movl $0x7, %edx
callq 0x2160
subq %rbx, %r14
xorps %xmm0, %xmm0
cvtsi2sd %r14, %xmm0
divsd 0x1702(%rip), %xmm0     # 0x4018
movq 0x36bb(%rip), %rdi      # 0x5fd8
callq 0x21b0
movq %rax, %rbx
leaq 0x174c(%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 0x2665
movsd %xmm0, 0x8(%rsp)
callq 0x2170
movq %rax, %r14
movq 0x364c(%rip), %rdi      # 0x5fd8
leaq 0x16ee(%rip), %rsi      # 0x4081
movl $0x14, %edx
callq 0x2160
movq 0x3634(%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 0x35f8(%rip), %rdi      # 0x5fd8
leaq 0x1689(%rip), %rsi      # 0x4070
movl $0x7, %edx
callq 0x2160
subq %rbx, %r14
xorps %xmm0, %xmm0
cvtsi2sd %r14, %xmm0
divsd 0x1614(%rip), %xmm0     # 0x4018
movq 0x35cd(%rip), %rdi      # 0x5fd8
callq 0x21b0
movq %rax, %rbx
leaq 0x165e(%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 0x2a65
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x2a7c
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 0x2aab
jmp 0x2a91
jmp 0x2a91
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2aab
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x2ac2
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
movq %rbx, %rdi
callq 0x21d0