// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x12d8, %rsp           # imm = 0x12D8
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
movq (%rdi), %rsi
movabsq $0x4008fcd6e9b9cb1b, %rax # imm = 0x4008FCD6E9B9CB1B
leaq 0x1d0(%rsp), %r12
movq %rax, (%r12)
leaq 0x68(%rsp), %rdi
leaq 0xaf8(%rsp), %rcx
movq %r12, %rdx
callq 0x11403e
movq (%r15), %rsi
movabsq $0x40147e6b74dce58d, %rax # imm = 0x40147E6B74DCE58D
movq %rax, (%r12)
leaq 0x50(%rsp), %rdi
leaq 0x1d0(%rsp), %rdx
leaq 0xaf8(%rsp), %rcx
callq 0x11403e
movq (%r15), %rsi
movabsq $0x401c7e6b74dce58d, %rax # imm = 0x401C7E6B74DCE58D
leaq 0x1d0(%rsp), %rdx
movq %rax, (%rdx)
leaq 0x38(%rsp), %rdi
leaq 0xaf8(%rsp), %rcx
callq 0x11403e
leaq 0xaf8(%rsp), %rdi
callq 0x114094
movq %rsp, %rdi
pushq $0x1
popq %rsi
callq 0x1144ba
leaq 0x12f431(%rip), %rsi    # 0x2430e8
leaq 0x1d0(%rsp), %rdi
leaq 0x80(%rsp), %rdx
callq 0x113686
movq %rsp, %rdi
leaq 0x1d0(%rsp), %rsi
leaq 0x68(%rsp), %rdx
callq 0x1144de
leaq 0x1d0(%rsp), %rdi
callq 0x110608
leaq 0x12f43e(%rip), %rsi    # 0x243133
leaq 0x1d0(%rsp), %rdi
leaq 0x80(%rsp), %rdx
callq 0x113686
movq %rsp, %rdi
leaq 0x1d0(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x1144de
leaq 0x1d0(%rsp), %rdi
callq 0x110608
leaq 0x12f43a(%rip), %rsi    # 0x24316d
leaq 0x1d0(%rsp), %rdi
leaq 0x80(%rsp), %rdx
callq 0x113686
movq %rsp, %rdi
leaq 0x1d0(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x1144de
leaq 0x1d0(%rsp), %rdi
callq 0x110608
leaq 0xaf8(%rsp), %rdi
movq %rsp, %rsi
callq 0x11a4a8
leaq 0x18(%rsp), %rdi
callq 0x114548
leaq 0x18(%rsp), %rdi
movq %rsp, %rsi
callq 0x1145a8
leaq 0x80(%rsp), %rdi
pushq $0x7f
popq %rsi
callq 0x114604
leaq 0x1d0(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x114714
leaq 0x80(%rsp), %rdi
callq 0x114d2c
leaq 0x1d0(%rsp), %rdi
leaq 0x18(%rsp), %rdx
movq %rbx, %rsi
callq 0x114d74
testb %al, %al
je 0x113e2f
leaq 0x80(%rsp), %rdi
movb $0x0, (%rdi)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rdi)
movupd %xmm0, 0x18(%rdi)
callq 0x1138d2
xorpd %xmm0, %xmm0
movl $0x7d0, %r12d           # imm = 0x7D0
movsd %xmm0, 0x8(%rsp)
subq $0x1, %r12
jb 0x113e6d
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
movapd %xmm1, %xmm0
jmp 0x113e04
leaq 0x80(%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
callq 0x1151f6
leaq 0x80(%rsp), %r14
movq (%r14), %rsi
movq (%rbx), %rdx
leaq 0x12f601(%rip), %rdi    # 0x24345a
xorl %eax, %eax
callq 0x110060
movq %r14, %rdi
callq 0x110608
jmp 0x113f39
leaq 0x80(%rsp), %rdi
callq 0x113994
xorpd %xmm0, %xmm0
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jne 0x113e90
jnp 0x113f28
leaq 0x80(%rsp), %rdi
callq 0x1139a8
movsd %xmm0, 0x8(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x1139a8
movsd %xmm0, 0x10(%rsp)
movq (%r15), %r15
movq (%r14), %r14
leaq 0x80(%rsp), %rdi
callq 0x1139a8
imulq %r14, %r15
imulq $0x7d0, %r15, %rax      # imm = 0x7D0
movq %rax, %xmm1
punpckldq 0x12a12f(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x12a137(%rip), %xmm1   # 0x23e020
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
movsd 0x12a183(%rip), %xmm1   # 0x23e080
divsd 0x10(%rsp), %xmm1
mulsd 0x12a165(%rip), %xmm0   # 0x23e070
divsd %xmm0, %xmm2
movq (%rbx), %rsi
leaq 0x12f576(%rip), %rdi    # 0x24348f
movsd 0x8(%rsp), %xmm0
movb $0x3, %al
callq 0x110060
jmp 0x113f39
movq (%rbx), %rsi
leaq 0x12f5a6(%rip), %rdi    # 0x2434d8
xorl %eax, %eax
callq 0x110060
leaq 0x1d0(%rsp), %rdi
callq 0x11524a
leaq 0x18(%rsp), %rdi
callq 0x115384
movq %rsp, %rdi
callq 0x11539a
leaq 0xaf8(%rsp), %rdi
callq 0x1153dc
leaq 0x38(%rsp), %rdi
callq 0x115556
leaq 0x50(%rsp), %rdi
callq 0x115556
leaq 0x68(%rsp), %rdi
callq 0x115556
addq $0x12d8, %rsp           # imm = 0x12D8
popq %rbx
popq %r12
popq %r14
popq %r15
retq
jmp 0x113fe8
jmp 0x113fe8
jmp 0x113fe8
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x114d2c
jmp 0x113ff8
jmp 0x113fac
movq %rax, %rbx
jmp 0x113ff8
jmp 0x113fcf
jmp 0x113fcf
jmp 0x113fbd
jmp 0x113fcf
jmp 0x113fbd
jmp 0x113fcf
movq %rax, %rbx
leaq 0x1d0(%rsp), %rdi
callq 0x110608
jmp 0x114002
movq %rax, %rbx
jmp 0x114002
movq %rax, %rbx
jmp 0x11400a
movq %rax, %rbx
jmp 0x114017
movq %rax, %rbx
jmp 0x114021
movq %rax, %rbx
jmp 0x11402b
movq %rax, %rbx
leaq 0x1d0(%rsp), %rdi
callq 0x11524a
leaq 0x18(%rsp), %rdi
callq 0x115384
movq %rsp, %rdi
callq 0x11539a
leaq 0xaf8(%rsp), %rdi
callq 0x1153dc
leaq 0x38(%rsp), %rdi
callq 0x115556
leaq 0x50(%rsp), %rdi
callq 0x115556
leaq 0x68(%rsp), %rdi
callq 0x115556
movq %rbx, %rdi
callq 0x110350
nop