// File: ArashPartow[P]exprtk-extras/exprtk_vector_benchmark_multithreaded.cpp
// Function: void run_expression_benchmark<double>(unsigned long const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned long const&)
void run_expression_benchmark(const std::size_t& vec_size,
                              const std::string& expression_string,
                              const std::size_t& cost)
{
   typedef exprtk::symbol_table<numeric_type> symbol_table_t;
   typedef exprtk::expression<numeric_type>   expression_t;
   typedef exprtk::parser<numeric_type>       parser_t;

   std::vector<T> v0(vec_size, T(3.1234567890));
   std::vector<T> v1(vec_size, T(5.1234567890));
   std::vector<T> v2(vec_size, T(7.1234567890));

   exprtk::rtl::vecops::package<T> vecops_package;

   symbol_table_t symbol_table;
   symbol_table.add_vector("v0",v0);
   symbol_table.add_vector("v1",v1);
   symbol_table.add_vector("v2",v2);
   symbol_table.add_package(vecops_package);

   expression_t expression;
   expression.register_symbol_table(symbol_table);

   parser_t parser;

   if (!parser.compile(expression_string,expression))
   {
      printf("[load_expression] - Parser Error: %s\tExpression: %s\n",
             parser.error().c_str(),
             expression_string.c_str());

      return;
   }

   exprtk::timer timer;

   T total = T(0);

   timer.start();

   for (std::size_t r = 0; r < rounds; ++r)
   {
      total += expression.value();
   }

   timer.stop();

   if (T(0) != total)
      printf("Total Time:%10.7f Rate:%11.3fevals/sec Perf: %5.3fGFLOPS Expression: %s\n",
             timer.time(),
             rounds / timer.time(),
             (rounds * vec_size * cost) / (1e+9 * timer.time()),
             expression_string.c_str());
   else
      printf("run_expression_benchmark() - Error running benchmark for expression: %s\n",
             expression_string.c_str());
}

// Assembly:
subq $0x1488, %rsp           # imm = 0x1488
movq %rdi, 0x1480(%rsp)
movq %rsi, 0x1478(%rsp)
movq %rdx, 0x1470(%rsp)
movq 0x1480(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x80(%rsp)
movabsq $0x4008fcd6e9b9cb1b, %rax # imm = 0x4008FCD6E9B9CB1B
movq %rax, 0x1450(%rsp)
leaq 0x144f(%rsp), %rdi
movq %rdi, 0x88(%rsp)
callq 0x11e6d0
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rcx
leaq 0x1458(%rsp), %rdi
leaq 0x1450(%rsp), %rdx
callq 0x11e6e0
jmp 0x11dee0
leaq 0x144f(%rsp), %rdi
callq 0x11e760
movq 0x1480(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x70(%rsp)
movabsq $0x40147e6b74dce58d, %rax # imm = 0x40147E6B74DCE58D
movq %rax, 0x1418(%rsp)
leaq 0x1417(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x11e6d0
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rcx
leaq 0x1420(%rsp), %rdi
leaq 0x1418(%rsp), %rdx
callq 0x11e6e0
jmp 0x11df42
leaq 0x1417(%rsp), %rdi
callq 0x11e760
movq 0x1480(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x60(%rsp)
movabsq $0x401c7e6b74dce58d, %rax # imm = 0x401C7E6B74DCE58D
movq %rax, 0x13f0(%rsp)
leaq 0x13ef(%rsp), %rdi
movq %rdi, 0x68(%rsp)
callq 0x11e6d0
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rcx
leaq 0x13f8(%rsp), %rdi
leaq 0x13f0(%rsp), %rdx
callq 0x11e6e0
jmp 0x11dfa4
leaq 0x13ef(%rsp), %rdi
callq 0x11e760
leaq 0xc08(%rsp), %rdi
callq 0x11e770
jmp 0x11dfc0
leaq 0xc00(%rsp), %rdi
movl $0x1, %esi
callq 0x11ee70
jmp 0x11dfd4
leaq 0xbdf(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x1136a0
movq 0x58(%rsp), %rdx
leaq 0x33d536(%rip), %rsi    # 0x45b528
leaq 0xbe0(%rsp), %rdi
callq 0x11c740
jmp 0x11e001
leaq 0xc00(%rsp), %rdi
leaq 0xbe0(%rsp), %rsi
leaq 0x1458(%rsp), %rdx
callq 0x11eeb0
jmp 0x11e020
leaq 0xbe0(%rsp), %rdi
callq 0x1137e8
leaq 0xbdf(%rsp), %rdi
callq 0x1137d0
leaq 0xbb7(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x1136a0
movq 0x50(%rsp), %rdx
leaq 0x33d51b(%rip), %rsi    # 0x45b573
leaq 0xbb8(%rsp), %rdi
callq 0x11c740
jmp 0x11e067
leaq 0xc00(%rsp), %rdi
leaq 0xbb8(%rsp), %rsi
leaq 0x1420(%rsp), %rdx
callq 0x11eeb0
jmp 0x11e086
leaq 0xbb8(%rsp), %rdi
callq 0x1137e8
leaq 0xbb7(%rsp), %rdi
callq 0x1137d0
leaq 0xb8f(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x1136a0
movq 0x48(%rsp), %rdx
leaq 0x33d4ef(%rip), %rsi    # 0x45b5ad
leaq 0xb90(%rsp), %rdi
callq 0x11c740
jmp 0x11e0cd
leaq 0xc00(%rsp), %rdi
leaq 0xb90(%rsp), %rsi
leaq 0x13f8(%rsp), %rdx
callq 0x11eeb0
jmp 0x11e0ec
leaq 0xb90(%rsp), %rdi
callq 0x1137e8
leaq 0xb8f(%rsp), %rdi
callq 0x1137d0
leaq 0xc00(%rsp), %rdi
leaq 0xc08(%rsp), %rsi
callq 0x11ef70
jmp 0x11e11d
leaq 0xb68(%rsp), %rdi
callq 0x11efa0
jmp 0x11e12c
leaq 0xb68(%rsp), %rdi
leaq 0xc00(%rsp), %rsi
callq 0x11f050
jmp 0x11e143
leaq 0xf0(%rsp), %rdi
movl $0x7f, %esi
callq 0x11f100
jmp 0x11e157
leaq 0x240(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x11f230
jmp 0x11e16e
leaq 0xf0(%rsp), %rdi
callq 0x11fa60
movq 0x1478(%rsp), %rsi
leaq 0x240(%rsp), %rdi
leaq 0xb68(%rsp), %rdx
callq 0x11fad0
movb %al, 0x47(%rsp)
jmp 0x11e19e
movb 0x47(%rsp), %al
testb $0x1, %al
jne 0x11e42d
jmp 0x11e1ac
leaq 0xd0(%rsp), %rdi
leaq 0x240(%rsp), %rsi
callq 0x120360
jmp 0x11e1c3
leaq 0xd0(%rsp), %rdi
callq 0x1130f0
movq %rax, 0x38(%rsp)
movq 0x1478(%rsp), %rdi
callq 0x1130f0
movq 0x38(%rsp), %rsi
movq %rax, %rdx
leaq 0x33d6a9(%rip), %rdi    # 0x45b89a
xorl %eax, %eax
callq 0x113080
jmp 0x11e1fa
leaq 0xd0(%rsp), %rdi
callq 0x1137e8
movl $0x1, 0xcc(%rsp)
jmp 0x11e5fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1440(%rsp)
movl %eax, 0x143c(%rsp)
leaq 0x144f(%rsp), %rdi
callq 0x11e760
jmp 0x11e6ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1440(%rsp)
movl %eax, 0x143c(%rsp)
leaq 0x1417(%rsp), %rdi
callq 0x11e760
jmp 0x11e6ad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1440(%rsp)
movl %eax, 0x143c(%rsp)
leaq 0x13ef(%rsp), %rdi
callq 0x11e760
jmp 0x11e6a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1440(%rsp)
movl %eax, 0x143c(%rsp)
jmp 0x11e693
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1440(%rsp)
movl %eax, 0x143c(%rsp)
jmp 0x11e686
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1440(%rsp)
movl %eax, 0x143c(%rsp)
jmp 0x11e2f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1440(%rsp)
movl %eax, 0x143c(%rsp)
leaq 0xbe0(%rsp), %rdi
callq 0x1137e8
leaq 0xbdf(%rsp), %rdi
callq 0x1137d0
jmp 0x11e679
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1440(%rsp)
movl %eax, 0x143c(%rsp)
jmp 0x11e33b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1440(%rsp)
movl %eax, 0x143c(%rsp)
leaq 0xbb8(%rsp), %rdi
callq 0x1137e8
leaq 0xbb7(%rsp), %rdi
callq 0x1137d0
jmp 0x11e679
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1440(%rsp)
movl %eax, 0x143c(%rsp)
jmp 0x11e384
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1440(%rsp)
movl %eax, 0x143c(%rsp)
leaq 0xb90(%rsp), %rdi
callq 0x1137e8
leaq 0xb8f(%rsp), %rdi
callq 0x1137d0
jmp 0x11e679
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1440(%rsp)
movl %eax, 0x143c(%rsp)
jmp 0x11e679
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1440(%rsp)
movl %eax, 0x143c(%rsp)
jmp 0x11e66c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1440(%rsp)
movl %eax, 0x143c(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x11fa60
jmp 0x11e66c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1440(%rsp)
movl %eax, 0x143c(%rsp)
jmp 0x11e65f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1440(%rsp)
movl %eax, 0x143c(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0x1137e8
jmp 0x11e65f
leaq 0xa0(%rsp), %rdi
callq 0x11cd90
jmp 0x11e43c
xorps %xmm0, %xmm0
movsd %xmm0, 0x98(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x11cdc0
movq $0x0, 0x90(%rsp)
cmpq $0x7d0, 0x90(%rsp) # imm = 0x7D0
jae 0x11e4b2
leaq 0xb68(%rsp), %rdi
callq 0x120420
movsd %xmm0, 0x30(%rsp)
jmp 0x11e484
movsd 0x30(%rsp), %xmm0
addsd 0x98(%rsp), %xmm0
movsd %xmm0, 0x98(%rsp)
movq 0x90(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x90(%rsp)
jmp 0x11e461
leaq 0xa0(%rsp), %rdi
callq 0x11d010
jmp 0x11e4c1
xorps %xmm0, %xmm0
ucomisd 0x98(%rsp), %xmm0
jne 0x11e4d6
jp 0x11e4d6
jmp 0x11e5cf
leaq 0xa0(%rsp), %rdi
callq 0x11d040
movsd %xmm0, 0x28(%rsp)
jmp 0x11e4eb
leaq 0xa0(%rsp), %rdi
callq 0x11d040
movsd %xmm0, 0x20(%rsp)
jmp 0x11e500
movsd 0x20(%rsp), %xmm1
movsd 0x337b42(%rip), %xmm0   # 0x456050
divsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x1480(%rsp), %rax
movq (%rax), %rax
movq 0x1470(%rsp), %rcx
movq (%rcx), %rcx
imulq %rcx, %rax
imulq $0x7d0, %rax, %rax      # imm = 0x7D0
movq %rax, %xmm0
movaps 0x337acb(%rip), %xmm1   # 0x456010
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x337acf(%rip), %xmm1   # 0x456020
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x11d040
movsd %xmm0, 0x18(%rsp)
jmp 0x11e57b
movsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x337ab1(%rip), %xmm2   # 0x456040
mulsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, (%rsp)
movq 0x1478(%rsp), %rdi
callq 0x1130f0
movsd 0x28(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
movsd (%rsp), %xmm2
movq %rax, %rsi
leaq 0x33d30b(%rip), %rdi    # 0x45b8cf
movb $0x3, %al
callq 0x113080
jmp 0x11e5cd
jmp 0x11e5f1
movq 0x1478(%rsp), %rdi
callq 0x1130f0
movq %rax, %rsi
leaq 0x33d332(%rip), %rdi    # 0x45b918
xorl %eax, %eax
callq 0x113080
jmp 0x11e5ef
jmp 0x11e5f1
movl $0x0, 0xcc(%rsp)
leaq 0x240(%rsp), %rdi
callq 0x120440
leaq 0xb68(%rsp), %rdi
callq 0x120640
leaq 0xc00(%rsp), %rdi
callq 0x120680
leaq 0xc08(%rsp), %rdi
callq 0x120700
leaq 0x13f8(%rsp), %rdi
callq 0x1208f0
leaq 0x1420(%rsp), %rdi
callq 0x1208f0
leaq 0x1458(%rsp), %rdi
callq 0x1208f0
addq $0x1488, %rsp           # imm = 0x1488
retq
leaq 0x240(%rsp), %rdi
callq 0x120440
leaq 0xb68(%rsp), %rdi
callq 0x120640
leaq 0xc00(%rsp), %rdi
callq 0x120680
leaq 0xc08(%rsp), %rdi
callq 0x120700
leaq 0x13f8(%rsp), %rdi
callq 0x1208f0
leaq 0x1420(%rsp), %rdi
callq 0x1208f0
leaq 0x1458(%rsp), %rdi
callq 0x1208f0
movq 0x1440(%rsp), %rdi
callq 0x113490
nopw (%rax,%rax)