// File: /workspace/github_cpp_makefile_star2_O3/ArashPartow[P]exprtk-extras/exprtk_immutable_symbol_table_example.cpp
// Function: void immutable_symtab_example<double>()
void immutable_symtab_example()
{
   typedef exprtk::symbol_table<T> symbol_table_t;
   typedef exprtk::expression<T>   expression_t;
   typedef exprtk::parser<T>       parser_t;

   T x = 1.1;
   T y = 2.2;
   T z = 3.3;
   T w = 4.4;

   symbol_table_t mutable_symbol_table;
   symbol_table_t immutable_symbol_table(symbol_table_t::symtab_mutability_type::e_immutable);

   mutable_symbol_table.add_variable("x", x);
   mutable_symbol_table.add_variable("y", y);

   immutable_symbol_table.add_variable("z", z);
   immutable_symbol_table.add_variable("w", w);

   expression_t expression;
   expression.register_symbol_table(immutable_symbol_table);
   expression.register_symbol_table(mutable_symbol_table  );

   parser_t parser;

   const std::vector<std::string> expressions =
   {
      "x := y + (z / w)",     // ok - will compile
      "y := y / x + (z / w)", // ok - will compile
      "z := y + x - w",       // Error - will not compile
      "z ==  (w := y / x)",   // Error - will not compile
   };

   for (const auto& expression_str : expressions)
   {

      if (!parser.compile(expression_str, expression))
      {
         for (std::size_t error_idx = 0; error_idx < parser.error_count(); ++error_idx)
         {
            const auto error = parser.get_error(error_idx);

            printf("Error: %02d Pos: %02d Type: [%14s] Message: %s\tExpression: %s\n",
                   static_cast<unsigned int>(error_idx),
                   static_cast<unsigned int>(error.token.position),
                   exprtk::parser_error::to_str(error.mode).c_str(),
                   error.diagnostic.c_str(),
                   expression_str.c_str());
         }

         continue;
      }

      // Modify all the variables from both the immutable
      // and mutable symbol tables

      x += 1.1;
      y += 2.2;
      z += 3.3;
      w += 4.4;

      expression.value();
   }

   return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb08, %rsp            # imm = 0xB08
movabsq $0x3ff199999999999a, %rax # imm = 0x3FF199999999999A
movq %rax, 0x28(%rsp)
movabsq $0x400199999999999a, %rax # imm = 0x400199999999999A
movq %rax, 0x20(%rsp)
movabsq $0x400a666666666666, %rax # imm = 0x400A666666666666
movq %rax, 0x18(%rsp)
movabsq $0x401199999999999a, %rax # imm = 0x401199999999999A
movq %rax, 0x10(%rsp)
leaq 0x8(%rsp), %rdi
movl $0x1, %esi
callq 0x117b28
movq %rsp, %rdi
movl $0x2, %esi
callq 0x117b28
leaq 0x1f0(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x18e558(%rip), %rsi    # 0x2a58d9
leaq 0x18e552(%rip), %rdx    # 0x2a58da
leaq 0x1e0(%rsp), %rdi
callq 0x117a92
leaq 0x8(%rsp), %rdi
leaq 0x1e0(%rsp), %rsi
leaq 0x28(%rsp), %rdx
xorl %ecx, %ecx
callq 0x117b70
movq 0x1e0(%rsp), %rdi
cmpq %r14, %rdi
je 0x1173cb
movq 0x1f0(%rsp), %rsi
incq %rsi
callq 0x114090
leaq 0x1e0(%rsp), %rdi
movq %r14, (%rdi)
leaq 0x18e70a(%rip), %rsi    # 0x2a5ae7
leaq 0x18e704(%rip), %rdx    # 0x2a5ae8
callq 0x117a92
leaq 0x8(%rsp), %rbx
leaq 0x1e0(%rsp), %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x117b70
movq 0x1e0(%rsp), %rdi
cmpq %r14, %rdi
je 0x117422
movq 0x1f0(%rsp), %rsi
incq %rsi
callq 0x114090
leaq 0x1e0(%rsp), %rdi
movq %r14, (%rdi)
leaq 0x18e54d(%rip), %rsi    # 0x2a5981
leaq 0x18e547(%rip), %rdx    # 0x2a5982
callq 0x117a92
movq %rsp, %rdi
leaq 0x1e0(%rsp), %rsi
leaq 0x18(%rsp), %rdx
xorl %ecx, %ecx
callq 0x117b70
movq 0x1e0(%rsp), %rdi
cmpq %r14, %rdi
je 0x117474
movq 0x1f0(%rsp), %rsi
incq %rsi
callq 0x114090
leaq 0x1e0(%rsp), %rdi
movq %r14, (%rdi)
leaq 0x18e530(%rip), %rsi    # 0x2a59b6
leaq 0x18e52a(%rip), %rdx    # 0x2a59b7
callq 0x117a92
movq %rsp, %r15
leaq 0x1e0(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x117b70
movq 0x1e0(%rsp), %rdi
cmpq %r14, %rdi
je 0x1174c9
movq 0x1f0(%rsp), %rsi
incq %rsi
callq 0x114090
leaq 0x38(%rsp), %rdi
callq 0x117cc0
leaq 0x40(%rsp), %r14
movq (%r14), %rax
movq 0x8(%r14), %rcx
movq %rcx, %rdx
subq %rax, %rdx
je 0x11750d
sarq $0x3, %rdx
movq (%rsp), %rsi
cmpq $0x1, %rdx
adcq $0x0, %rdx
movq %rax, %rdi
cmpq %r15, %rdi
je 0x117522
cmpq (%rdi), %rsi
je 0x117522
addq $0x8, %rdi
decq %rdx
jne 0x1174fa
movq %rsp, %rsi
movq %r14, %rdi
callq 0x11bfd2
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rcx
subq %rax, %rcx
je 0x11754b
sarq $0x3, %rcx
movq 0x8(%rsp), %rdx
cmpq $0x1, %rcx
adcq $0x0, %rcx
cmpq %rbx, %rax
je 0x117558
cmpq (%rax), %rdx
je 0x117558
addq $0x8, %rax
decq %rcx
jne 0x117538
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x11bfd2
leaq 0x90(%rsp), %rdi
movl $0x7f, %esi
callq 0x117d4c
leaq 0x1e0(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x117e4c
leaq 0x190(%rsp), %rdi
callq 0x11c1d4
leaq 0x160(%rsp), %rdi
callq 0x11c1d4
leaq 0x130(%rsp), %rdi
callq 0x11c1d4
leaq 0x100(%rsp), %rbx
movq %rbx, %rdi
callq 0x11c1d4
leaq 0xd0(%rsp), %r12
movq %r12, %rdi
callq 0x11c1d4
leaq 0xa0(%rsp), %r14
movq %r14, %rdi
callq 0x11c1d4
movq %r14, -0x10(%r14)
leaq 0x18e3a2(%rip), %rsi    # 0x2a5983
leaq 0x18e3ab(%rip), %rdx    # 0x2a5993
leaq 0x90(%rsp), %r14
movq %r14, %rdi
callq 0x117a92
leaq 0xb0(%rsp), %r15
leaq 0xc0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x18e381(%rip), %rsi    # 0x2a5994
leaq 0x18e38e(%rip), %rdx    # 0x2a59a8
movq %r15, %rdi
callq 0x117a92
leaq 0xe0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x18e374(%rip), %rsi    # 0x2a59a9
leaq 0x18e37b(%rip), %rdx    # 0x2a59b7
movq %r12, %rdi
callq 0x117a92
leaq 0xf0(%rsp), %r15
movq %rbx, (%r15)
leaq 0x18e362(%rip), %rsi    # 0x2a59b8
leaq 0x18e36d(%rip), %rdx    # 0x2a59ca
movq %r15, %rdi
callq 0x117a92
leaq 0x58(%rsp), %rdi
leaq 0x90(%rsp), %rsi
leaq 0x70(%rsp), %rcx
movl $0x4, %edx
callq 0x118670
movq $-0x80, %r14
movq -0x10(%rbx), %rdi
cmpq %rdi, %rbx
je 0x11769c
movq (%rbx), %rsi
incq %rsi
callq 0x114090
addq $-0x20, %rbx
addq $0x20, %r14
jne 0x117688
movq 0x58(%rsp), %rbx
movq 0x60(%rsp), %rax
movq %rax, 0x30(%rsp)
cmpq %rax, %rbx
je 0x117943
movabsq $-0x30c30c30c30c30c3, %r12 # imm = 0xCF3CF3CF3CF3CF3D
leaq 0x1e0(%rsp), %rdi
movq %rbx, %rsi
leaq 0x38(%rsp), %rdx
callq 0x1186b8
testb %al, %al
je 0x117754
movsd 0x28(%rsp), %xmm0
addsd 0x189919(%rip), %xmm0   # 0x2a1008
movsd %xmm0, 0x28(%rsp)
movsd 0x20(%rsp), %xmm0
addsd 0x18990d(%rip), %xmm0   # 0x2a1010
movsd %xmm0, 0x20(%rsp)
movsd 0x18(%rsp), %xmm0
addsd 0x189901(%rip), %xmm0   # 0x2a1018
movsd %xmm0, 0x18(%rsp)
movsd 0x10(%rsp), %xmm0
addsd 0x1898f5(%rip), %xmm0   # 0x2a1020
movsd %xmm0, 0x10(%rsp)
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
addq $0x20, %rbx
cmpq 0x30(%rsp), %rbx
jne 0x1176c8
jmp 0x117943
movq $-0x1, %r13
xorl %ebp, %ebp
xorl %r14d, %r14d
movq 0x530(%rsp), %rax
movq 0x510(%rsp), %rdi
movq %rax, %rcx
subq %rdi, %rcx
sarq $0x3, %rcx
cmpq $0x1, %rax
adcq $-0x1, %rcx
leaq (%rcx,%rcx,2), %rax
movq 0x518(%rsp), %rcx
subq 0x520(%rsp), %rcx
sarq $0x3, %rcx
imulq %r12, %rcx
addq %rax, %rcx
movq 0x4f8(%rsp), %rsi
movq 0x508(%rsp), %rax
subq %rsi, %rax
sarq $0x3, %rax
imulq %r12, %rax
addq %rcx, %rax
cmpq %rax, %r14
jae 0x117740
movq %rsi, %rdx
subq 0x500(%rsp), %rdx
sarq $0x3, %rdx
imulq %r12, %rdx
movq %r14, %rcx
addq %rdx, %rcx
js 0x1177ee
cmpq $0x2, %rcx
ja 0x117809
addq %rbp, %rsi
jmp 0x117831
movq %r13, %rax
subq %rdx, %rax
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
mulq %rdx
shrq %rdx
notq %rdx
jmp 0x11781c
movq %rcx, %rax
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
mulq %rdx
shrq %rdx
imulq $-0x1f8, %rdx, %rax     # imm = 0xFE08
addq (%rdi,%rdx,8), %rax
imulq $0xa8, %rcx, %rsi
addq %rax, %rsi
leaq 0x90(%rsp), %rdi
callq 0x17e42e
movq 0xb8(%rsp), %r15
movl 0xc0(%rsp), %esi
leaq 0x70(%rsp), %rdi
callq 0x119253
movq 0x70(%rsp), %rcx
movq 0xc8(%rsp), %r8
movq (%rbx), %r9
leaq 0x18e15d(%rip), %rdi    # 0x2a59cb
movl %r14d, %esi
movl %r15d, %edx
xorl %eax, %eax
callq 0x114050
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x11789d
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x114090
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0x1178c2
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x114090
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0x1178e7
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x114090
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x11790c
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x114090
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x117931
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x114090
incq %r14
addq $0xa8, %rbp
decq %r13
jmp 0x117760
leaq 0x58(%rsp), %rdi
callq 0x11936a
leaq 0x1e0(%rsp), %rdi
callq 0x1193c8
leaq 0x38(%rsp), %rdi
callq 0x11968a
movq %rsp, %rdi
callq 0x1196d8
leaq 0x8(%rsp), %rdi
callq 0x1196d8
addq $0xb08, %rsp            # imm = 0xB08
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x114580
jmp 0x117a55
jmp 0x1179af
movq %rax, %rbx
movq %r12, %r15
jmp 0x1179b2
movq %rax, %rbx
addq $-0x10, %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x1179ca
movq (%r15), %rsi
incq %rsi
callq 0x114090
leaq -0x20(%r15), %rax
addq $-0x10, %r15
cmpq %r14, %r15
movq %rax, %r15
jne 0x1179b6
jmp 0x117a55
movq %rax, %rbx
jmp 0x117a55
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x118628
jmp 0x117a62
jmp 0x117a2f
jmp 0x117a25
jmp 0x117a03
jmp 0x117a25
jmp 0x117a03
jmp 0x117a25
jmp 0x117a03
jmp 0x117a25
movq %rax, %rbx
movq 0x1e0(%rsp), %rdi
cmpq %r14, %rdi
je 0x117a6c
movq 0x1f0(%rsp), %rsi
incq %rsi
callq 0x114090
jmp 0x117a6c
movq %rax, %rbx
jmp 0x117a6c
movq %rax, %rbx
jmp 0x117a74
movq %rax, %rbx
jmp 0x117a62
jmp 0x117a36
movq %rax, %rbx
jmp 0x117a4b
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x119300
leaq 0x58(%rsp), %rdi
callq 0x11936a
leaq 0x1e0(%rsp), %rdi
callq 0x1193c8
leaq 0x38(%rsp), %rdi
callq 0x11968a
movq %rsp, %rdi
callq 0x1196d8
leaq 0x8(%rsp), %rdi
callq 0x1196d8
movq %rbx, %rdi
callq 0x1142e0