// File: /workspace/github_cpp_makefile_star2_O1/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 0x11ba96
leaq 0x58(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x1b83cc(%rip), %rsi    # 0x2d38e1
leaq 0x1b83ce(%rip), %rdx    # 0x2d38ea
leaq 0x48(%rsp), %rdi
callq 0x11ba06
leaq 0x198(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x11bc20
leaq 0x30(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x1b82f0(%rip), %rsi    # 0x2d3839
leaq 0x1b82ea(%rip), %rdx    # 0x2d383a
leaq 0x20(%rsp), %rdi
callq 0x11ba06
leaq 0x1d8(%rsp), %rbx
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x129f4c
leaq 0x10(%rsp), %rbp
movq %rbp, -0x10(%rbp)
leaq 0x1b836c(%rip), %rsi    # 0x2d38eb
leaq 0x1b8535(%rip), %rdx    # 0x2d3abb
movq %rsp, %rdi
callq 0x11ba06
leaq 0x1b8(%rsp), %r15
movq %rsp, %rsi
movq %r15, %rdi
callq 0x118520
leaq 0x13f0(%rsp), %r14
leaq 0x198(%rsp), %rsi
movq %r14, %rdi
callq 0x11fb50
leaq 0x13f8(%rsp), %rcx
cmpq %rax, %rcx
jne 0x11b673
leaq 0xac0(%rsp), %rdi
leaq 0x198(%rsp), %rsi
movq %r15, %rdx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x11e8ae
testb %al, %al
je 0x11b673
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 0x11f780
movq (%rax), %r15
leaq 0x198(%rsp), %rsi
movq %r14, %rdi
callq 0x11fad4
movq %r15, %rdi
movq %rax, %rsi
callq 0x11f7fc
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x11b689
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x118090
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x11b6a0
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x118090
movq %rbx, %rdi
callq 0x12a1e6
leaq 0x1c8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x11b6c9
movq 0x1c8(%rsp), %rsi
incq %rsi
callq 0x118090
leaq 0x1a8(%rsp), %r14
movq -0x10(%r14), %rdi
cmpq %r14, %rdi
je 0x11b6ea
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x118090
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
je 0x11b701
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x118090
leaq 0xac0(%rsp), %rdi
callq 0x11bcfa
leaq 0x198(%rsp), %rdi
movq %r14, (%rdi)
leaq 0x1b8119(%rip), %rsi    # 0x2d3839
leaq 0x1b8113(%rip), %rdx    # 0x2d383a
callq 0x11ba06
leaq 0xac0(%rsp), %rbx
leaq 0x198(%rsp), %rsi
leaq 0x40(%rsp), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x11be40
movq 0x198(%rsp), %rdi
cmpq %r14, %rdi
je 0x11b768
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x118090
leaq 0x20(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x1b8345(%rip), %rsi    # 0x2d3abc
leaq 0x1b834a(%rip), %rdx    # 0x2d3ac8
callq 0x11ba06
movq %rsp, %rdi
callq 0x11bfae
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %rax
subq %rcx, %rax
je 0x11b7ea
sarq $0x3, %rax
cmpq $0x1, %rax
movq %rax, %rsi
adcq $0x0, %rsi
cmpq %rbx, %rcx
je 0x11b7fc
movq 0xac0(%rsp), %rdx
cmpq (%rcx), %rdx
je 0x11b7fc
addq $0x8, %rcx
movl $0x1, %edi
subq %rsi, %rdi
xorl %esi, %esi
cmpq %rsi, %rdi
je 0x11b7ea
decq %rsi
cmpq %rbx, %rcx
je 0x11b7e2
leaq 0x8(%rcx), %r8
cmpq (%rcx), %rdx
movq %r8, %rcx
jne 0x11b7c9
negq %rsi
cmpq %rax, %rsi
jb 0x11b7fc
leaq 0x8(%rsp), %rdi
leaq 0xac0(%rsp), %rsi
callq 0x12b386
leaq 0x48(%rsp), %rdi
movl $0x7f, %esi
callq 0x11c048
leaq 0x198(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x11c148
leaq 0x148(%rsp), %rdi
callq 0x12b56c
leaq 0x118(%rsp), %rdi
callq 0x12b56c
leaq 0xe8(%rsp), %rdi
callq 0x12b56c
leaq 0xb8(%rsp), %rdi
callq 0x12b56c
leaq 0x88(%rsp), %rdi
callq 0x12b56c
leaq 0x58(%rsp), %rdi
callq 0x12b56c
leaq 0x198(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq %rsp, %rdx
callq 0x11c96c
xorl %ebx, %ebx
leaq 0x1b8243(%rip), %r14    # 0x2d3ac9
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 0x118050
incq %rbx
cmpq $0x28, %rbx
jne 0x11b886
leaq 0x198(%rsp), %rdi
callq 0x11d33e
movq %rsp, %rdi
callq 0x11d600
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x11b8e3
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x118090
leaq 0xac0(%rsp), %rdi
callq 0x11d64e
addq $0x14a8, %rsp           # imm = 0x14A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x11b91b
jmp 0x11b9b6
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x11c924
jmp 0x11b9c6
movq %rax, %rbx
jmp 0x11b9c6
movq %rax, %rbx
jmp 0x11b9ce
jmp 0x11b963
movq %rax, %rbx
movq 0x198(%rsp), %rdi
cmpq %r14, %rdi
je 0x11b9e5
movq 0x1a8(%rsp), %rsi
jmp 0x11b9dd
jmp 0x11b963
jmp 0x11b963
jmp 0x11b954
movq %rax, %rbx
jmp 0x11b981
movq %rax, %rbx
jmp 0x11b998
movq %rax, %rbx
jmp 0x11b9a5
movq %rax, %rbx
jmp 0x11b9e5
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x11b981
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x118090
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x11b998
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x118090
leaq 0x198(%rsp), %rdi
callq 0x11bcba
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
je 0x11b9e5
movq 0x58(%rsp), %rsi
jmp 0x11b9dd
movq %rax, %rbx
leaq 0x198(%rsp), %rdi
callq 0x11d33e
movq %rsp, %rdi
callq 0x11d600
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x11b9e5
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x118090
leaq 0xac0(%rsp), %rdi
callq 0x11d64e
movq %rbx, %rdi
callq 0x1182e0