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

   std::vector<T> v0(vec_size, T(2.1234567890));
   std::vector<T> v1(vec_size, T(3.1234567890));
   std::vector<T> v2(vec_size, T(5.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(expr_string,expression))
   {
      printf("[load_expression] - Parser Error: %s\tExpression: %s\n",
             parser.error().c_str(),
             expr_string.c_str());

      return std::numeric_limits<T>::quiet_NaN();
   }

   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()),
             expr_string.c_str());
   else
      printf("run_expression_benchmark() - Error running benchmark for expression: %s\n",
             expr_string.c_str());

   return timer.time();
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x12d8, %rsp           # imm = 0x12D8
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movabsq $0x4000fcd6e9b9cb1b, %rax # imm = 0x4000FCD6E9B9CB1B
leaq 0x1d0(%rsp), %r12
movq %rax, (%r12)
leaq 0x68(%rsp), %rdi
leaq 0xaf8(%rsp), %rcx
movq %r14, %rsi
movq %r12, %rdx
callq 0x113e1e
movabsq $0x4008fcd6e9b9cb1b, %rax # imm = 0x4008FCD6E9B9CB1B
movq %rax, (%r12)
leaq 0x50(%rsp), %rdi
leaq 0x1d0(%rsp), %rdx
leaq 0xaf8(%rsp), %rcx
movq %r14, %rsi
callq 0x113e1e
movabsq $0x40147e6b74dce58d, %rax # imm = 0x40147E6B74DCE58D
leaq 0x1d0(%rsp), %rdx
movq %rax, (%rdx)
leaq 0x38(%rsp), %rdi
leaq 0xaf8(%rsp), %rcx
movq %r14, %rsi
callq 0x113e1e
leaq 0xaf8(%rsp), %rdi
callq 0x113e74
leaq 0x8(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x11429a
leaq 0x12f676(%rip), %rsi    # 0x2430e8
leaq 0x1d0(%rsp), %rdi
leaq 0x80(%rsp), %rdx
callq 0x1136b6
leaq 0x8(%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
leaq 0x68(%rsp), %rdx
callq 0x1142be
leaq 0x1d0(%rsp), %rdi
callq 0x110608
leaq 0x12f681(%rip), %rsi    # 0x243133
leaq 0x1d0(%rsp), %rdi
leaq 0x80(%rsp), %rdx
callq 0x1136b6
leaq 0x8(%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x1142be
leaq 0x1d0(%rsp), %rdi
callq 0x110608
leaq 0x12f67b(%rip), %rsi    # 0x24316d
leaq 0x1d0(%rsp), %rdi
leaq 0x80(%rsp), %rdx
callq 0x1136b6
leaq 0x8(%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x1142be
leaq 0x1d0(%rsp), %rdi
callq 0x110608
leaq 0xaf8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x11a2dc
leaq 0x18(%rsp), %rdi
callq 0x114328
leaq 0x18(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x114388
leaq 0x80(%rsp), %rdi
pushq $0x7f
popq %rsi
callq 0x1143e4
leaq 0x1d0(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x1144f4
leaq 0x80(%rsp), %rdi
callq 0x114b0c
leaq 0x1d0(%rsp), %rdi
leaq 0x18(%rsp), %rdx
movq %rbx, %rsi
callq 0x114b54
testb %al, %al
je 0x113bf2
leaq 0x80(%rsp), %rdi
movb $0x0, (%rdi)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rdi)
movupd %xmm0, 0x18(%rdi)
callq 0x11502a
xorpd %xmm0, %xmm0
movl $0x7d0, %r12d           # imm = 0x7D0
movsd %xmm0, (%rsp)
subq $0x1, %r12
jb 0x113c38
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
movapd %xmm1, %xmm0
jmp 0x113bc9
leaq 0x80(%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
callq 0x114fd6
leaq 0x80(%rsp), %r14
movq (%r14), %rsi
movq (%rbx), %rdx
leaq 0x12f824(%rip), %rdi    # 0x243440
xorl %eax, %eax
callq 0x110080
movq %r14, %rdi
callq 0x110608
movsd 0x12a445(%rip), %xmm0   # 0x23e078
jmp 0x113d0b
leaq 0x80(%rsp), %rdi
callq 0x115038
xorpd %xmm0, %xmm0
movsd (%rsp), %xmm1
ucomisd %xmm0, %xmm1
jne 0x113c5a
jnp 0x113ced
leaq 0x80(%rsp), %rdi
callq 0x11504c
movsd %xmm0, (%rsp)
leaq 0x80(%rsp), %rdi
callq 0x11504c
movsd %xmm0, 0x10(%rsp)
movq (%r15), %r15
leaq 0x80(%rsp), %rdi
callq 0x11504c
imulq %r15, %r14
imulq $0x7d0, %r14, %rax      # imm = 0x7D0
movq %rax, %xmm1
punpckldq 0x12a369(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x12a371(%rip), %xmm1   # 0x23e020
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
movsd 0x12a3bd(%rip), %xmm1   # 0x23e080
divsd 0x10(%rsp), %xmm1
mulsd 0x12a39f(%rip), %xmm0   # 0x23e070
divsd %xmm0, %xmm2
movq (%rbx), %rsi
leaq 0x12f796(%rip), %rdi    # 0x243475
movsd (%rsp), %xmm0
movb $0x3, %al
callq 0x110080
jmp 0x113cfe
movq (%rbx), %rsi
leaq 0x12f7c7(%rip), %rdi    # 0x2434be
xorl %eax, %eax
callq 0x110080
leaq 0x80(%rsp), %rdi
callq 0x11504c
movsd %xmm0, (%rsp)
leaq 0x1d0(%rsp), %rdi
callq 0x11507e
leaq 0x18(%rsp), %rdi
callq 0x1151b8
leaq 0x8(%rsp), %rdi
callq 0x1151ce
leaq 0xaf8(%rsp), %rdi
callq 0x115210
leaq 0x38(%rsp), %rdi
callq 0x11538a
leaq 0x50(%rsp), %rdi
callq 0x11538a
leaq 0x68(%rsp), %rdi
callq 0x11538a
movsd (%rsp), %xmm0
addq $0x12d8, %rsp           # imm = 0x12D8
popq %rbx
popq %r12
popq %r14
popq %r15
retq
jmp 0x113dc6
jmp 0x113dc6
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x114b0c
jmp 0x113dd6
jmp 0x113d88
movq %rax, %rbx
jmp 0x113dd6
jmp 0x113dab
jmp 0x113dab
jmp 0x113d99
jmp 0x113dab
jmp 0x113d99
jmp 0x113dab
movq %rax, %rbx
leaq 0x1d0(%rsp), %rdi
callq 0x110608
jmp 0x113de0
movq %rax, %rbx
jmp 0x113de0
movq %rax, %rbx
jmp 0x113dea
movq %rax, %rbx
jmp 0x113df7
movq %rax, %rbx
jmp 0x113e01
movq %rax, %rbx
jmp 0x113e0b
jmp 0x113dc6
movq %rax, %rbx
leaq 0x1d0(%rsp), %rdi
callq 0x11507e
leaq 0x18(%rsp), %rdi
callq 0x1151b8
leaq 0x8(%rsp), %rdi
callq 0x1151ce
leaq 0xaf8(%rsp), %rdi
callq 0x115210
leaq 0x38(%rsp), %rdi
callq 0x11538a
leaq 0x50(%rsp), %rdi
callq 0x11538a
leaq 0x68(%rsp), %rdi
callq 0x11538a
movq %rbx, %rdi
callq 0x110360
nop