// File: /workspace/github_cpp_makefile_star2_O2/ArashPartow[P]exprtk/exprtk_test.cpp
// Function: bool run_test05<double>()
bool run_test05()
{
   typedef exprtk::expression<T> expression_t;

   const std::string expression_string = "clamp(-1.0,sin(2 * pi * x_var123) + cos(y_var123 / 2 * pi),+1.0)";

   exprtk::symbol_table<T>  symbol_table;
   std::deque<expression_t> expression_list;

   T x = T(-1000);
   T y = T(-1000);

   symbol_table.add_variable("x_var123",x);
   symbol_table.add_variable("y_var123",y);
   symbol_table.add_constants();

   const std::size_t expression_count = 10;
   for (std::size_t i = 0; i < expression_count; ++i)
   {
      expression_t e;
      e.register_symbol_table(symbol_table);

      {
         exprtk::parser<T> parser;

         if (!parser.compile(expression_string,e))
         {
            printf("run_test05() - Error: %s   Expression: %s\n",
                   parser.error().c_str(),
                   expression_string.c_str());

            return false;
         }
      }

      expression_list.push_back(e);
   }

   const T pi = T(3.141592653589793238462643383279502);
   const T increment = T(0.001);

   while ((x <= T(+1000)) && (y <= T(+1000)))
   {
      T real_result = clamp<T>(-1.0,std::sin(2 * pi * x) + std::cos(y / 2 * pi),+1.0);

      for (std::size_t i = 0; i < expression_list.size(); ++i)
      {
         expression_t& expr = expression_list[i];

         T result = expr.value();

         if (not_equal(result,real_result))
         {
            printf("run_test05() - Computation Error:  Expression: [%s]\tExpected: %19.15f\tResult: %19.15f x:%19.15f\ty:%19.15f\tIndex:%d\n",
                   expression_string.c_str(),
                   static_cast<double>(real_result),
                   static_cast<double>(result),
                   static_cast<double>(x),
                   static_cast<double>(y),
                   static_cast<unsigned int>(i));

            return false;
         }
      }

      x += increment;
      y += increment;
   }

   return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb28, %rsp            # imm = 0xB28
leaq 0x1819b4(%rip), %rsi    # 0x2e89d3
leaq 0x20(%rsp), %rdi
leaq 0x200(%rsp), %rdx
callq 0x127016
leaq 0x8(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x19486e
leaq 0x60(%rsp), %rdi
callq 0x2bb8b6
movabsq $-0x3f70c00000000000, %rax # imm = 0xC08F400000000000
movq %rax, 0x10(%rsp)
movq %rax, (%rsp)
leaq 0x1819b2(%rip), %rsi    # 0x2e8a14
leaq 0x200(%rsp), %rdi
leaq 0xb0(%rsp), %rdx
callq 0x127016
leaq 0x8(%rsp), %rdi
leaq 0x200(%rsp), %rsi
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x19666e
leaq 0x200(%rsp), %rdi
callq 0x118648
leaq 0x181979(%rip), %rsi    # 0x2e8a1d
leaq 0x200(%rsp), %rdi
leaq 0xb0(%rsp), %rdx
callq 0x127016
leaq 0x8(%rsp), %rdi
leaq 0x200(%rsp), %rsi
movq %rsp, %rdx
xorl %ecx, %ecx
callq 0x19666e
leaq 0x200(%rsp), %rdi
callq 0x118648
leaq 0x8(%rsp), %rdi
callq 0x194892
pushq $0xa
popq %r14
leaq 0x40(%rsp), %rbx
leaq 0xb0(%rsp), %r15
pushq $0x7f
popq %r12
leaq 0x200(%rsp), %r13
leaq 0x20(%rsp), %rbp
subq $0x1, %r14
jb 0x167177
movq %rbx, %rdi
callq 0x194918
movq %rbx, %rdi
leaq 0x8(%rsp), %rsi
callq 0x194978
movq %r15, %rdi
movq %r12, %rsi
callq 0x1949d4
movq %r13, %rdi
movq %r15, %rsi
callq 0x194ae4
movq %r15, %rdi
callq 0x1950fc
movq %r13, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x195144
testb %al, %al
je 0x1672bb
movq %r13, %rdi
callq 0x19561a
leaq 0x60(%rsp), %rdi
movq %rbx, %rsi
callq 0x2bb830
movq %rbx, %rdi
callq 0x19577a
jmp 0x167109
movsd 0x10(%rsp), %xmm0
movsd (%rsp), %xmm1
movsd 0x16707e(%rip), %xmm2   # 0x2ce208
movsd 0x16707e(%rip), %xmm3   # 0x2ce210
leaq 0x60(%rsp), %r14
movabsq $0x3ddb7cdfd9d7bdbb, %rbx # imm = 0x3DDB7CDFD9D7BDBB
leaq 0xb0(%rsp), %r15
leaq 0x200(%rsp), %r12
leaq 0x40(%rsp), %r13
ucomisd %xmm0, %xmm2
movb $0x1, %bpl
jb 0x167345
ucomisd %xmm1, %xmm2
jb 0x167345
mulsd %xmm3, %xmm0
callq 0x1181c0
movsd %xmm0, 0x18(%rsp)
movsd (%rsp), %xmm0
mulsd 0x16702f(%rip), %xmm0   # 0x2ce218
mulsd 0x16702f(%rip), %xmm0   # 0x2ce220
callq 0x118500
addsd 0x18(%rsp), %xmm0
movsd 0x166fbc(%rip), %xmm1   # 0x2ce1c0
minsd %xmm0, %xmm1
movsd 0x167018(%rip), %xmm3   # 0x2ce228
cmpltsd %xmm3, %xmm0
movapd %xmm0, %xmm2
andnpd %xmm1, %xmm2
andpd %xmm3, %xmm0
orpd %xmm2, %xmm0
movlpd %xmm0, 0x200(%rsp)
xorl %ebp, %ebp
movq %r14, %rdi
callq 0x2bb85a
cmpq %rax, %rbp
jae 0x167280
leaq 0x70(%rsp), %rdi
movq %rbp, %rsi
callq 0x2bbd1e
movq (%rax), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movsd %xmm0, 0xb0(%rsp)
movq %rbx, 0x40(%rsp)
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x2ba163
testb %al, %al
jne 0x167311
incq %rbp
jmp 0x167230
movsd 0x10(%rsp), %xmm0
movsd 0x166faa(%rip), %xmm2   # 0x2ce238
addsd %xmm2, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd (%rsp), %xmm1
addsd %xmm2, %xmm1
movsd %xmm1, (%rsp)
movsd 0x166f5a(%rip), %xmm2   # 0x2ce208
movsd 0x166f5a(%rip), %xmm3   # 0x2ce210
jmp 0x1671b6
leaq 0xb0(%rsp), %rdi
leaq 0x200(%rsp), %rsi
callq 0x1955c6
leaq 0xb0(%rsp), %rbx
movq (%rbx), %rsi
movq 0x20(%rsp), %rdx
leaq 0x18173f(%rip), %rdi    # 0x2e8a26
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x118080
movq %rbx, %rdi
callq 0x118648
leaq 0x200(%rsp), %rdi
callq 0x19561a
leaq 0x40(%rsp), %rdi
callq 0x19577a
jmp 0x167345
movq 0x20(%rsp), %rsi
movsd 0x200(%rsp), %xmm0
movsd 0xb0(%rsp), %xmm1
movsd 0x10(%rsp), %xmm2
movsd (%rsp), %xmm3
leaq 0x181717(%rip), %rdi    # 0x2e8a51
movl %ebp, %edx
movb $0x4, %al
callq 0x118080
xorl %ebp, %ebp
leaq 0x60(%rsp), %rdi
callq 0x2bb86a
leaq 0x8(%rsp), %rdi
callq 0x195790
leaq 0x20(%rsp), %rdi
callq 0x118648
movl %ebp, %eax
addq $0xb28, %rsp            # imm = 0xB28
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1673b8
jmp 0x16739f
jmp 0x16737f
jmp 0x16739f
movq %rax, %rbx
leaq 0x200(%rsp), %rdi
callq 0x118648
jmp 0x1673d7
jmp 0x16739f
movq %rax, %rbx
jmp 0x1673e1
movq %rax, %rbx
jmp 0x1673eb
jmp 0x16739f
movq %rax, %rbx
jmp 0x1673d7
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x1950fc
jmp 0x1673cd
jmp 0x1673ca
movq %rax, %rbx
leaq 0x200(%rsp), %rdi
callq 0x19561a
jmp 0x1673cd
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x19577a
leaq 0x60(%rsp), %rdi
callq 0x2bb86a
leaq 0x8(%rsp), %rdi
callq 0x195790
leaq 0x20(%rsp), %rdi
callq 0x118648
movq %rbx, %rdi
callq 0x118360