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

   const std::string wave_program =
      " var r := 0;                                          "
      "                                                      "
      " for (var i := 0; i < 1000; i += 1)                   "
      " {                                                    "
      "    r += (1 / (2i + 1)) * sin((4i + 2) * pi * f * t); "
      " };                                                   "
      "                                                      "
      " r *= a * (4 / pi);                                   ";

   static const T pi = T(3.141592653589793238462643383279502);

   T f = pi / T(10);
   T t = T(0);
   T a = T(10);

   symbol_table_t symbol_table;
   symbol_table.add_variable("f",f);
   symbol_table.add_variable("t",t);
   symbol_table.add_variable("a",a);
   symbol_table.add_constants();

   expression_t expression;
   expression.register_symbol_table(symbol_table);

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

   const T delta = (T(4) * pi) / T(1000);

   for (t = (T(-2) * pi); t <= (T(+2) * pi); t += delta)
   {
      const T result = expression.value();
      printf("%19.15f\t%19.15f\n", t, result);
   }
}

// Assembly:
pushq %rbx
subq $0xae0, %rsp            # imm = 0xAE0
leaq 0x129e0f(%rip), %rsi    # 0x23a111
leaq 0x48(%rsp), %rdi
leaq 0x1b8(%rsp), %rdx
callq 0x1102b8
andq $0x0, 0x10(%rsp)
movabsq $0x3fd41b2f769cf0e0, %rax # imm = 0x3FD41B2F769CF0E0
movq %rax, 0x20(%rsp)
movabsq $0x4024000000000000, %rax # imm = 0x4024000000000000
movq %rax, 0x18(%rsp)
leaq 0x8(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x110606
leaq 0x129d32(%rip), %rsi    # 0x23a07e
leaq 0x1b8(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x1102b8
leaq 0x8(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
leaq 0x20(%rsp), %rdx
xorl %ecx, %ecx
callq 0x11062a
leaq 0x1b8(%rsp), %rdi
callq 0x10e5b8
leaq 0x12a5fa(%rip), %rsi    # 0x23a985
leaq 0x1b8(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x1102b8
leaq 0x8(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x11062a
leaq 0x1b8(%rsp), %rdi
callq 0x10e5b8
leaq 0x12b11e(%rip), %rsi    # 0x23b4e8
leaq 0x1b8(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x1102b8
leaq 0x8(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
leaq 0x18(%rsp), %rdx
xorl %ecx, %ecx
callq 0x11062a
leaq 0x1b8(%rsp), %rdi
callq 0x10e5b8
leaq 0x8(%rsp), %rdi
callq 0x110696
leaq 0x28(%rsp), %rdi
callq 0x1106bc
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x11071c
leaq 0x68(%rsp), %rdi
pushq $0x7f
popq %rsi
callq 0x110778
leaq 0x1b8(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x110888
leaq 0x68(%rsp), %rdi
callq 0x110ea0
leaq 0x1b8(%rsp), %rdi
leaq 0x48(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x110ee8
movsd 0x124b9b(%rip), %xmm0   # 0x235008
leaq 0x129e4e(%rip), %rbx    # 0x23a2c2
movsd %xmm0, 0x10(%rsp)
movsd 0x124b8e(%rip), %xmm1   # 0x235010
ucomisd %xmm0, %xmm1
jb 0x1104bb
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movapd %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
movb $0x2, %al
callq 0x10e060
movsd 0x10(%rsp), %xmm0
addsd 0x124b5f(%rip), %xmm0   # 0x235018
jmp 0x110474
leaq 0x1b8(%rsp), %rdi
callq 0x11136a
leaq 0x28(%rsp), %rdi
callq 0x1114a4
leaq 0x8(%rsp), %rdi
callq 0x1114ba
leaq 0x48(%rsp), %rdi
callq 0x10e5b8
addq $0xae0, %rsp            # imm = 0xAE0
popq %rbx
retq
jmp 0x11052f
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x110ea0
jmp 0x11053f
jmp 0x110502
movq %rax, %rbx
jmp 0x11053f
jmp 0x110525
jmp 0x110525
jmp 0x110513
jmp 0x110525
jmp 0x110513
jmp 0x110525
movq %rax, %rbx
leaq 0x1b8(%rsp), %rdi
callq 0x10e5b8
jmp 0x110549
movq %rax, %rbx
jmp 0x110549
movq %rax, %rbx
jmp 0x110553
movq %rax, %rbx
leaq 0x1b8(%rsp), %rdi
callq 0x11136a
leaq 0x28(%rsp), %rdi
callq 0x1114a4
leaq 0x8(%rsp), %rdi
callq 0x1114ba
leaq 0x48(%rsp), %rdi
callq 0x10e5b8
movq %rbx, %rdi
callq 0x10e310