// File: /workspace/github_cpp_makefile_star2_O2/ArashPartow[P]exprtk-extras/exprtk_calc.cpp
// Function: main
int main()
{
   typedef exprtk::symbol_table<double> symbol_table_t;
   typedef exprtk::expression<double>   expression_t;
   typedef exprtk::parser<double>       parser_t;
   typedef exprtk::parser_error::type   err_t;

   for ( ; ; )
   {
      double x = 1.0;
      double y = 2.0;
      double z = 3.0;
      double w = 4.0;
      double u = 5.0;
      double v = 6.0;

      symbol_table_t symbol_table;
      symbol_table.add_variable("x",x);
      symbol_table.add_variable("y",y);
      symbol_table.add_variable("z",z);
      symbol_table.add_variable("w",w);
      symbol_table.add_variable("u",u);
      symbol_table.add_variable("v",v);
      symbol_table.add_constants();

      expression_t expression;
      expression.register_symbol_table(symbol_table);

      std::string expression_str;

      printf(">> ");
      std::getline(std::cin,expression_str);

      if (expression_str.empty())
         continue;
      else if ("exit" == expression_str)
         break;
      else if ("quit" == expression_str)
         break;

      parser_t parser;

      if (!parser.compile(expression_str,expression))
      {
         printf("Error: %s\tExpression: %s\n",
                parser.error().c_str(),
                expression_str.c_str());

         for (std::size_t i = 0; i < parser.error_count(); ++i)
         {
            err_t error = parser.get_error(i);
            printf("Error: %02d Pos: %02d Type: [%14s] Message: %s\tExpression: %s\n",
                   static_cast<unsigned int>(i),
                   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;
      }

      double result = expression.value();

      printf("result: %20.10f\n",result);
   }

   return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb18, %rsp            # imm = 0xB18
leaq 0x28(%rsp), %r14
leaq 0x1f0(%rsp), %r12
leaq 0xa0(%rsp), %r13
leaq 0x80(%rsp), %rbx
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x58(%rsp)
movabsq $0x4000000000000000, %rax # imm = 0x4000000000000000
movq %rax, 0x50(%rsp)
movabsq $0x4008000000000000, %rax # imm = 0x4008000000000000
movq %rax, 0x48(%rsp)
movabsq $0x4010000000000000, %rax # imm = 0x4010000000000000
movq %rax, 0x40(%rsp)
movabsq $0x4014000000000000, %rax # imm = 0x4014000000000000
movq %rax, 0x38(%rsp)
movabsq $0x4018000000000000, %rax # imm = 0x4018000000000000
movq %rax, 0x30(%rsp)
movq %r14, %rdi
pushq $0x1
popq %rsi
callq 0x11073a
movq %r12, %rdi
leaq 0x12ad9c(%rip), %rsi    # 0x23b085
movq %r13, %rdx
callq 0x1106fe
movq %r14, %rdi
movq %r12, %rsi
leaq 0x58(%rsp), %rdx
xorl %ecx, %ecx
callq 0x11075e
leaq 0x60(%rsp), %rbp
movq %r12, %rdi
callq 0x10e5d8
movq %r12, %rdi
leaq 0x12aff3(%rip), %rsi    # 0x23b30d
movq %r13, %rdx
callq 0x1106fe
movq %r14, %rdi
movq %r12, %rsi
leaq 0x50(%rsp), %rdx
xorl %ecx, %ecx
callq 0x11075e
movq %r12, %rdi
callq 0x10e5d8
movq %r12, %rdi
leaq 0x12adbd(%rip), %rsi    # 0x23b103
movq %r13, %rdx
callq 0x1106fe
movq %r14, %rdi
movq %r12, %rsi
leaq 0x48(%rsp), %rdx
xorl %ecx, %ecx
callq 0x11075e
movq %r12, %rdi
callq 0x10e5d8
movq %r12, %rdi
leaq 0x12ad36(%rip), %rsi    # 0x23b0a8
movq %r13, %rdx
callq 0x1106fe
movq %r14, %rdi
movq %r12, %rsi
leaq 0x40(%rsp), %rdx
xorl %ecx, %ecx
callq 0x11075e
movq %r12, %rdi
callq 0x10e5d8
movq %r12, %rdi
leaq 0x12ad67(%rip), %rsi    # 0x23b105
movq %r13, %rdx
callq 0x1106fe
movq %r14, %rdi
movq %r12, %rsi
leaq 0x38(%rsp), %rdx
xorl %ecx, %ecx
callq 0x11075e
movq %r12, %rdi
callq 0x10e5d8
movq %r12, %rdi
leaq 0x12ad3d(%rip), %rsi    # 0x23b107
movq %r13, %rdx
callq 0x1106fe
movq %r14, %rdi
movq %r12, %rsi
leaq 0x30(%rsp), %rdx
xorl %ecx, %ecx
callq 0x11075e
movq %r12, %rdi
callq 0x10e5d8
movq %r14, %rdi
callq 0x1107ca
movq %rbp, %rdi
callq 0x1107f0
movq %rbp, %rdi
movq %r14, %rsi
callq 0x110850
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
andq $0x0, 0x10(%rsp)
movb $0x0, 0x18(%rsp)
leaq 0x12ace6(%rip), %rdi    # 0x23b109
xorl %eax, %eax
callq 0x10e060
movq 0x2b3bb7(%rip), %rdi    # 0x3c3fe8
leaq 0x8(%rsp), %rsi
callq 0x10e260
cmpq $0x0, 0x10(%rsp)
je 0x1104d1
leaq 0x12acbf(%rip), %rdi    # 0x23b10d
leaq 0x8(%rsp), %r15
movq %r15, %rsi
callq 0x1108ab
movb $0x1, %bpl
testb %al, %al
jne 0x1104d3
leaq 0x12aca9(%rip), %rdi    # 0x23b112
movq %r15, %rsi
callq 0x1108ab
testb %al, %al
jne 0x1104d3
movq %r13, %rdi
pushq $0x7f
popq %rsi
callq 0x1108c2
movq %r12, %rdi
movq %r13, %rsi
callq 0x1109d2
leaq 0x60(%rsp), %rbp
movq %r13, %rdi
callq 0x110fea
movq %r12, %rdi
leaq 0x8(%rsp), %rsi
movq %rbp, %rdx
callq 0x111032
testb %al, %al
je 0x1104fd
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
leaq 0x12acae(%rip), %rdi    # 0x23b170
movb $0x1, %al
callq 0x10e060
movq %r12, %rdi
callq 0x111674
xorl %ebp, %ebp
leaq 0x8(%rsp), %rdi
callq 0x10e5d8
leaq 0x60(%rsp), %rdi
callq 0x1117ae
movq %r14, %rdi
callq 0x1117c4
testb %bpl, %bpl
je 0x11027a
jmp 0x1105ae
movq %r13, %rdi
movq %r12, %rsi
callq 0x1114b4
movq 0xa0(%rsp), %rsi
movq 0x8(%rsp), %rdx
leaq 0x12abfb(%rip), %rdi    # 0x23b117
xorl %eax, %eax
callq 0x10e060
movq %r13, %rdi
callq 0x10e5d8
xorl %r15d, %r15d
movq %r15, (%rsp)
leaq 0x4f8(%rsp), %rdi
callq 0x1729ae
cmpq %rax, %r15
jae 0x1104c9
movq %r13, %rdi
movq %r12, %rsi
movq %rsp, %rdx
callq 0x111508
movq (%rsp), %rbp
movq 0xc8(%rsp), %r15
movl 0xd0(%rsp), %esi
movq %rbx, %rdi
callq 0x11159c
movq 0x80(%rsp), %rcx
movq 0xd8(%rsp), %r8
movq 0x8(%rsp), %r9
leaq 0x12aba8(%rip), %rdi    # 0x23b131
movl %ebp, %esi
movl %r15d, %edx
xorl %eax, %eax
callq 0x10e060
movq %rbx, %rdi
callq 0x10e5d8
movq %r13, %rdi
callq 0x111648
movq (%rsp), %r15
incq %r15
jmp 0x11052e
xorl %eax, %eax
addq $0xb18, %rsp            # imm = 0xB18
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x110615
jmp 0x110615
jmp 0x110615
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x110fea
jmp 0x110637
jmp 0x110610
jmp 0x110606
jmp 0x1105f2
jmp 0x110606
jmp 0x1105f2
jmp 0x110606
jmp 0x1105f2
jmp 0x110606
jmp 0x1105f2
jmp 0x110606
jmp 0x1105f2
jmp 0x110606
movq %rax, %rbx
leaq 0x1f0(%rsp), %rdi
callq 0x10e5d8
jmp 0x11064b
jmp 0x110606
movq %rax, %rbx
jmp 0x11064b
movq %rax, %rbx
jmp 0x110641
movq %rax, %rbx
jmp 0x110637
movq %rax, %rbx
jmp 0x11062a
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x111648
leaq 0x1f0(%rsp), %rdi
callq 0x111674
leaq 0x8(%rsp), %rdi
callq 0x10e5d8
leaq 0x60(%rsp), %rdi
callq 0x1117ae
leaq 0x28(%rsp), %rdi
callq 0x1117c4
movq %rbx, %rdi
callq 0x10e320