// File: ArashPartow[P]exprtk/exprtk_simple_example_01.cpp
// Function: void trig_function<double>()
void trig_function()
{
   typedef exprtk::symbol_table<T> symbol_table_t;
   typedef exprtk::expression<T>   expression_t;
   typedef exprtk::parser<T>       parser_t;

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

   T x;

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

   expression_t expression;
   expression.register_symbol_table(symbol_table);

   parser_t parser;
   parser.compile(expression_string,expression);

   for (x = T(-5); x <= T(+5); x += T(0.001))
   {
      const T y = expression.value();
      printf("%19.15f\t%19.15f\n", x, y);
   }
}

// Assembly:
subq $0xb28, %rsp            # imm = 0xB28
leaq 0xb07(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x111640
movq 0x10(%rsp), %rdx
leaq 0x32fd30(%rip), %rsi    # 0x448555
leaq 0xb08(%rsp), %rdi
callq 0x118740
jmp 0x118834
leaq 0xb07(%rsp), %rdi
callq 0x111760
leaq 0xae0(%rsp), %rdi
movl $0x1, %esi
callq 0x118dd0
jmp 0x118855
leaq 0xabf(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x111640
movq 0x8(%rsp), %rdx
leaq 0x32fc3a(%rip), %rsi    # 0x4484ad
leaq 0xac0(%rsp), %rdi
callq 0x118740
jmp 0x118882
leaq 0xae0(%rsp), %rdi
leaq 0xac0(%rsp), %rsi
leaq 0xae8(%rsp), %rdx
xorl %ecx, %ecx
callq 0x118e10
jmp 0x1188a3
leaq 0xac0(%rsp), %rdi
callq 0x111778
leaq 0xabf(%rsp), %rdi
callq 0x111760
leaq 0xae0(%rsp), %rdi
callq 0x118ec0
jmp 0x1188cc
leaq 0xa98(%rsp), %rdi
callq 0x118f20
jmp 0x1188db
leaq 0xa98(%rsp), %rdi
leaq 0xae0(%rsp), %rsi
callq 0x118fd0
jmp 0x1188f2
leaq 0x20(%rsp), %rdi
movl $0x7f, %esi
callq 0x119080
jmp 0x118903
leaq 0x170(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x1191b0
jmp 0x118917
leaq 0x20(%rsp), %rdi
callq 0x1199e0
leaq 0x170(%rsp), %rdi
leaq 0xb08(%rsp), %rsi
leaq 0xa98(%rsp), %rdx
callq 0x119a50
jmp 0x118940
movsd 0x32a6c0(%rip), %xmm0   # 0x443008
movsd %xmm0, 0xae8(%rsp)
movsd 0x32a6b7(%rip), %xmm0   # 0x443010
ucomisd 0xae8(%rsp), %xmm0
jb 0x118abe
leaq 0xa98(%rsp), %rdi
callq 0x11a2e0
movsd %xmm0, (%rsp)
jmp 0x11897c
movsd (%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0xae8(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
leaq 0x32fbed(%rip), %rdi    # 0x44858a
movb $0x2, %al
callq 0x111080
jmp 0x1189a6
jmp 0x1189a8
movsd 0x32a668(%rip), %xmm0   # 0x443018
addsd 0xae8(%rsp), %xmm0
movsd %xmm0, 0xae8(%rsp)
jmp 0x118951
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xaf8(%rsp)
movl %eax, 0xaf4(%rsp)
leaq 0xb07(%rsp), %rdi
callq 0x111760
jmp 0x118b21
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xaf8(%rsp)
movl %eax, 0xaf4(%rsp)
jmp 0x118b14
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xaf8(%rsp)
movl %eax, 0xaf4(%rsp)
jmp 0x118a3a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xaf8(%rsp)
movl %eax, 0xaf4(%rsp)
leaq 0xac0(%rsp), %rdi
callq 0x111778
leaq 0xabf(%rsp), %rdi
callq 0x111760
jmp 0x118b07
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xaf8(%rsp)
movl %eax, 0xaf4(%rsp)
jmp 0x118b07
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xaf8(%rsp)
movl %eax, 0xaf4(%rsp)
jmp 0x118afa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xaf8(%rsp)
movl %eax, 0xaf4(%rsp)
leaq 0x20(%rsp), %rdi
callq 0x1199e0
jmp 0x118afa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xaf8(%rsp)
movl %eax, 0xaf4(%rsp)
leaq 0x170(%rsp), %rdi
callq 0x11a300
jmp 0x118afa
leaq 0x170(%rsp), %rdi
callq 0x11a300
leaq 0xa98(%rsp), %rdi
callq 0x11a500
leaq 0xae0(%rsp), %rdi
callq 0x11a540
leaq 0xb08(%rsp), %rdi
callq 0x111778
addq $0xb28, %rsp            # imm = 0xB28
retq
leaq 0xa98(%rsp), %rdi
callq 0x11a500
leaq 0xae0(%rsp), %rdi
callq 0x11a540
leaq 0xb08(%rsp), %rdi
callq 0x111778
movq 0xaf8(%rsp), %rdi
callq 0x111440
nop