// File: ArashPartow[P]exprtk/exprtk_test.cpp
// Function: bool run_test04<double>()
bool run_test04()
{
   const std::string expression_string = "clamp(-1.0,sin(2 * pi * x) + cos(y / 2 * pi),+1.0)";

   exprtk::symbol_table<T> symbol_table;
   exprtk::expression<T> expression;

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

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

   expression.register_symbol_table(symbol_table);

   {
      exprtk::parser<T> parser;

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

         return false;
      }
   }

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

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

      if (not_equal(result1,result2))
      {
         printf("run_test04() - Computation Error:  Expression: [%s]\tExpected: %19.15f\tResult: %19.15f x:%19.15f\ty:%19.15f\n",
                expression_string.c_str(),
                static_cast<double>(result1),
                static_cast<double>(result2),
                static_cast<double>(x),
                static_cast<double>(y));

         return false;
      }

      x += increment;
      y += increment;
   }

   return true;
}

// Assembly:
subq $0xbf8, %rsp            # imm = 0xBF8
leaq 0xbcf(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x11b6f0
movq 0x48(%rsp), %rdx
leaq 0x401364(%rip), %rsi    # 0x5b5c49
leaq 0xbd0(%rsp), %rdi
callq 0x134520
jmp 0x1b48f4
leaq 0xbcf(%rsp), %rdi
callq 0x11b820
leaq 0xbb0(%rsp), %rdi
movl $0x1, %esi
callq 0x22de90
jmp 0x1b4915
leaq 0xb90(%rsp), %rdi
callq 0x22e450
jmp 0x1b4924
movabsq $-0x3f70c00000000000, %rax # imm = 0xC08F400000000000
movq %rax, 0xb88(%rsp)
movq %rax, 0xb80(%rsp)
leaq 0xb5f(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x11b6f0
movq 0x40(%rsp), %rdx
leaq 0x41bf5b(%rip), %rsi    # 0x5d08b7
leaq 0xb60(%rsp), %rdi
callq 0x134520
jmp 0x1b496b
leaq 0xbb0(%rsp), %rdi
leaq 0xb60(%rsp), %rsi
leaq 0xb88(%rsp), %rdx
xorl %ecx, %ecx
callq 0x2341e0
jmp 0x1b498c
leaq 0xb60(%rsp), %rdi
callq 0x11b838
leaq 0xb5f(%rsp), %rdi
callq 0x11b820
leaq 0xb37(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x11b6f0
movq 0x38(%rsp), %rdx
leaq 0x407231(%rip), %rsi    # 0x5bbbf5
leaq 0xb38(%rsp), %rdi
callq 0x134520
jmp 0x1b49d3
leaq 0xbb0(%rsp), %rdi
leaq 0xb38(%rsp), %rsi
leaq 0xb80(%rsp), %rdx
xorl %ecx, %ecx
callq 0x2341e0
jmp 0x1b49f4
leaq 0xb38(%rsp), %rdi
callq 0x11b838
leaq 0xb37(%rsp), %rdi
callq 0x11b820
leaq 0xbb0(%rsp), %rdi
callq 0x22ded0
jmp 0x1b4a1d
leaq 0xb90(%rsp), %rdi
leaq 0xbb0(%rsp), %rsi
callq 0x22e500
jmp 0x1b4a34
leaq 0xb8(%rsp), %rdi
movl $0x7f, %esi
callq 0x22e5b0
jmp 0x1b4a48
leaq 0x208(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x22e6e0
jmp 0x1b4a5f
leaq 0xb8(%rsp), %rdi
callq 0x22ef10
leaq 0x208(%rsp), %rdi
leaq 0xbd0(%rsp), %rsi
leaq 0xb90(%rsp), %rdx
callq 0x22ef80
movb %al, 0x37(%rsp)
jmp 0x1b4a8f
movb 0x37(%rsp), %al
testb $0x1, %al
jne 0x1b4c78
jmp 0x1b4a9d
leaq 0x98(%rsp), %rdi
leaq 0x208(%rsp), %rsi
callq 0x22f810
jmp 0x1b4ab4
leaq 0x98(%rsp), %rdi
callq 0x11b120
movq %rax, 0x28(%rsp)
leaq 0xbd0(%rsp), %rdi
callq 0x11b120
movq 0x28(%rsp), %rsi
movq %rax, %rdx
leaq 0x40119a(%rip), %rdi    # 0x5b5c7c
xorl %eax, %eax
callq 0x11b0b0
jmp 0x1b4aeb
leaq 0x98(%rsp), %rdi
callq 0x11b838
movb $0x0, 0xbf7(%rsp)
movl $0x1, 0x94(%rsp)
jmp 0x1b4c83
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xbc0(%rsp)
movl %eax, 0xbbc(%rsp)
leaq 0xbcf(%rsp), %rdi
callq 0x11b820
jmp 0x1b4f04
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xbc0(%rsp)
movl %eax, 0xbbc(%rsp)
jmp 0x1b4ef7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xbc0(%rsp)
movl %eax, 0xbbc(%rsp)
jmp 0x1b4eea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xbc0(%rsp)
movl %eax, 0xbbc(%rsp)
jmp 0x1b4b9f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xbc0(%rsp)
movl %eax, 0xbbc(%rsp)
leaq 0xb60(%rsp), %rdi
callq 0x11b838
leaq 0xb5f(%rsp), %rdi
callq 0x11b820
jmp 0x1b4edd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xbc0(%rsp)
movl %eax, 0xbbc(%rsp)
jmp 0x1b4be8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xbc0(%rsp)
movl %eax, 0xbbc(%rsp)
leaq 0xb38(%rsp), %rdi
callq 0x11b838
leaq 0xb37(%rsp), %rdi
callq 0x11b820
jmp 0x1b4edd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xbc0(%rsp)
movl %eax, 0xbbc(%rsp)
jmp 0x1b4edd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xbc0(%rsp)
movl %eax, 0xbbc(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0x22ef10
jmp 0x1b4edd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xbc0(%rsp)
movl %eax, 0xbbc(%rsp)
jmp 0x1b4e47
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xbc0(%rsp)
movl %eax, 0xbbc(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x11b838
jmp 0x1b4e47
movl $0x0, 0x94(%rsp)
leaq 0x208(%rsp), %rdi
callq 0x22f8d0
movl 0x94(%rsp), %eax
testl %eax, %eax
jne 0x1b4ea5
jmp 0x1b4ca1
movsd 0x3e63af(%rip), %xmm0   # 0x59b058
movsd %xmm0, 0x88(%rsp)
movsd 0x3e6396(%rip), %xmm0   # 0x59b050
movsd %xmm0, 0x80(%rsp)
xorl %eax, %eax
movsd 0x3e6393(%rip), %xmm0   # 0x59b060
ucomisd 0xb88(%rsp), %xmm0
movb %al, 0x27(%rsp)
jb 0x1b4cf4
movsd 0x3e637c(%rip), %xmm0   # 0x59b060
ucomisd 0xb80(%rsp), %xmm0
setae %al
movb %al, 0x27(%rsp)
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0x1b4d01
jmp 0x1b4e92
leaq 0xb90(%rsp), %rdi
callq 0x22fb10
movsd %xmm0, 0x18(%rsp)
jmp 0x1b4d16
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x78(%rsp)
movabsq $-0x4010000000000000, %rax # imm = 0xBFF0000000000000
movq %rax, 0x68(%rsp)
movsd 0xb88(%rsp), %xmm0
movsd 0x3e6326(%rip), %xmm1   # 0x59b068
mulsd %xmm1, %xmm0
callq 0x11b2e0
movsd %xmm0, 0x8(%rsp)
movsd 0xb80(%rsp), %xmm0
movsd 0x3e630e(%rip), %xmm1   # 0x59b070
mulsd %xmm1, %xmm0
movsd 0x3e62ea(%rip), %xmm1   # 0x59b058
mulsd %xmm1, %xmm0
callq 0x11b6c0
movaps %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x60(%rsp)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x58(%rsp)
leaq 0x68(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x561910
movsd %xmm0, 0x10(%rsp)
jmp 0x1b4db5
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x70(%rsp)
movabsq $0x3ddb7cdfd9d7bdbb, %rax # imm = 0x3DDB7CDFD9D7BDBB
movq %rax, 0x50(%rsp)
leaq 0x78(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x22fb30
movb %al, 0x7(%rsp)
jmp 0x1b4dea
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0x1b4df4
jmp 0x1b4e59
leaq 0xbd0(%rsp), %rdi
callq 0x11b120
movq %rax, %rsi
movsd 0x78(%rsp), %xmm0
movsd 0x70(%rsp), %xmm1
movsd 0xb88(%rsp), %xmm2
movsd 0xb80(%rsp), %xmm3
leaq 0x400e7e(%rip), %rdi    # 0x5b5ca7
movb $0x4, %al
callq 0x11b0b0
jmp 0x1b4e32
movb $0x0, 0xbf7(%rsp)
movl $0x1, 0x94(%rsp)
jmp 0x1b4ea5
leaq 0x208(%rsp), %rdi
callq 0x22f8d0
jmp 0x1b4edd
movsd 0x3e61ef(%rip), %xmm0   # 0x59b050
addsd 0xb88(%rsp), %xmm0
movsd %xmm0, 0xb88(%rsp)
movsd 0x3e61d5(%rip), %xmm0   # 0x59b050
addsd 0xb80(%rsp), %xmm0
movsd %xmm0, 0xb80(%rsp)
jmp 0x1b4cc3
movb $0x1, 0xbf7(%rsp)
movl $0x1, 0x94(%rsp)
leaq 0xb90(%rsp), %rdi
callq 0x22fb60
leaq 0xbb0(%rsp), %rdi
callq 0x22fc60
leaq 0xbd0(%rsp), %rdi
callq 0x11b838
movb 0xbf7(%rsp), %al
andb $0x1, %al
addq $0xbf8, %rsp            # imm = 0xBF8
retq
leaq 0xb90(%rsp), %rdi
callq 0x22fb60
leaq 0xbb0(%rsp), %rdi
callq 0x22fc60
leaq 0xbd0(%rsp), %rdi
callq 0x11b838
movq 0xbc0(%rsp), %rdi
callq 0x11b4e0
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)