// File: /workspace/github_cpp_makefile_star2_O3/ArashPartow[P]exprtk/exprtk_simple_example_04.cpp
// Function: void fibonacci<double>()
void fibonacci()
{
   typedef exprtk::symbol_table<T>         symbol_table_t;
   typedef exprtk::expression<T>           expression_t;
   typedef exprtk::parser<T>               parser_t;
   typedef exprtk::function_compositor<T>  compositor_t;
   typedef typename compositor_t::function function_t;

   T x = T(0);

   compositor_t compositor;

   compositor.add(
      function_t("fibonacci")
      .var("x")
      .expression
      (
         " switch                      "
         " {                           "
         "    case x == 0 : 0;         "
         "    case x == 1 : 1;         "
         "    default     :            "
         "    {                        "
         "       var prev := 0;        "
         "       var curr := 1;        "
         "       while ((x -= 1) > 0)  "
         "       {                     "
         "          var temp := prev;  "
         "          prev := curr;      "
         "          curr += temp;      "
         "       };                    "
         "    };                       "
         " }                           "
      ));

   symbol_table_t& symbol_table = compositor.symbol_table();
   symbol_table.add_constants();
   symbol_table.add_variable("x",x);

   std::string expression_str = "fibonacci(x)";

   expression_t expression;
   expression.register_symbol_table(symbol_table);

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

   for (std::size_t i = 0; i < 40; ++i)
   {
      x = static_cast<T>(i);

      const T result = expression.value();

      printf("fibonacci(%3d) = %10.0f\n",
             static_cast<int>(i),
             result);
   }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x14a8, %rsp           # imm = 0x14A8
movq $0x0, 0x40(%rsp)
leaq 0xac0(%rsp), %rdi
callq 0x119a1a
leaq 0x58(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x19649d(%rip), %rsi    # 0x2af959
leaq 0x19649f(%rip), %rdx    # 0x2af962
leaq 0x48(%rsp), %rdi
callq 0x119984
leaq 0x198(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x119ba4
leaq 0x30(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x1963c1(%rip), %rsi    # 0x2af8b1
leaq 0x1963bb(%rip), %rdx    # 0x2af8b2
leaq 0x20(%rsp), %rdi
callq 0x119984
leaq 0x1d8(%rsp), %rbx
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x12651e
leaq 0x10(%rsp), %rbp
movq %rbp, -0x10(%rbp)
leaq 0x19643d(%rip), %rsi    # 0x2af963
leaq 0x196606(%rip), %rdx    # 0x2afb33
movq %rsp, %rdi
callq 0x119984
leaq 0x1b8(%rsp), %r15
movq %rsp, %rsi
movq %r15, %rdi
callq 0x116520
leaq 0x13f0(%rsp), %r14
leaq 0x198(%rsp), %rsi
movq %r14, %rdi
callq 0x11dc82
leaq 0x13f8(%rsp), %rcx
cmpq %rax, %rcx
jne 0x11961a
leaq 0xac0(%rsp), %rdi
leaq 0x198(%rsp), %rsi
movq %r15, %rdx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x11c9e8
testb %al, %al
je 0x11961a
leaq 0x198(%rsp), %rsi
movq 0x88(%rsi), %rax
movq %rax, %rcx
subq 0x68(%rsi), %rcx
shrq $0x3, %rcx
cmpq $0x1, %rax
adcq $-0x1, %rcx
movq 0x60(%rsi), %rax
movq 0x70(%rsi), %rdx
subq 0x78(%rsi), %rdx
subq 0x50(%rsi), %rax
sarq $0x5, %rdx
sarq $0x5, %rax
leaq (%rcx,%rcx,2), %rcx
shlq $0x8, %rcx
addq 0x1420(%rsp), %rcx
leaq (%rdx,%rdx,2), %rdx
shlq $0x4, %rdx
leaq (%rax,%rax,2), %rdi
shlq $0x4, %rdi
addq %rdx, %rdi
addq %rcx, %rdi
callq 0x11d8a6
movq (%rax), %r15
leaq 0x198(%rsp), %rsi
movq %r14, %rdi
callq 0x11dc06
movq %r15, %rdi
movq %rax, %rsi
callq 0x11d922
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x119630
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x116090
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x119647
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x116090
movq %rbx, %rdi
callq 0x1267b8
leaq 0x1c8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x119670
movq 0x1c8(%rsp), %rsi
incq %rsi
callq 0x116090
leaq 0x1a8(%rsp), %r14
movq -0x10(%r14), %rdi
cmpq %r14, %rdi
je 0x119691
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x116090
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
je 0x1196a8
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x116090
leaq 0xac0(%rsp), %rdi
callq 0x119c7e
leaq 0x198(%rsp), %rdi
movq %r14, (%rdi)
leaq 0x1961ea(%rip), %rsi    # 0x2af8b1
leaq 0x1961e4(%rip), %rdx    # 0x2af8b2
callq 0x119984
leaq 0xac0(%rsp), %rbx
leaq 0x198(%rsp), %rsi
leaq 0x40(%rsp), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x119dc4
movq 0x198(%rsp), %rdi
cmpq %r14, %rdi
je 0x11970f
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x116090
leaq 0x20(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x196416(%rip), %rsi    # 0x2afb34
leaq 0x19641b(%rip), %rdx    # 0x2afb40
callq 0x119984
movq %rsp, %rdi
callq 0x119f14
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
subq %rax, %rcx
je 0x119768
sarq $0x3, %rcx
movq 0xac0(%rsp), %rdx
cmpq $0x1, %rcx
adcq $0x0, %rcx
cmpq %rbx, %rax
je 0x11977a
cmpq (%rax), %rdx
je 0x11977a
addq $0x8, %rax
decq %rcx
jne 0x119755
leaq 0x8(%rsp), %rdi
leaq 0xac0(%rsp), %rsi
callq 0x127466
leaq 0x48(%rsp), %rdi
movl $0x7f, %esi
callq 0x119fa0
leaq 0x198(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x11a0a0
leaq 0x148(%rsp), %rdi
callq 0x12764c
leaq 0x118(%rsp), %rdi
callq 0x12764c
leaq 0xe8(%rsp), %rdi
callq 0x12764c
leaq 0xb8(%rsp), %rdi
callq 0x12764c
leaq 0x88(%rsp), %rdi
callq 0x12764c
leaq 0x58(%rsp), %rdi
callq 0x12764c
leaq 0x198(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq %rsp, %rdx
callq 0x11a8c4
xorl %ebx, %ebx
leaq 0x19633d(%rip), %r14    # 0x2afb41
xorps %xmm0, %xmm0
cvtsi2sd %rbx, %xmm0
movsd %xmm0, 0x40(%rsp)
movq (%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movq %r14, %rdi
movl %ebx, %esi
movb $0x1, %al
callq 0x116050
incq %rbx
cmpq $0x28, %rbx
jne 0x119804
leaq 0x198(%rsp), %rdi
callq 0x11b460
movq %rsp, %rdi
callq 0x11b722
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x119861
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x116090
leaq 0xac0(%rsp), %rdi
callq 0x11b770
addq $0x14a8, %rsp           # imm = 0x14A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x119899
jmp 0x119934
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x11a87c
jmp 0x119944
movq %rax, %rbx
jmp 0x119944
movq %rax, %rbx
jmp 0x11994c
jmp 0x1198e1
movq %rax, %rbx
movq 0x198(%rsp), %rdi
cmpq %r14, %rdi
je 0x119963
movq 0x1a8(%rsp), %rsi
jmp 0x11995b
jmp 0x1198e1
jmp 0x1198e1
jmp 0x1198d2
movq %rax, %rbx
jmp 0x1198ff
movq %rax, %rbx
jmp 0x119916
movq %rax, %rbx
jmp 0x119923
movq %rax, %rbx
jmp 0x119963
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x1198ff
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x116090
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x119916
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x116090
leaq 0x198(%rsp), %rdi
callq 0x119c3e
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
je 0x119963
movq 0x58(%rsp), %rsi
jmp 0x11995b
movq %rax, %rbx
leaq 0x198(%rsp), %rdi
callq 0x11b460
movq %rsp, %rdi
callq 0x11b722
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x119963
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x116090
leaq 0xac0(%rsp), %rdi
callq 0x11b770
movq %rbx, %rdi
callq 0x1162e0