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

   const std::string expression_string = "sin(2x + 1 / 3)";

   T x = T(0);

   exprtk::symbol_table<T> symbol_table;
   symbol_table.add_variable("x",x);

   expression_t expression;
   expression.register_symbol_table(symbol_table);

   {
      exprtk::parser<T> parser;

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

         return false;
      }
   }

   for (x = T(-200); x < T(200); x += T(0.0001))
   {
      {
         T deriv1_real_result = T(2) * std::cos(T(2) * x + T(1.0 / 3.0));
         T deriv1_result1 = exprtk::derivative(expression,x);
         T deriv1_result2 = exprtk::derivative(expression,"x");

         if (not_equal(deriv1_result1,deriv1_result2,T(0.00001)))
         {
            printf("run_test07() - 1st Derivative Error:  result1 != result2\n");
            return false;
         }

         if (not_equal(deriv1_result1,deriv1_real_result,T(0.00001)))
         {
            printf("run_test07() - 1st Derivative Error:  x: %19.15f\tExpected: %19.15f\tResult: %19.15f\n",
                   static_cast<double>(x),
                   static_cast<double>(deriv1_real_result),
                   static_cast<double>(deriv1_result1));

            return false;
         }
      }

      {
         T deriv2_real_result = T(-4) * std::sin(T(2) * x + T(1.0 / 3.0));
         T deriv2_result1 = exprtk::second_derivative(expression,x);
         T deriv2_result2 = exprtk::second_derivative(expression,"x");

         if (not_equal(deriv2_result1,deriv2_result2,T(0.0000001)))
         {
            printf("run_test07() - 2nd Derivative Error:  result1 != result2\n");
            return false;
         }

         if (not_equal(deriv2_result1,deriv2_real_result,T(0.01)))
         {
            printf("run_test07() - 2nd Derivative Error:  x: %19.15f\tExpected: %19.15f\tResult: %19.15f\n",
                   static_cast<double>(x),
                   static_cast<double>(deriv2_real_result),
                   static_cast<double>(deriv2_result1));

            return false;
         }
      }

      {
         T deriv3_real_result = T(-8) * std::cos(T(2) * x + T(1.0 / 3.0));
         T deriv3_result1 = exprtk::third_derivative(expression,x);
         T deriv3_result2 = exprtk::third_derivative(expression,"x");

         if (not_equal(deriv3_result1,deriv3_result2,T(0.0000001)))
         {
            printf("run_test07() - 3rd Derivative Error:  result1 != result2\n");
            return false;
         }

         if (not_equal(deriv3_result1,deriv3_real_result,T(0.01)))
         {
            printf("run_test07() - 3rd Derivative Error:  x: %19.15f\tExpected: %19.15f\tResult: %19.15f\n",
                   static_cast<double>(x),
                   static_cast<double>(deriv3_real_result),
                   static_cast<double>(deriv3_result1));

            return false;
         }
      }
   }

   return true;
}

// Assembly:
subq $0xcd8, %rsp            # imm = 0xCD8
leaq 0xcaf(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x11b6f0
movq 0x78(%rsp), %rdx
leaq 0x400233(%rip), %rsi    # 0x5b5eb8
leaq 0xcb0(%rsp), %rdi
callq 0x134520
jmp 0x1b5c94
leaq 0xcaf(%rsp), %rdi
callq 0x11b820
movq $0x0, 0xc90(%rsp)
leaq 0xc88(%rsp), %rdi
movl $0x1, %esi
callq 0x22de90
jmp 0x1b5cc1
leaq 0xc67(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0x11b6f0
movq 0x70(%rsp), %rdx
leaq 0x41abd8(%rip), %rsi    # 0x5d08b7
leaq 0xc68(%rsp), %rdi
callq 0x134520
jmp 0x1b5cee
leaq 0xc88(%rsp), %rdi
leaq 0xc68(%rsp), %rsi
leaq 0xc90(%rsp), %rdx
xorl %ecx, %ecx
callq 0x2341e0
jmp 0x1b5d0f
leaq 0xc68(%rsp), %rdi
callq 0x11b838
leaq 0xc67(%rsp), %rdi
callq 0x11b820
leaq 0xc40(%rsp), %rdi
callq 0x22e450
jmp 0x1b5d38
leaq 0xc40(%rsp), %rdi
leaq 0xc88(%rsp), %rsi
callq 0x22e500
jmp 0x1b5d4f
leaq 0x1c8(%rsp), %rdi
movl $0x7f, %esi
callq 0x22e5b0
jmp 0x1b5d63
leaq 0x318(%rsp), %rdi
leaq 0x1c8(%rsp), %rsi
callq 0x22e6e0
jmp 0x1b5d7a
leaq 0x1c8(%rsp), %rdi
callq 0x22ef10
leaq 0x318(%rsp), %rdi
leaq 0xcb0(%rsp), %rsi
leaq 0xc40(%rsp), %rdx
callq 0x22ef80
movb %al, 0x6f(%rsp)
jmp 0x1b5daa
movb 0x6f(%rsp), %al
testb $0x1, %al
jne 0x1b5f4a
jmp 0x1b5db8
leaq 0x1a8(%rsp), %rdi
leaq 0x318(%rsp), %rsi
callq 0x22f810
jmp 0x1b5dcf
leaq 0x1a8(%rsp), %rdi
callq 0x11b120
movq %rax, 0x60(%rsp)
leaq 0xcb0(%rsp), %rdi
callq 0x11b120
movq 0x60(%rsp), %rsi
movq %rax, %rdx
leaq 0x4000cb(%rip), %rdi    # 0x5b5ec8
xorl %eax, %eax
callq 0x11b0b0
jmp 0x1b5e06
leaq 0x1a8(%rsp), %rdi
callq 0x11b838
movb $0x0, 0xcd7(%rsp)
movl $0x1, 0x1a4(%rsp)
jmp 0x1b5f55
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xca0(%rsp)
movl %eax, 0xc9c(%rsp)
leaq 0xcaf(%rsp), %rdi
callq 0x11b820
jmp 0x1b66e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xca0(%rsp)
movl %eax, 0xc9c(%rsp)
jmp 0x1b66d3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xca0(%rsp)
movl %eax, 0xc9c(%rsp)
jmp 0x1b5ea1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xca0(%rsp)
movl %eax, 0xc9c(%rsp)
leaq 0xc68(%rsp), %rdi
callq 0x11b838
leaq 0xc67(%rsp), %rdi
callq 0x11b820
jmp 0x1b66c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xca0(%rsp)
movl %eax, 0xc9c(%rsp)
jmp 0x1b66c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xca0(%rsp)
movl %eax, 0xc9c(%rsp)
jmp 0x1b66b9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xca0(%rsp)
movl %eax, 0xc9c(%rsp)
leaq 0x1c8(%rsp), %rdi
callq 0x22ef10
jmp 0x1b66b9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xca0(%rsp)
movl %eax, 0xc9c(%rsp)
jmp 0x1b6103
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xca0(%rsp)
movl %eax, 0xc9c(%rsp)
leaq 0x1a8(%rsp), %rdi
callq 0x11b838
jmp 0x1b6103
movl $0x0, 0x1a4(%rsp)
leaq 0x318(%rsp), %rdi
callq 0x22f8d0
movl 0x1a4(%rsp), %eax
testl %eax, %eax
jne 0x1b6681
jmp 0x1b5f73
movsd 0x3e511d(%rip), %xmm0   # 0x59b098
movsd %xmm0, 0xc90(%rsp)
movsd 0x3e5114(%rip), %xmm0   # 0x59b0a0
ucomisd 0xc90(%rsp), %xmm0
jbe 0x1b666e
movsd 0xc90(%rsp), %xmm0
addsd %xmm0, %xmm0
movsd 0x3e50f8(%rip), %xmm1   # 0x59b0a8
addsd %xmm1, %xmm0
callq 0x11b6c0
addsd %xmm0, %xmm0
movsd %xmm0, 0x198(%rsp)
movabsq $0x3e45798ee2308c3a, %rax # imm = 0x3E45798EE2308C3A
movq %rax, 0x188(%rsp)
leaq 0xc40(%rsp), %rdi
leaq 0xc90(%rsp), %rsi
leaq 0x188(%rsp), %rdx
callq 0x5634d0
movsd %xmm0, 0x58(%rsp)
jmp 0x1b5ffd
movsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x190(%rsp)
leaq 0x15f(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x11b6f0
movq 0x50(%rsp), %rdx
leaq 0x41a88d(%rip), %rsi    # 0x5d08b7
leaq 0x160(%rsp), %rdi
callq 0x134520
jmp 0x1b6039
movabsq $0x3e45798ee2308c3a, %rax # imm = 0x3E45798EE2308C3A
movq %rax, 0x150(%rsp)
leaq 0xc40(%rsp), %rdi
leaq 0x160(%rsp), %rsi
leaq 0x150(%rsp), %rdx
callq 0x563610
movsd %xmm0, 0x48(%rsp)
jmp 0x1b6070
leaq 0x160(%rsp), %rdi
callq 0x11b838
leaq 0x15f(%rsp), %rdi
callq 0x11b820
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x180(%rsp)
movabsq $0x3ee4f8b588e368f1, %rax # imm = 0x3EE4F8B588E368F1
movq %rax, 0x148(%rsp)
leaq 0x190(%rsp), %rdi
leaq 0x180(%rsp), %rsi
leaq 0x148(%rsp), %rdx
callq 0x22fb30
movb %al, 0x47(%rsp)
jmp 0x1b60ce
movb 0x47(%rsp), %al
testb $0x1, %al
jne 0x1b60db
jmp 0x1b615e
leaq 0x3ffe11(%rip), %rdi    # 0x5b5ef3
xorl %eax, %eax
callq 0x11b0b0
jmp 0x1b60eb
movb $0x0, 0xcd7(%rsp)
movl $0x1, 0x1a4(%rsp)
jmp 0x1b6681
leaq 0x318(%rsp), %rdi
callq 0x22f8d0
jmp 0x1b66b9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xca0(%rsp)
movl %eax, 0xc9c(%rsp)
jmp 0x1b614c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xca0(%rsp)
movl %eax, 0xc9c(%rsp)
leaq 0x160(%rsp), %rdi
callq 0x11b838
leaq 0x15f(%rsp), %rdi
callq 0x11b820
jmp 0x1b66b9
movabsq $0x3ee4f8b588e368f1, %rax # imm = 0x3EE4F8B588E368F1
movq %rax, 0x140(%rsp)
leaq 0x190(%rsp), %rdi
leaq 0x198(%rsp), %rsi
leaq 0x140(%rsp), %rdx
callq 0x22fb30
movb %al, 0x46(%rsp)
jmp 0x1b6193
movb 0x46(%rsp), %al
testb $0x1, %al
jne 0x1b619d
jmp 0x1b61e0
movsd 0xc90(%rsp), %xmm0
movsd 0x198(%rsp), %xmm1
movsd 0x190(%rsp), %xmm2
leaq 0x3ffd6e(%rip), %rdi    # 0x5b5f2d
movb $0x3, %al
callq 0x11b0b0
jmp 0x1b61c8
movb $0x0, 0xcd7(%rsp)
movl $0x1, 0x1a4(%rsp)
jmp 0x1b6681
movsd 0xc90(%rsp), %xmm0
addsd %xmm0, %xmm0
movsd 0x3e4eb3(%rip), %xmm1   # 0x59b0a8
addsd %xmm1, %xmm0
callq 0x11b2e0
movsd 0x3e4e1a(%rip), %xmm1   # 0x59b020
mulsd %xmm1, %xmm0
movsd %xmm0, 0x138(%rsp)
movabsq $0x3ee4f8b588e368f1, %rax # imm = 0x3EE4F8B588E368F1
movq %rax, 0x128(%rsp)
leaq 0xc40(%rsp), %rdi
leaq 0xc90(%rsp), %rsi
leaq 0x128(%rsp), %rdx
callq 0x5636f0
movsd %xmm0, 0x38(%rsp)
jmp 0x1b624a
movsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x130(%rsp)
leaq 0xff(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x11b6f0
movq 0x30(%rsp), %rdx
leaq 0x41a640(%rip), %rsi    # 0x5d08b7
leaq 0x100(%rsp), %rdi
callq 0x134520
jmp 0x1b6286
movabsq $0x3ee4f8b588e368f1, %rax # imm = 0x3EE4F8B588E368F1
movq %rax, 0xf0(%rsp)
leaq 0xc40(%rsp), %rdi
leaq 0x100(%rsp), %rsi
leaq 0xf0(%rsp), %rdx
callq 0x563860
movsd %xmm0, 0x28(%rsp)
jmp 0x1b62bd
leaq 0x100(%rsp), %rdi
callq 0x11b838
leaq 0xff(%rsp), %rdi
callq 0x11b820
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x120(%rsp)
movabsq $0x3e7ad7f29abcaf48, %rax # imm = 0x3E7AD7F29ABCAF48
movq %rax, 0xe8(%rsp)
leaq 0x130(%rsp), %rdi
leaq 0x120(%rsp), %rsi
leaq 0xe8(%rsp), %rdx
callq 0x22fb30
movb %al, 0x27(%rsp)
jmp 0x1b631b
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0x1b6325
jmp 0x1b6396
leaq 0x3ffc55(%rip), %rdi    # 0x5b5f81
xorl %eax, %eax
callq 0x11b0b0
jmp 0x1b6335
movb $0x0, 0xcd7(%rsp)
movl $0x1, 0x1a4(%rsp)
jmp 0x1b6681
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xca0(%rsp)
movl %eax, 0xc9c(%rsp)
jmp 0x1b6384
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xca0(%rsp)
movl %eax, 0xc9c(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x11b838
leaq 0xff(%rsp), %rdi
callq 0x11b820
jmp 0x1b66b9
movabsq $0x3f847ae147ae147b, %rax # imm = 0x3F847AE147AE147B
movq %rax, 0xe0(%rsp)
leaq 0x130(%rsp), %rdi
leaq 0x138(%rsp), %rsi
leaq 0xe0(%rsp), %rdx
callq 0x22fb30
movb %al, 0x26(%rsp)
jmp 0x1b63cb
movb 0x26(%rsp), %al
testb $0x1, %al
jne 0x1b63d5
jmp 0x1b6418
movsd 0xc90(%rsp), %xmm0
movsd 0x138(%rsp), %xmm1
movsd 0x130(%rsp), %xmm2
leaq 0x3ffbc4(%rip), %rdi    # 0x5b5fbb
movb $0x3, %al
callq 0x11b0b0
jmp 0x1b6400
movb $0x0, 0xcd7(%rsp)
movl $0x1, 0x1a4(%rsp)
jmp 0x1b6681
movsd 0xc90(%rsp), %xmm0
addsd %xmm0, %xmm0
movsd 0x3e4c7b(%rip), %xmm1   # 0x59b0a8
addsd %xmm1, %xmm0
callq 0x11b6c0
movsd 0x3e4c72(%rip), %xmm1   # 0x59b0b0
mulsd %xmm1, %xmm0
movsd %xmm0, 0xd8(%rsp)
movabsq $0x3f1a36e2eb1c432d, %rax # imm = 0x3F1A36E2EB1C432D
movq %rax, 0xc8(%rsp)
leaq 0xc40(%rsp), %rdi
leaq 0xc90(%rsp), %rsi
leaq 0xc8(%rsp), %rdx
callq 0x563940
movsd %xmm0, 0x18(%rsp)
jmp 0x1b6482
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0xd0(%rsp)
leaq 0x9f(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x11b6f0
movq 0x10(%rsp), %rdx
leaq 0x41a408(%rip), %rsi    # 0x5d08b7
leaq 0xa0(%rsp), %rdi
callq 0x134520
jmp 0x1b64be
movabsq $0x3f1a36e2eb1c432d, %rax # imm = 0x3F1A36E2EB1C432D
movq %rax, 0x90(%rsp)
leaq 0xc40(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
leaq 0x90(%rsp), %rdx
callq 0x563a70
movsd %xmm0, 0x8(%rsp)
jmp 0x1b64f5
leaq 0xa0(%rsp), %rdi
callq 0x11b838
leaq 0x9f(%rsp), %rdi
callq 0x11b820
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0xc0(%rsp)
movabsq $0x3e7ad7f29abcaf48, %rax # imm = 0x3E7AD7F29ABCAF48
movq %rax, 0x88(%rsp)
leaq 0xd0(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
leaq 0x88(%rsp), %rdx
callq 0x22fb30
movb %al, 0x7(%rsp)
jmp 0x1b6553
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0x1b655d
jmp 0x1b65ce
leaq 0x3ffaab(%rip), %rdi    # 0x5b600f
xorl %eax, %eax
callq 0x11b0b0
jmp 0x1b656d
movb $0x0, 0xcd7(%rsp)
movl $0x1, 0x1a4(%rsp)
jmp 0x1b6681
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xca0(%rsp)
movl %eax, 0xc9c(%rsp)
jmp 0x1b65bc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xca0(%rsp)
movl %eax, 0xc9c(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x11b838
leaq 0x9f(%rsp), %rdi
callq 0x11b820
jmp 0x1b66b9
movabsq $0x3f847ae147ae147b, %rax # imm = 0x3F847AE147AE147B
movq %rax, 0x80(%rsp)
leaq 0xd0(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
leaq 0x80(%rsp), %rdx
callq 0x22fb30
movb %al, 0x6(%rsp)
jmp 0x1b6603
movb 0x6(%rsp), %al
testb $0x1, %al
jne 0x1b660d
jmp 0x1b664d
movsd 0xc90(%rsp), %xmm0
movsd 0xd8(%rsp), %xmm1
movsd 0xd0(%rsp), %xmm2
leaq 0x3ffa1a(%rip), %rdi    # 0x5b6049
movb $0x3, %al
callq 0x11b0b0
jmp 0x1b6638
movb $0x0, 0xcd7(%rsp)
movl $0x1, 0x1a4(%rsp)
jmp 0x1b6681
jmp 0x1b664f
movsd 0x3e49f9(%rip), %xmm0   # 0x59b050
addsd 0xc90(%rsp), %xmm0
movsd %xmm0, 0xc90(%rsp)
jmp 0x1b5f84
movb $0x1, 0xcd7(%rsp)
movl $0x1, 0x1a4(%rsp)
leaq 0xc40(%rsp), %rdi
callq 0x22fb60
leaq 0xc88(%rsp), %rdi
callq 0x22fc60
leaq 0xcb0(%rsp), %rdi
callq 0x11b838
movb 0xcd7(%rsp), %al
andb $0x1, %al
addq $0xcd8, %rsp            # imm = 0xCD8
retq
leaq 0xc40(%rsp), %rdi
callq 0x22fb60
leaq 0xc88(%rsp), %rdi
callq 0x22fc60
leaq 0xcb0(%rsp), %rdi
callq 0x11b838
movq 0xca0(%rsp), %rdi
callq 0x11b4e0
nopl (%rax)