// File: ArashPartow[P]exprtk/exprtk_simple_example_07.cpp
// Function: void logic<double>()
void logic()
{
   typedef exprtk::symbol_table<T> symbol_table_t;
   typedef exprtk::expression<T>   expression_t;
   typedef exprtk::parser<T>       parser_t;

   const std::string expression_string = "not(A and B) or C";

   symbol_table_t symbol_table;
   symbol_table.create_variable("A");
   symbol_table.create_variable("B");
   symbol_table.create_variable("C");

   expression_t expression;
   expression.register_symbol_table(symbol_table);

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

   printf(" # | A | B | C | %s\n"
          "---+---+---+---+-%s\n",
          expression_string.c_str(),
          std::string(expression_string.size(),'-').c_str());

   for (int i = 0; i < 8; ++i)
   {
      symbol_table.get_variable("A")->ref() = T((i & 0x01) ? 1 : 0);
      symbol_table.get_variable("B")->ref() = T((i & 0x02) ? 1 : 0);
      symbol_table.get_variable("C")->ref() = T((i & 0x04) ? 1 : 0);

      const int result = static_cast<int>(expression.value());

      printf(" %d | %d | %d | %d | %d \n",
             i,
             static_cast<int>(symbol_table.get_variable("A")->value()),
             static_cast<int>(symbol_table.get_variable("B")->value()),
             static_cast<int>(symbol_table.get_variable("C")->value()),
             result);
   }
}

// Assembly:
subq $0xda8, %rsp            # imm = 0xDA8
leaq 0xd87(%rsp), %rdi
movq %rdi, 0x120(%rsp)
callq 0x111660
movq 0x120(%rsp), %rdx
leaq 0x32fcfa(%rip), %rsi    # 0x448545
leaq 0xd88(%rsp), %rdi
callq 0x118760
jmp 0x11885a
leaq 0xd87(%rsp), %rdi
callq 0x111780
leaq 0xd68(%rsp), %rdi
movl $0x1, %esi
callq 0x119620
jmp 0x11887b
leaq 0xd47(%rsp), %rdi
movq %rdi, 0x118(%rsp)
callq 0x111660
movq 0x118(%rsp), %rdx
leaq 0x334615(%rip), %rsi    # 0x44ceb4
leaq 0xd48(%rsp), %rdi
callq 0x118760
jmp 0x1188ae
movq $0x0, 0xd38(%rsp)
leaq 0xd68(%rsp), %rdi
leaq 0xd48(%rsp), %rsi
leaq 0xd38(%rsp), %rdx
callq 0x119660
jmp 0x1188d9
leaq 0xd48(%rsp), %rdi
callq 0x111798
leaq 0xd47(%rsp), %rdi
callq 0x111780
leaq 0xd17(%rsp), %rdi
movq %rdi, 0x110(%rsp)
callq 0x111660
movq 0x110(%rsp), %rdx
leaq 0x32fc40(%rip), %rsi    # 0x448557
leaq 0xd18(%rsp), %rdi
callq 0x118760
jmp 0x118926
movq $0x0, 0xd08(%rsp)
leaq 0xd68(%rsp), %rdi
leaq 0xd18(%rsp), %rsi
leaq 0xd08(%rsp), %rdx
callq 0x119660
jmp 0x118951
leaq 0xd18(%rsp), %rdi
callq 0x111798
leaq 0xd17(%rsp), %rdi
callq 0x111780
leaq 0xce7(%rsp), %rdi
movq %rdi, 0x108(%rsp)
callq 0x111660
movq 0x108(%rsp), %rdx
leaq 0x32fbc6(%rip), %rsi    # 0x448555
leaq 0xce8(%rsp), %rdi
callq 0x118760
jmp 0x11899e
movq $0x0, 0xcd8(%rsp)
leaq 0xd68(%rsp), %rdi
leaq 0xce8(%rsp), %rsi
leaq 0xcd8(%rsp), %rdx
callq 0x119660
jmp 0x1189c9
leaq 0xce8(%rsp), %rdi
callq 0x111798
leaq 0xce7(%rsp), %rdi
callq 0x111780
leaq 0xcb8(%rsp), %rdi
callq 0x119740
jmp 0x1189f2
leaq 0xcb8(%rsp), %rdi
leaq 0xd68(%rsp), %rsi
callq 0x1197f0
jmp 0x118a09
leaq 0x240(%rsp), %rdi
movl $0x7f, %esi
callq 0x1198a0
jmp 0x118a1d
leaq 0x390(%rsp), %rdi
leaq 0x240(%rsp), %rsi
callq 0x1199d0
jmp 0x118a34
leaq 0x240(%rsp), %rdi
callq 0x11a200
leaq 0x390(%rsp), %rdi
leaq 0xd88(%rsp), %rsi
leaq 0xcb8(%rsp), %rdx
callq 0x11a270
jmp 0x118a60
leaq 0xd88(%rsp), %rdi
movq %rdi, 0xe8(%rsp)
callq 0x1110f0
movq 0xe8(%rsp), %rdi
movq %rax, 0xf0(%rsp)
callq 0x111230
movq %rax, 0xf8(%rsp)
leaq 0x21f(%rsp), %rdi
movq %rdi, 0x100(%rsp)
callq 0x111660
movq 0xf8(%rsp), %rsi
movq 0x100(%rsp), %rcx
leaq 0x220(%rsp), %rdi
movl $0x2d, %edx
callq 0x11ab00
jmp 0x118acb
leaq 0x220(%rsp), %rdi
callq 0x1110f0
movq 0xf0(%rsp), %rsi
movq %rax, %rdx
leaq 0x32fa6f(%rip), %rdi    # 0x448559
xorl %eax, %eax
callq 0x111080
jmp 0x118af3
leaq 0x220(%rsp), %rdi
callq 0x111798
leaq 0x21f(%rsp), %rdi
callq 0x111780
movl $0x0, 0x218(%rsp)
cmpl $0x8, 0x218(%rsp)
jge 0x119301
movl 0x218(%rsp), %eax
andl $0x1, %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0xd8(%rsp)
leaq 0x1f7(%rsp), %rdi
movq %rdi, 0xe0(%rsp)
callq 0x111660
movq 0xe0(%rsp), %rdx
leaq 0x334353(%rip), %rsi    # 0x44ceb4
leaq 0x1f8(%rsp), %rdi
callq 0x118760
jmp 0x118b70
leaq 0xd68(%rsp), %rdi
leaq 0x1f8(%rsp), %rsi
callq 0x11ab80
movq %rax, 0xd0(%rsp)
jmp 0x118b8f
movq 0xd0(%rsp), %rdi
callq 0x11ac00
movq %rax, 0xc8(%rsp)
jmp 0x118ba6
movq 0xc8(%rsp), %rax
movsd 0xd8(%rsp), %xmm0
movsd %xmm0, (%rax)
leaq 0x1f8(%rsp), %rdi
callq 0x111798
leaq 0x1f7(%rsp), %rdi
callq 0x111780
movl 0x218(%rsp), %eax
testb $0x2, %al
movsd 0x32a422(%rip), %xmm0   # 0x443008
xorps %xmm1, %xmm1
movsd %xmm1, 0xb8(%rsp)
movsd %xmm0, 0xc0(%rsp)
jne 0x118c0f
movsd 0xb8(%rsp), %xmm0
movsd %xmm0, 0xc0(%rsp)
movsd 0xc0(%rsp), %xmm0
movsd %xmm0, 0xa8(%rsp)
leaq 0x1cf(%rsp), %rdi
movq %rdi, 0xb0(%rsp)
callq 0x111660
movq 0xb0(%rsp), %rdx
leaq 0x32f912(%rip), %rsi    # 0x448557
leaq 0x1d0(%rsp), %rdi
callq 0x118760
jmp 0x118c54
leaq 0xd68(%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
callq 0x11ab80
movq %rax, 0xa0(%rsp)
jmp 0x118c73
movq 0xa0(%rsp), %rdi
callq 0x11ac00
movq %rax, 0x98(%rsp)
jmp 0x118c8a
movq 0x98(%rsp), %rax
movsd 0xa8(%rsp), %xmm0
movsd %xmm0, (%rax)
leaq 0x1d0(%rsp), %rdi
callq 0x111798
leaq 0x1cf(%rsp), %rdi
callq 0x111780
movl 0x218(%rsp), %eax
testb $0x4, %al
movsd 0x32a33e(%rip), %xmm0   # 0x443008
xorps %xmm1, %xmm1
movsd %xmm1, 0x88(%rsp)
movsd %xmm0, 0x90(%rsp)
jne 0x118cf3
movsd 0x88(%rsp), %xmm0
movsd %xmm0, 0x90(%rsp)
movsd 0x90(%rsp), %xmm0
movsd %xmm0, 0x78(%rsp)
leaq 0x1a7(%rsp), %rdi
movq %rdi, 0x80(%rsp)
callq 0x111660
movq 0x80(%rsp), %rdx
leaq 0x32f82f(%rip), %rsi    # 0x448555
leaq 0x1a8(%rsp), %rdi
callq 0x118760
jmp 0x118d35
leaq 0xd68(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
callq 0x11ab80
movq %rax, 0x70(%rsp)
jmp 0x118d51
movq 0x70(%rsp), %rdi
callq 0x11ac00
movq %rax, 0x68(%rsp)
jmp 0x118d62
movq 0x68(%rsp), %rax
movsd 0x78(%rsp), %xmm0
movsd %xmm0, (%rax)
leaq 0x1a8(%rsp), %rdi
callq 0x111798
leaq 0x1a7(%rsp), %rdi
callq 0x111780
leaq 0xcb8(%rsp), %rdi
callq 0x11ac10
movsd %xmm0, 0x60(%rsp)
jmp 0x118da0
movsd 0x60(%rsp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x1a0(%rsp)
movl 0x218(%rsp), %eax
movl %eax, 0x54(%rsp)
leaq 0x17f(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x111660
movq 0x58(%rsp), %rdx
leaq 0x3340da(%rip), %rsi    # 0x44ceb4
leaq 0x180(%rsp), %rdi
callq 0x118760
jmp 0x118de9
leaq 0xd68(%rsp), %rdi
leaq 0x180(%rsp), %rsi
callq 0x11ab80
movq %rax, 0x48(%rsp)
jmp 0x118e05
movq 0x48(%rsp), %rdi
callq 0x11ac30
movsd %xmm0, 0x40(%rsp)
jmp 0x118e17
movsd 0x40(%rsp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x34(%rsp)
leaq 0x157(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x111660
movq 0x38(%rsp), %rdx
leaq 0x32f714(%rip), %rsi    # 0x448557
leaq 0x158(%rsp), %rdi
callq 0x118760
jmp 0x118e52
leaq 0xd68(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0x11ab80
movq %rax, 0x28(%rsp)
jmp 0x118e6e
movq 0x28(%rsp), %rdi
callq 0x11ac30
movsd %xmm0, 0x20(%rsp)
jmp 0x118e80
movsd 0x20(%rsp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x14(%rsp)
leaq 0x12f(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x111660
movq 0x18(%rsp), %rdx
leaq 0x32f6a9(%rip), %rsi    # 0x448555
leaq 0x130(%rsp), %rdi
callq 0x118760
jmp 0x118ebb
leaq 0xd68(%rsp), %rdi
leaq 0x130(%rsp), %rsi
callq 0x11ab80
movq %rax, 0x8(%rsp)
jmp 0x118ed7
movq 0x8(%rsp), %rdi
callq 0x11ac30
movsd %xmm0, (%rsp)
jmp 0x118ee8
movl 0x14(%rsp), %ecx
movl 0x34(%rsp), %edx
movl 0x54(%rsp), %esi
movsd (%rsp), %xmm0
cvttsd2si %xmm0, %r8d
movl 0x1a0(%rsp), %r9d
leaq 0x32f675(%rip), %rdi    # 0x448582
xorl %eax, %eax
callq 0x111080
jmp 0x118f16
leaq 0x130(%rsp), %rdi
callq 0x111798
leaq 0x12f(%rsp), %rdi
callq 0x111780
leaq 0x158(%rsp), %rdi
callq 0x111798
leaq 0x157(%rsp), %rdi
callq 0x111780
leaq 0x180(%rsp), %rdi
callq 0x111798
leaq 0x17f(%rsp), %rdi
callq 0x111780
movl 0x218(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x218(%rsp)
jmp 0x118b18
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd78(%rsp)
movl %eax, 0xd74(%rsp)
leaq 0xd87(%rsp), %rdi
callq 0x111780
jmp 0x119371
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd78(%rsp)
movl %eax, 0xd74(%rsp)
jmp 0x119364
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd78(%rsp)
movl %eax, 0xd74(%rsp)
jmp 0x118ff0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd78(%rsp)
movl %eax, 0xd74(%rsp)
leaq 0xd48(%rsp), %rdi
callq 0x111798
leaq 0xd47(%rsp), %rdi
callq 0x111780
jmp 0x119357
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd78(%rsp)
movl %eax, 0xd74(%rsp)
jmp 0x119039
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd78(%rsp)
movl %eax, 0xd74(%rsp)
leaq 0xd18(%rsp), %rdi
callq 0x111798
leaq 0xd17(%rsp), %rdi
callq 0x111780
jmp 0x119357
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd78(%rsp)
movl %eax, 0xd74(%rsp)
jmp 0x119082
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd78(%rsp)
movl %eax, 0xd74(%rsp)
leaq 0xce8(%rsp), %rdi
callq 0x111798
leaq 0xce7(%rsp), %rdi
callq 0x111780
jmp 0x119357
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd78(%rsp)
movl %eax, 0xd74(%rsp)
jmp 0x119357
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd78(%rsp)
movl %eax, 0xd74(%rsp)
jmp 0x11934a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd78(%rsp)
movl %eax, 0xd74(%rsp)
leaq 0x240(%rsp), %rdi
callq 0x11a200
jmp 0x11934a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd78(%rsp)
movl %eax, 0xd74(%rsp)
jmp 0x11933d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd78(%rsp)
movl %eax, 0xd74(%rsp)
jmp 0x11913c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd78(%rsp)
movl %eax, 0xd74(%rsp)
leaq 0x220(%rsp), %rdi
callq 0x111798
leaq 0x21f(%rsp), %rdi
callq 0x111780
jmp 0x11933d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd78(%rsp)
movl %eax, 0xd74(%rsp)
jmp 0x119185
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd78(%rsp)
movl %eax, 0xd74(%rsp)
leaq 0x1f8(%rsp), %rdi
callq 0x111798
leaq 0x1f7(%rsp), %rdi
callq 0x111780
jmp 0x11933d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd78(%rsp)
movl %eax, 0xd74(%rsp)
jmp 0x1191ce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd78(%rsp)
movl %eax, 0xd74(%rsp)
leaq 0x1d0(%rsp), %rdi
callq 0x111798
leaq 0x1cf(%rsp), %rdi
callq 0x111780
jmp 0x11933d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd78(%rsp)
movl %eax, 0xd74(%rsp)
jmp 0x119217
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd78(%rsp)
movl %eax, 0xd74(%rsp)
leaq 0x1a8(%rsp), %rdi
callq 0x111798
leaq 0x1a7(%rsp), %rdi
callq 0x111780
jmp 0x11933d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd78(%rsp)
movl %eax, 0xd74(%rsp)
jmp 0x1192f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd78(%rsp)
movl %eax, 0xd74(%rsp)
jmp 0x1192e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd78(%rsp)
movl %eax, 0xd74(%rsp)
jmp 0x1192d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd78(%rsp)
movl %eax, 0xd74(%rsp)
jmp 0x1192cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd78(%rsp)
movl %eax, 0xd74(%rsp)
jmp 0x1192be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd78(%rsp)
movl %eax, 0xd74(%rsp)
leaq 0x130(%rsp), %rdi
callq 0x111798
leaq 0x12f(%rsp), %rdi
callq 0x111780
leaq 0x158(%rsp), %rdi
callq 0x111798
leaq 0x157(%rsp), %rdi
callq 0x111780
leaq 0x180(%rsp), %rdi
callq 0x111798
leaq 0x17f(%rsp), %rdi
callq 0x111780
jmp 0x11933d
leaq 0x390(%rsp), %rdi
callq 0x11ac50
leaq 0xcb8(%rsp), %rdi
callq 0x11ae50
leaq 0xd68(%rsp), %rdi
callq 0x11ae90
leaq 0xd88(%rsp), %rdi
callq 0x111798
addq $0xda8, %rsp            # imm = 0xDA8
retq
leaq 0x390(%rsp), %rdi
callq 0x11ac50
leaq 0xcb8(%rsp), %rdi
callq 0x11ae50
leaq 0xd68(%rsp), %rdi
callq 0x11ae90
leaq 0xd88(%rsp), %rdi
callq 0x111798
movq 0xd78(%rsp), %rdi
callq 0x111460
nop