// File: 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:
subq $0xd78, %rsp            # imm = 0xD78
movl $0x0, 0xd74(%rsp)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0xd68(%rsp)
movabsq $0x4000000000000000, %rax # imm = 0x4000000000000000
movq %rax, 0xd60(%rsp)
movabsq $0x4008000000000000, %rax # imm = 0x4008000000000000
movq %rax, 0xd58(%rsp)
movabsq $0x4010000000000000, %rax # imm = 0x4010000000000000
movq %rax, 0xd50(%rsp)
movabsq $0x4014000000000000, %rax # imm = 0x4014000000000000
movq %rax, 0xd48(%rsp)
movabsq $0x4018000000000000, %rax # imm = 0x4018000000000000
movq %rax, 0xd40(%rsp)
leaq 0xd38(%rsp), %rdi
movl $0x1, %esi
callq 0x1191c0
leaq 0xd17(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x111660
movq 0x78(%rsp), %rdx
leaq 0x32fe9f(%rip), %rsi    # 0x4484cd
leaq 0xd18(%rsp), %rdi
callq 0x119100
jmp 0x11863d
leaq 0xd38(%rsp), %rdi
leaq 0xd18(%rsp), %rsi
leaq 0xd68(%rsp), %rdx
xorl %ecx, %ecx
callq 0x119200
jmp 0x11865e
leaq 0xd18(%rsp), %rdi
callq 0x1117a8
leaq 0xd17(%rsp), %rdi
callq 0x111790
leaq 0xcdf(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0x111660
movq 0x70(%rsp), %rdx
leaq 0x32feb5(%rip), %rsi    # 0x44854b
leaq 0xce0(%rsp), %rdi
callq 0x119100
jmp 0x1186a5
leaq 0xd38(%rsp), %rdi
leaq 0xce0(%rsp), %rsi
leaq 0xd60(%rsp), %rdx
xorl %ecx, %ecx
callq 0x119200
jmp 0x1186c6
leaq 0xce0(%rsp), %rdi
callq 0x1117a8
leaq 0xcdf(%rsp), %rdi
callq 0x111790
leaq 0xcb7(%rsp), %rdi
movq %rdi, 0x68(%rsp)
callq 0x111660
movq 0x68(%rsp), %rdx
leaq 0x32fe4f(%rip), %rsi    # 0x44854d
leaq 0xcb8(%rsp), %rdi
callq 0x119100
jmp 0x11870d
leaq 0xd38(%rsp), %rdi
leaq 0xcb8(%rsp), %rsi
leaq 0xd58(%rsp), %rdx
xorl %ecx, %ecx
callq 0x119200
jmp 0x11872e
leaq 0xcb8(%rsp), %rdi
callq 0x1117a8
leaq 0xcb7(%rsp), %rdi
callq 0x111790
leaq 0xc8f(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x111660
movq 0x60(%rsp), %rdx
leaq 0x32fd8a(%rip), %rsi    # 0x4484f0
leaq 0xc90(%rsp), %rdi
callq 0x119100
jmp 0x118775
leaq 0xd38(%rsp), %rdi
leaq 0xc90(%rsp), %rsi
leaq 0xd50(%rsp), %rdx
xorl %ecx, %ecx
callq 0x119200
jmp 0x118796
leaq 0xc90(%rsp), %rdi
callq 0x1117a8
leaq 0xc8f(%rsp), %rdi
callq 0x111790
leaq 0xc67(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x111660
movq 0x58(%rsp), %rdx
leaq 0x32fd81(%rip), %rsi    # 0x44854f
leaq 0xc68(%rsp), %rdi
callq 0x119100
jmp 0x1187dd
leaq 0xd38(%rsp), %rdi
leaq 0xc68(%rsp), %rsi
leaq 0xd48(%rsp), %rdx
xorl %ecx, %ecx
callq 0x119200
jmp 0x1187fe
leaq 0xc68(%rsp), %rdi
callq 0x1117a8
leaq 0xc67(%rsp), %rdi
callq 0x111790
leaq 0xc3f(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x111660
movq 0x50(%rsp), %rdx
leaq 0x32fd1b(%rip), %rsi    # 0x448551
leaq 0xc40(%rsp), %rdi
callq 0x119100
jmp 0x118845
leaq 0xd38(%rsp), %rdi
leaq 0xc40(%rsp), %rsi
leaq 0xd40(%rsp), %rdx
xorl %ecx, %ecx
callq 0x119200
jmp 0x118866
leaq 0xc40(%rsp), %rdi
callq 0x1117a8
leaq 0xc3f(%rsp), %rdi
callq 0x111790
leaq 0xd38(%rsp), %rdi
callq 0x1192b0
jmp 0x11888f
leaq 0xc18(%rsp), %rdi
callq 0x119310
jmp 0x11889e
leaq 0xc18(%rsp), %rdi
leaq 0xd38(%rsp), %rsi
callq 0x1193c0
jmp 0x1188b5
leaq 0xbf8(%rsp), %rdi
callq 0x111270
leaq 0x32fc8a(%rip), %rdi    # 0x448553
xorl %eax, %eax
callq 0x111080
jmp 0x1188d2
movq 0x50070f(%rip), %rdi    # 0x618fe8
leaq 0xbf8(%rsp), %rsi
callq 0x111390
jmp 0x1188e8
leaq 0xbf8(%rsp), %rdi
callq 0x111220
testb $0x1, %al
jne 0x1188fe
jmp 0x118b0f
movl $0x3, 0xbf4(%rsp)
jmp 0x118e63
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd08(%rsp)
movl %eax, 0xd04(%rsp)
jmp 0x118945
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd08(%rsp)
movl %eax, 0xd04(%rsp)
leaq 0xd18(%rsp), %rdi
callq 0x1117a8
leaq 0xd17(%rsp), %rdi
callq 0x111790
jmp 0x118ed7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd08(%rsp)
movl %eax, 0xd04(%rsp)
jmp 0x11898e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd08(%rsp)
movl %eax, 0xd04(%rsp)
leaq 0xce0(%rsp), %rdi
callq 0x1117a8
leaq 0xcdf(%rsp), %rdi
callq 0x111790
jmp 0x118ed7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd08(%rsp)
movl %eax, 0xd04(%rsp)
jmp 0x1189d7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd08(%rsp)
movl %eax, 0xd04(%rsp)
leaq 0xcb8(%rsp), %rdi
callq 0x1117a8
leaq 0xcb7(%rsp), %rdi
callq 0x111790
jmp 0x118ed7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd08(%rsp)
movl %eax, 0xd04(%rsp)
jmp 0x118a20
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd08(%rsp)
movl %eax, 0xd04(%rsp)
leaq 0xc90(%rsp), %rdi
callq 0x1117a8
leaq 0xc8f(%rsp), %rdi
callq 0x111790
jmp 0x118ed7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd08(%rsp)
movl %eax, 0xd04(%rsp)
jmp 0x118a69
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd08(%rsp)
movl %eax, 0xd04(%rsp)
leaq 0xc68(%rsp), %rdi
callq 0x1117a8
leaq 0xc67(%rsp), %rdi
callq 0x111790
jmp 0x118ed7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd08(%rsp)
movl %eax, 0xd04(%rsp)
jmp 0x118ab2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd08(%rsp)
movl %eax, 0xd04(%rsp)
leaq 0xc40(%rsp), %rdi
callq 0x1117a8
leaq 0xc3f(%rsp), %rdi
callq 0x111790
jmp 0x118ed7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd08(%rsp)
movl %eax, 0xd04(%rsp)
jmp 0x118ed7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd08(%rsp)
movl %eax, 0xd04(%rsp)
jmp 0x118eca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd08(%rsp)
movl %eax, 0xd04(%rsp)
jmp 0x118ebd
leaq 0x32fa41(%rip), %rdi    # 0x448557
leaq 0xbf8(%rsp), %rsi
callq 0x119470
movb %al, 0x4f(%rsp)
jmp 0x118b29
movb 0x4f(%rsp), %al
testb $0x1, %al
jne 0x118b33
jmp 0x118b43
movl $0x2, 0xbf4(%rsp)
jmp 0x118e63
leaq 0x32fa12(%rip), %rdi    # 0x44855c
leaq 0xbf8(%rsp), %rsi
callq 0x119470
movb %al, 0x4e(%rsp)
jmp 0x118b5d
movb 0x4e(%rsp), %al
testb $0x1, %al
jne 0x118b67
jmp 0x118b77
movl $0x2, 0xbf4(%rsp)
jmp 0x118e63
jmp 0x118b79
jmp 0x118b7b
leaq 0x178(%rsp), %rdi
movl $0x7f, %esi
callq 0x1194a0
jmp 0x118b8f
leaq 0x2c8(%rsp), %rdi
leaq 0x178(%rsp), %rsi
callq 0x1195d0
jmp 0x118ba6
leaq 0x178(%rsp), %rdi
callq 0x119e00
leaq 0x2c8(%rsp), %rdi
leaq 0xbf8(%rsp), %rsi
leaq 0xc18(%rsp), %rdx
callq 0x119e70
movb %al, 0x4d(%rsp)
jmp 0x118bd6
movb 0x4d(%rsp), %al
testb $0x1, %al
jne 0x118e0e
jmp 0x118be4
leaq 0x158(%rsp), %rdi
leaq 0x2c8(%rsp), %rsi
callq 0x11a700
jmp 0x118bfb
leaq 0x158(%rsp), %rdi
callq 0x1110f0
movq %rax, 0x40(%rsp)
leaq 0xbf8(%rsp), %rdi
callq 0x1110f0
movq 0x40(%rsp), %rsi
movq %rax, %rdx
leaq 0x32f938(%rip), %rdi    # 0x448561
xorl %eax, %eax
callq 0x111080
jmp 0x118c32
leaq 0x158(%rsp), %rdi
callq 0x1117a8
movq $0x0, 0x150(%rsp)
movq 0x150(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0x2c8(%rsp), %rdi
callq 0x11a7c0
movq %rax, 0x38(%rsp)
jmp 0x118c6c
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
cmpq %rcx, %rax
jae 0x118e01
leaq 0xa8(%rsp), %rdi
leaq 0x2c8(%rsp), %rsi
leaq 0x150(%rsp), %rdx
callq 0x11a7e0
jmp 0x118c9e
movl 0x150(%rsp), %eax
movl %eax, 0x28(%rsp)
movl 0xd0(%rsp), %eax
movl %eax, 0x2c(%rsp)
movl 0xd8(%rsp), %esi
leaq 0x88(%rsp), %rdi
callq 0x11a8c0
jmp 0x118cca
leaq 0x88(%rsp), %rdi
callq 0x1110f0
movq %rax, 0x18(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0x1110f0
movq %rax, 0x20(%rsp)
leaq 0xbf8(%rsp), %rdi
callq 0x1110f0
movl 0x28(%rsp), %esi
movl 0x2c(%rsp), %edx
movq 0x18(%rsp), %rcx
movq 0x20(%rsp), %r8
movq %rax, %r9
leaq 0x32f864(%rip), %rdi    # 0x44857b
xorl %eax, %eax
callq 0x111080
jmp 0x118d20
leaq 0x88(%rsp), %rdi
callq 0x1117a8
leaq 0xa8(%rsp), %rdi
callq 0x11ac00
movq 0x150(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x150(%rsp)
jmp 0x118c4b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd08(%rsp)
movl %eax, 0xd04(%rsp)
leaq 0x178(%rsp), %rdi
callq 0x119e00
jmp 0x118ebd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd08(%rsp)
movl %eax, 0xd04(%rsp)
jmp 0x118eb0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd08(%rsp)
movl %eax, 0xd04(%rsp)
leaq 0x158(%rsp), %rdi
callq 0x1117a8
jmp 0x118eb0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd08(%rsp)
movl %eax, 0xd04(%rsp)
jmp 0x118def
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd08(%rsp)
movl %eax, 0xd04(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x1117a8
leaq 0xa8(%rsp), %rdi
callq 0x11ac00
jmp 0x118eb0
movl $0x3, 0xbf4(%rsp)
jmp 0x118e56
leaq 0xc18(%rsp), %rdi
callq 0x11ac50
movsd %xmm0, 0x10(%rsp)
jmp 0x118e23
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x80(%rsp)
movsd 0x80(%rsp), %xmm0
leaq 0x32f778(%rip), %rdi    # 0x4485ba
movb $0x1, %al
callq 0x111080
jmp 0x118e4b
movl $0x0, 0xbf4(%rsp)
leaq 0x2c8(%rsp), %rdi
callq 0x11ac70
leaq 0xbf8(%rsp), %rdi
callq 0x1117a8
leaq 0xc18(%rsp), %rdi
callq 0x11ae70
leaq 0xd38(%rsp), %rdi
callq 0x11aeb0
movl 0xbf4(%rsp), %eax
movl %eax, 0xc(%rsp)
testl %eax, %eax
je 0x118eab
jmp 0x118e9b
movl 0xc(%rsp), %eax
subl $0x2, %eax
je 0x118ee6
jmp 0x118ea6
jmp 0x118592
jmp 0x118592
leaq 0x2c8(%rsp), %rdi
callq 0x11ac70
leaq 0xbf8(%rsp), %rdi
callq 0x1117a8
leaq 0xc18(%rsp), %rdi
callq 0x11ae70
leaq 0xd38(%rsp), %rdi
callq 0x11aeb0
jmp 0x118ef0
xorl %eax, %eax
addq $0xd78, %rsp            # imm = 0xD78
retq
movq 0xd08(%rsp), %rdi
callq 0x111460
nopl (%rax)