// File: 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:
subq $0xc68, %rsp            # imm = 0xC68
leaq 0xc3f(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x11b6f0
movq 0x48(%rsp), %rdx
leaq 0x400dcd(%rip), %rsi    # 0x5b5d12
leaq 0xc40(%rsp), %rdi
callq 0x134520
jmp 0x1b4f54
leaq 0xc3f(%rsp), %rdi
callq 0x11b820
leaq 0xc20(%rsp), %rdi
movl $0x1, %esi
callq 0x22de90
jmp 0x1b4f75
leaq 0xbd0(%rsp), %rdi
callq 0x561990
jmp 0x1b4f84
movabsq $-0x3f70c00000000000, %rax # imm = 0xC08F400000000000
movq %rax, 0xbc8(%rsp)
movq %rax, 0xbc0(%rsp)
leaq 0xb9f(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x11b6f0
movq 0x40(%rsp), %rdx
leaq 0x400d97(%rip), %rsi    # 0x5b5d53
leaq 0xba0(%rsp), %rdi
callq 0x134520
jmp 0x1b4fcb
leaq 0xc20(%rsp), %rdi
leaq 0xba0(%rsp), %rsi
leaq 0xbc8(%rsp), %rdx
xorl %ecx, %ecx
callq 0x2341e0
jmp 0x1b4fec
leaq 0xba0(%rsp), %rdi
callq 0x11b838
leaq 0xb9f(%rsp), %rdi
callq 0x11b820
leaq 0xb77(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x11b6f0
movq 0x38(%rsp), %rdx
leaq 0x400d38(%rip), %rsi    # 0x5b5d5c
leaq 0xb78(%rsp), %rdi
callq 0x134520
jmp 0x1b5033
leaq 0xc20(%rsp), %rdi
leaq 0xb78(%rsp), %rsi
leaq 0xbc0(%rsp), %rdx
xorl %ecx, %ecx
callq 0x2341e0
jmp 0x1b5054
leaq 0xb78(%rsp), %rdi
callq 0x11b838
leaq 0xb77(%rsp), %rdi
callq 0x11b820
leaq 0xc20(%rsp), %rdi
callq 0x22ded0
jmp 0x1b507d
movq $0xa, 0xb68(%rsp)
movq $0x0, 0xb60(%rsp)
cmpq $0xa, 0xb60(%rsp)
jae 0x1b53c6
leaq 0xb40(%rsp), %rdi
callq 0x22e450
jmp 0x1b50b3
leaq 0xb40(%rsp), %rdi
leaq 0xc20(%rsp), %rsi
callq 0x22e500
jmp 0x1b50ca
leaq 0xc8(%rsp), %rdi
movl $0x7f, %esi
callq 0x22e5b0
jmp 0x1b50de
leaq 0x218(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x22e6e0
jmp 0x1b50f5
leaq 0xc8(%rsp), %rdi
callq 0x22ef10
leaq 0x218(%rsp), %rdi
leaq 0xc40(%rsp), %rsi
leaq 0xb40(%rsp), %rdx
callq 0x22ef80
movb %al, 0x37(%rsp)
jmp 0x1b5125
movb 0x37(%rsp), %al
testb $0x1, %al
jne 0x1b5327
jmp 0x1b5133
leaq 0xa8(%rsp), %rdi
leaq 0x218(%rsp), %rsi
callq 0x22f810
jmp 0x1b514a
leaq 0xa8(%rsp), %rdi
callq 0x11b120
movq %rax, 0x28(%rsp)
leaq 0xc40(%rsp), %rdi
callq 0x11b120
movq 0x28(%rsp), %rsi
movq %rax, %rdx
leaq 0x400bed(%rip), %rdi    # 0x5b5d65
xorl %eax, %eax
callq 0x11b0b0
jmp 0x1b5181
leaq 0xa8(%rsp), %rdi
callq 0x11b838
movb $0x0, 0xc67(%rsp)
movl $0x1, 0xa4(%rsp)
jmp 0x1b5332
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc30(%rsp)
movl %eax, 0xc2c(%rsp)
leaq 0xc3f(%rsp), %rdi
callq 0x11b820
jmp 0x1b5670
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc30(%rsp)
movl %eax, 0xc2c(%rsp)
jmp 0x1b5663
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc30(%rsp)
movl %eax, 0xc2c(%rsp)
jmp 0x1b5656
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc30(%rsp)
movl %eax, 0xc2c(%rsp)
jmp 0x1b5235
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc30(%rsp)
movl %eax, 0xc2c(%rsp)
leaq 0xba0(%rsp), %rdi
callq 0x11b838
leaq 0xb9f(%rsp), %rdi
callq 0x11b820
jmp 0x1b5649
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc30(%rsp)
movl %eax, 0xc2c(%rsp)
jmp 0x1b527e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc30(%rsp)
movl %eax, 0xc2c(%rsp)
leaq 0xb78(%rsp), %rdi
callq 0x11b838
leaq 0xb77(%rsp), %rdi
callq 0x11b820
jmp 0x1b5649
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc30(%rsp)
movl %eax, 0xc2c(%rsp)
jmp 0x1b5649
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc30(%rsp)
movl %eax, 0xc2c(%rsp)
jmp 0x1b53b4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc30(%rsp)
movl %eax, 0xc2c(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x22ef10
jmp 0x1b53b4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc30(%rsp)
movl %eax, 0xc2c(%rsp)
jmp 0x1b53a7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc30(%rsp)
movl %eax, 0xc2c(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x11b838
jmp 0x1b53a7
movl $0x0, 0xa4(%rsp)
leaq 0x218(%rsp), %rdi
callq 0x22f8d0
movl 0xa4(%rsp), %eax
testl %eax, %eax
jne 0x1b536e
jmp 0x1b534c
leaq 0xbd0(%rsp), %rdi
leaq 0xb40(%rsp), %rsi
callq 0x5619a0
jmp 0x1b5363
movl $0x0, 0xa4(%rsp)
leaq 0xb40(%rsp), %rdi
callq 0x22fb60
movl 0xa4(%rsp), %eax
testl %eax, %eax
jne 0x1b5611
jmp 0x1b538c
jmp 0x1b538e
movq 0xb60(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xb60(%rsp)
jmp 0x1b5095
leaq 0x218(%rsp), %rdi
callq 0x22f8d0
leaq 0xb40(%rsp), %rdi
callq 0x22fb60
jmp 0x1b5649
movsd 0x3e5c8a(%rip), %xmm0   # 0x59b058
movsd %xmm0, 0x98(%rsp)
movsd 0x3e5c99(%rip), %xmm0   # 0x59b078
movsd %xmm0, 0x90(%rsp)
xorl %eax, %eax
movsd 0x3e5c6e(%rip), %xmm0   # 0x59b060
ucomisd 0xbc8(%rsp), %xmm0
movb %al, 0x27(%rsp)
jb 0x1b5419
movsd 0x3e5c57(%rip), %xmm0   # 0x59b060
ucomisd 0xbc0(%rsp), %xmm0
setae %al
movb %al, 0x27(%rsp)
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0x1b5426
jmp 0x1b55fe
movsd 0x3e5c5a(%rip), %xmm0   # 0x59b088
movsd %xmm0, 0x80(%rsp)
movsd 0x3e5c29(%rip), %xmm0   # 0x59b068
mulsd 0xbc8(%rsp), %xmm0
callq 0x11b2e0
movsd %xmm0, 0x18(%rsp)
movsd 0xbc0(%rsp), %xmm0
movsd 0x3e5c1c(%rip), %xmm1   # 0x59b080
divsd %xmm1, %xmm0
movsd 0x3e5be8(%rip), %xmm1   # 0x59b058
mulsd %xmm1, %xmm0
callq 0x11b6c0
movaps %xmm0, %xmm1
movsd 0x18(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x78(%rsp)
movsd 0x3e5bac(%rip), %xmm0   # 0x59b040
movsd %xmm0, 0x70(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x78(%rsp), %rsi
leaq 0x70(%rsp), %rdx
callq 0x561910
movsd %xmm0, 0x88(%rsp)
movq $0x0, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0xbd0(%rsp), %rdi
callq 0x561a00
movq %rax, %rcx
movq 0x10(%rsp), %rax
cmpq %rcx, %rax
jae 0x1b55c5
movq 0x68(%rsp), %rsi
leaq 0xbd0(%rsp), %rdi
callq 0x561a20
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rdi
callq 0x22fb10
movsd %xmm0, 0x8(%rsp)
jmp 0x1b5514
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
movabsq $0x3ddb7cdfd9d7bdbb, %rax # imm = 0x3DDB7CDFD9D7BDBB
movq %rax, 0x50(%rsp)
leaq 0x58(%rsp), %rdi
leaq 0x88(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x22fb30
movb %al, 0x7(%rsp)
jmp 0x1b554c
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0x1b5556
jmp 0x1b55b0
leaq 0xc40(%rsp), %rdi
callq 0x11b120
movq %rax, %rsi
movsd 0x88(%rsp), %xmm0
movsd 0x58(%rsp), %xmm1
movsd 0xbc8(%rsp), %xmm2
movsd 0xbc0(%rsp), %xmm3
movl 0x68(%rsp), %edx
leaq 0x4007fe(%rip), %rdi    # 0x5b5d90
movb $0x4, %al
callq 0x11b0b0
jmp 0x1b559b
movb $0x0, 0xc67(%rsp)
movl $0x1, 0xa4(%rsp)
jmp 0x1b5611
jmp 0x1b55b2
movq 0x68(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x68(%rsp)
jmp 0x1b54c3
movsd 0x3e5aab(%rip), %xmm0   # 0x59b078
addsd 0xbc8(%rsp), %xmm0
movsd %xmm0, 0xbc8(%rsp)
movsd 0x3e5a91(%rip), %xmm0   # 0x59b078
addsd 0xbc0(%rsp), %xmm0
movsd %xmm0, 0xbc0(%rsp)
jmp 0x1b53e8
movb $0x1, 0xc67(%rsp)
movl $0x1, 0xa4(%rsp)
leaq 0xbd0(%rsp), %rdi
callq 0x561a50
leaq 0xc20(%rsp), %rdi
callq 0x22fc60
leaq 0xc40(%rsp), %rdi
callq 0x11b838
movb 0xc67(%rsp), %al
andb $0x1, %al
addq $0xc68, %rsp            # imm = 0xC68
retq
leaq 0xbd0(%rsp), %rdi
callq 0x561a50
leaq 0xc20(%rsp), %rdi
callq 0x22fc60
leaq 0xc40(%rsp), %rdi
callq 0x11b838
movq 0xc30(%rsp), %rdi
callq 0x11b4e0
nopl (%rax)