// File: /workspace/github_cpp_makefile_star2_O2/ArashPartow[P]exprtk-extras/exprtk_funcall_benchmark.cpp
// Function: void function_call_benchmark01<double>()
void function_call_benchmark01()
{
   typedef exprtk::symbol_table<T>         symbol_table_t;
   typedef exprtk::expression<T>           expression_t;
   typedef exprtk::parser<T>               parser_t;
   typedef exprtk::function_compositor<T>  compositor_t;
   typedef typename compositor_t::function function_t;

   T v1 = T(1);
   T v2 = T(2);

   func0<T> f0;

   symbol_table_t symbol_table;

   symbol_table.add_constants();

   symbol_table.add_variable("v1"   , v1           );
   symbol_table.add_variable("v2"   , v2           );
   symbol_table.add_function("func0", f0           );
   symbol_table.add_function("func1", func1<double>);

   compositor_t compositor(symbol_table);

   compositor.add(
      function_t("func2")
      .var("v1").var("v2")
      .expression(" 1 + cos(v1 * v2) / 3;"));

   const std::string program0 = "func0(v1,v2);";
   const std::string program1 = "func1(v1,v2);";
   const std::string program2 = "func2(v1,v2);";

   expression_t expression0(symbol_table);
   expression_t expression1(symbol_table);
   expression_t expression2(symbol_table);

   parser_t parser;

   if (!parser.compile(program0,expression0))
   {
      printf("Error: %s\tExpression: %s\n",
             parser.error().c_str(),
             program0.c_str());

      return;
   }

   if (!parser.compile(program1,expression1))
   {
      printf("Error: %s\tExpression: %s\n",
             parser.error().c_str(),
             program1.c_str());

      return;
   }

   if (!parser.compile(program2,expression2))
   {
      printf("Error: %s\tExpression: %s\n",
             parser.error().c_str(),
             program1.c_str());

      return;
   }

   const std::size_t rounds = 100000000;

   {
      T total = T(0);

      exprtk::timer timer;
      timer.start();

      for (std::size_t r = 0; r < rounds; ++r)
      {
         total += expression0.value();
         std::swap(v1,v2);
      }

      timer.stop();

      printf("[custom function]  Total time: %8.3fsec\tRate: %15.3f\tTotal:%20.5f\n",
             timer.time(),
             rounds / timer.time(),
             total);
   }

   {
      T total = T(0);

      exprtk::timer timer;
      timer.start();

      for (std::size_t r = 0; r < rounds; ++r)
      {
         total += expression1.value();
         std::swap(v1,v2);
      }

      timer.stop();

      printf("[free function  ]  Total time: %8.3fsec\tRate: %15.3f\tTotal:%20.5f\n",
             timer.time(),
             rounds / timer.time(),
             total);
   }

   {
      T total = T(0);

      exprtk::timer timer;
      timer.start();

      for (std::size_t r = 0; r < rounds; ++r)
      {
         total += expression2.value();
         std::swap(v1,v2);
      }

      timer.stop();

      printf("[compositor     ]  Total time: %8.3fsec\tRate: %15.3f\tTotal:%20.5f\n",
             timer.time(),
             rounds / timer.time(),
             total);
   }

   {
      T total = T(0);

      exprtk::timer timer;
      timer.start();

      for (std::size_t r = 0; r < rounds; ++r)
      {
         total += func1<T>(v1,v2);
         std::swap(v1,v2);
      }

      timer.stop();

      printf("[native         ]  Total time: %8.3fsec\tRate: %15.3f\tTotal:%20.5f\n",
             timer.time(),
             rounds / timer.time(),
             total);
   }
}

// Assembly:
pushq %rbx
subq $0x1580, %rsp           # imm = 0x1580
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x20(%rsp)
movw $0x100, 0x100(%rsp)     # imm = 0x100
andq $0x0, 0x108(%rsp)
movabsq $0x4000000000000000, %rax # imm = 0x4000000000000000
orq $-0x1, 0x110(%rsp)
movq %rax, 0x18(%rsp)
movq $0x2, 0x118(%rsp)
leaq 0x25b338(%rip), %rax    # 0x36e6a0
movq %rax, 0xf8(%rsp)
leaq 0x10(%rsp), %rbx
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x113cc6
movq %rbx, %rdi
callq 0x113cea
leaq 0x131d9e(%rip), %rsi    # 0x24512d
leaq 0xb98(%rsp), %rdi
leaq 0x270(%rsp), %rdx
callq 0x1132d8
leaq 0x10(%rsp), %rdi
leaq 0xb98(%rsp), %rsi
leaq 0x20(%rsp), %rdx
xorl %ecx, %ecx
callq 0x113d10
leaq 0xb98(%rsp), %rdi
callq 0x1115d8
leaq 0x131d5f(%rip), %rsi    # 0x245130
leaq 0xb98(%rsp), %rdi
leaq 0x270(%rsp), %rdx
callq 0x1132d8
leaq 0x10(%rsp), %rdi
leaq 0xb98(%rsp), %rsi
leaq 0x18(%rsp), %rdx
xorl %ecx, %ecx
callq 0x113d10
leaq 0xb98(%rsp), %rdi
callq 0x1115d8
leaq 0x131d20(%rip), %rsi    # 0x245133
leaq 0xb98(%rsp), %rdi
leaq 0x270(%rsp), %rdx
callq 0x1132d8
leaq 0x10(%rsp), %rdi
leaq 0xb98(%rsp), %rsi
leaq 0xf8(%rsp), %rdx
callq 0x113d7c
leaq 0xb98(%rsp), %rdi
callq 0x1115d8
leaq 0x131ce3(%rip), %rsi    # 0x245139
leaq 0xb98(%rsp), %rdi
leaq 0x270(%rsp), %rdx
callq 0x1132d8
leaq 0xa1e(%rip), %rdx       # 0x113e90
leaq 0x10(%rsp), %rdi
leaq 0xb98(%rsp), %rsi
callq 0x113ddc
leaq 0xb98(%rsp), %rdi
callq 0x1115d8
leaq 0xb98(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x113eac
leaq 0x131c95(%rip), %rsi    # 0x24513f
leaq 0x120(%rsp), %rdi
leaq 0xd8(%rsp), %rdx
callq 0x1132d8
leaq 0x270(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x113fca
leaq 0x131c52(%rip), %rsi    # 0x24512d
leaq 0x58(%rsp), %rdi
leaq 0xb8(%rsp), %rdx
callq 0x1132d8
leaq 0x2b0(%rsp), %rbx
leaq 0x58(%rsp), %rsi
movq %rbx, %rdi
callq 0x11ef54
leaq 0x131c27(%rip), %rsi    # 0x245130
leaq 0x38(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0x1132d8
leaq 0x38(%rsp), %rsi
movq %rbx, %rdi
callq 0x11ef54
leaq 0x131c16(%rip), %rsi    # 0x245145
leaq 0x78(%rsp), %rdi
leaq 0x37(%rsp), %rdx
callq 0x1132d8
leaq 0x290(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x111560
leaq 0xb98(%rsp), %rdi
leaq 0x270(%rsp), %rsi
xorl %edx, %edx
callq 0x113fba
leaq 0x78(%rsp), %rdi
callq 0x1115d8
leaq 0x38(%rsp), %rdi
callq 0x1115d8
leaq 0x58(%rsp), %rdi
callq 0x1115d8
leaq 0x270(%rsp), %rdi
callq 0x114016
leaq 0x120(%rsp), %rdi
callq 0x1115d8
leaq 0x131bb6(%rip), %rsi    # 0x24515c
leaq 0x58(%rsp), %rdi
leaq 0x270(%rsp), %rdx
callq 0x1132d8
leaq 0x131bab(%rip), %rsi    # 0x24516a
leaq 0x38(%rsp), %rdi
leaq 0x270(%rsp), %rdx
callq 0x1132d8
leaq 0x131ba0(%rip), %rsi    # 0x245178
leaq 0x78(%rsp), %rdi
leaq 0x270(%rsp), %rdx
callq 0x1132d8
leaq 0xd8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x114036
leaq 0xb8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x114036
leaq 0x98(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x114036
leaq 0x120(%rsp), %rdi
pushq $0x7f
popq %rsi
callq 0x1140a2
leaq 0x270(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x1141b2
leaq 0x120(%rsp), %rdi
callq 0x1147ca
leaq 0x270(%rsp), %rdi
leaq 0x58(%rsp), %rsi
leaq 0xd8(%rsp), %rdx
callq 0x114812
testb %al, %al
je 0x11372b
leaq 0x270(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0xb8(%rsp), %rdx
callq 0x114812
testb %al, %al
je 0x113752
leaq 0x270(%rsp), %rdi
leaq 0x78(%rsp), %rsi
leaq 0x98(%rsp), %rdx
callq 0x114812
testb %al, %al
je 0x113769
leaq 0x120(%rsp), %rdi
movb $0x0, (%rdi)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rdi)
movupd %xmm0, 0x18(%rdi)
callq 0x114ce8
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movl $0x5f5e100, %ebx        # imm = 0x5F5E100
subq $0x1, %rbx
jb 0x113816
movq 0xd8(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0x20(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd %xmm1, 0x20(%rsp)
movsd %xmm0, 0x18(%rsp)
jmp 0x1136e5
leaq 0x120(%rsp), %rdi
leaq 0x270(%rsp), %rsi
callq 0x114c94
leaq 0x120(%rsp), %rbx
movq (%rbx), %rsi
movq 0x58(%rsp), %rdx
jmp 0x11378e
leaq 0x120(%rsp), %rdi
leaq 0x270(%rsp), %rsi
callq 0x114c94
jmp 0x11377e
leaq 0x120(%rsp), %rdi
leaq 0x270(%rsp), %rsi
callq 0x114c94
leaq 0x120(%rsp), %rbx
movq (%rbx), %rsi
movq 0x38(%rsp), %rdx
leaq 0x1319f1(%rip), %rdi    # 0x245186
xorl %eax, %eax
callq 0x111060
movq %rbx, %rdi
callq 0x1115d8
leaq 0x270(%rsp), %rdi
callq 0x114d3c
leaq 0x98(%rsp), %rdi
callq 0x114e76
leaq 0xb8(%rsp), %rdi
callq 0x114e76
leaq 0xd8(%rsp), %rdi
callq 0x114e76
leaq 0x78(%rsp), %rdi
callq 0x1115d8
leaq 0x38(%rsp), %rdi
callq 0x1115d8
leaq 0x58(%rsp), %rdi
callq 0x1115d8
leaq 0xb98(%rsp), %rdi
callq 0x114e8c
leaq 0x10(%rsp), %rdi
callq 0x114ee0
addq $0x1580, %rsp           # imm = 0x1580
popq %rbx
retq
leaq 0x120(%rsp), %rbx
movq %rbx, %rdi
callq 0x114cf6
movq %rbx, %rdi
callq 0x114d0a
movsd %xmm0, 0x28(%rsp)
leaq 0x120(%rsp), %rdi
callq 0x114d0a
movsd 0x12c7bf(%rip), %xmm1   # 0x240008
divsd %xmm0, %xmm1
leaq 0x13194c(%rip), %rdi    # 0x2451a0
movsd 0x28(%rsp), %xmm0
movsd 0x8(%rsp), %xmm2
movb $0x3, %al
callq 0x111060
leaq 0x120(%rsp), %rdi
movb $0x0, (%rdi)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rdi)
movupd %xmm0, 0x18(%rdi)
callq 0x114ce8
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movl $0x5f5e100, %ebx        # imm = 0x5F5E100
subq $0x1, %rbx
jb 0x1138d6
movq 0xb8(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0x20(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd %xmm1, 0x20(%rsp)
movsd %xmm0, 0x18(%rsp)
jmp 0x113894
leaq 0x120(%rsp), %rbx
movq %rbx, %rdi
callq 0x114cf6
movq %rbx, %rdi
callq 0x114d0a
movsd %xmm0, 0x28(%rsp)
leaq 0x120(%rsp), %rdi
callq 0x114d0a
movsd 0x12c6ff(%rip), %xmm1   # 0x240008
divsd %xmm0, %xmm1
leaq 0x1318cf(%rip), %rdi    # 0x2451e3
movsd 0x28(%rsp), %xmm0
movsd 0x8(%rsp), %xmm2
movb $0x3, %al
callq 0x111060
leaq 0x120(%rsp), %rdi
movb $0x0, (%rdi)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rdi)
movupd %xmm0, 0x18(%rdi)
callq 0x114ce8
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movl $0x5f5e100, %ebx        # imm = 0x5F5E100
subq $0x1, %rbx
jb 0x113996
movq 0x98(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0x20(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd %xmm1, 0x20(%rsp)
movsd %xmm0, 0x18(%rsp)
jmp 0x113954
leaq 0x120(%rsp), %rbx
movq %rbx, %rdi
callq 0x114cf6
movq %rbx, %rdi
callq 0x114d0a
movsd %xmm0, 0x28(%rsp)
leaq 0x120(%rsp), %rdi
callq 0x114d0a
movsd 0x12c63f(%rip), %xmm1   # 0x240008
divsd %xmm0, %xmm1
leaq 0x131852(%rip), %rdi    # 0x245226
movsd 0x28(%rsp), %xmm0
movsd 0x8(%rsp), %xmm2
movb $0x3, %al
callq 0x111060
leaq 0x120(%rsp), %rdi
movb $0x0, (%rdi)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rdi)
movupd %xmm0, 0x18(%rdi)
callq 0x114ce8
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movl $0x5f5e100, %ebx        # imm = 0x5F5E100
subq $0x1, %rbx
jb 0x113a65
movsd 0x20(%rsp), %xmm0
mulsd 0x18(%rsp), %xmm0
callq 0x1114c0
divsd 0x12c5dd(%rip), %xmm0   # 0x240010
addsd 0x12c5dd(%rip), %xmm0   # 0x240018
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0x20(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd %xmm1, 0x20(%rsp)
movsd %xmm0, 0x18(%rsp)
jmp 0x113a14
leaq 0x120(%rsp), %rbx
movq %rbx, %rdi
callq 0x114cf6
movq %rbx, %rdi
callq 0x114d0a
movsd %xmm0, 0x28(%rsp)
leaq 0x120(%rsp), %rdi
callq 0x114d0a
movsd 0x12c570(%rip), %xmm1   # 0x240008
divsd %xmm0, %xmm1
leaq 0x1317c6(%rip), %rdi    # 0x245269
movsd 0x28(%rsp), %xmm0
movsd 0x8(%rsp), %xmm2
movb $0x3, %al
callq 0x111060
jmp 0x1137a4
jmp 0x113bb0
jmp 0x113bb0
jmp 0x113bb0
jmp 0x113bb0
jmp 0x113bb0
jmp 0x113bb0
jmp 0x113bb0
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
callq 0x1147ca
jmp 0x113bc0
movq %rax, %rbx
jmp 0x113bc0
movq %rax, %rbx
jmp 0x113bcd
movq %rax, %rbx
jmp 0x113bda
movq %rax, %rbx
jmp 0x113be7
movq %rax, %rbx
jmp 0x113bf1
movq %rax, %rbx
jmp 0x113bfb
jmp 0x113b3d
jmp 0x113b27
movq %rax, %rbx
jmp 0x113b81
jmp 0x113b2e
movq %rax, %rbx
jmp 0x113b8b
movq %rax, %rbx
jmp 0x113b95
movq %rax, %rbx
jmp 0x113ba2
movq %rax, %rbx
jmp 0x113c05
jmp 0x113b6a
jmp 0x113b53
jmp 0x113b6a
jmp 0x113b53
jmp 0x113b6a
jmp 0x113b53
jmp 0x113b6a
movq %rax, %rbx
leaq 0xb98(%rsp), %rdi
callq 0x1115d8
jmp 0x113c12
jmp 0x113b6a
movq %rax, %rbx
jmp 0x113c12
jmp 0x113bb0
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x1115d8
leaq 0x38(%rsp), %rdi
callq 0x1115d8
leaq 0x58(%rsp), %rdi
callq 0x1115d8
leaq 0x270(%rsp), %rdi
callq 0x114016
leaq 0x120(%rsp), %rdi
jmp 0x113c00
jmp 0x113bb0
jmp 0x113bb0
movq %rax, %rbx
leaq 0x270(%rsp), %rdi
callq 0x114d3c
leaq 0x98(%rsp), %rdi
callq 0x114e76
leaq 0xb8(%rsp), %rdi
callq 0x114e76
leaq 0xd8(%rsp), %rdi
callq 0x114e76
leaq 0x78(%rsp), %rdi
callq 0x1115d8
leaq 0x38(%rsp), %rdi
callq 0x1115d8
leaq 0x58(%rsp), %rdi
callq 0x1115d8
leaq 0xb98(%rsp), %rdi
callq 0x114e8c
leaq 0x10(%rsp), %rdi
callq 0x114ee0
movq %rbx, %rdi
callq 0x111320