// File: ArashPartow[P]exprtk/exprtk_simple_example_05.cpp
// Function: void custom_function<double>()
void custom_function()
{
   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 =
      "myfunc(sin(x / pi), otherfunc(3 * y, x / 2, x * y))";

   T x = T(1);
   T y = T(2);
   myfunc<T> mf;

   symbol_table_t symbol_table;
   symbol_table.add_variable("x",x);
   symbol_table.add_variable("y",y);
   symbol_table.add_function("myfunc",mf);
   symbol_table.add_function("otherfunc",myotherfunc);
   symbol_table.add_constants();

   expression_t expression;
   expression.register_symbol_table(symbol_table);

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

   const T result = expression.value();
   printf("Result: %10.5f\n",result);
}

// Assembly:
subq $0xbe8, %rsp            # imm = 0xBE8
leaq 0xbc7(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x111640
movq 0x28(%rsp), %rdx
leaq 0x331d24(%rip), %rsi    # 0x44a549
leaq 0xbc8(%rsp), %rdi
callq 0x118740
jmp 0x118834
leaq 0xbc7(%rsp), %rdi
callq 0x111760
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0xba8(%rsp)
movabsq $0x4000000000000000, %rax # imm = 0x4000000000000000
movq %rax, 0xba0(%rsp)
leaq 0xb78(%rsp), %rdi
callq 0x118ff0
jmp 0x118874
leaq 0xb70(%rsp), %rdi
movl $0x1, %esi
callq 0x119050
jmp 0x118888
leaq 0xb4f(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x111640
movq 0x20(%rsp), %rdx
leaq 0x331bfb(%rip), %rsi    # 0x44a4a1
leaq 0xb50(%rsp), %rdi
callq 0x118740
jmp 0x1188b5
leaq 0xb70(%rsp), %rdi
leaq 0xb50(%rsp), %rsi
leaq 0xba8(%rsp), %rdx
xorl %ecx, %ecx
callq 0x119090
jmp 0x1188d6
leaq 0xb50(%rsp), %rdi
callq 0x111778
leaq 0xb4f(%rsp), %rdi
callq 0x111760
leaq 0xb27(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x111640
movq 0x18(%rsp), %rdx
leaq 0x331c6f(%rip), %rsi    # 0x44a57d
leaq 0xb28(%rsp), %rdi
callq 0x118740
jmp 0x11891d
leaq 0xb70(%rsp), %rdi
leaq 0xb28(%rsp), %rsi
leaq 0xba0(%rsp), %rdx
xorl %ecx, %ecx
callq 0x119090
jmp 0x11893e
leaq 0xb28(%rsp), %rdi
callq 0x111778
leaq 0xb27(%rsp), %rdi
callq 0x111760
leaq 0xaff(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x111640
movq 0x10(%rsp), %rdx
leaq 0x331c09(%rip), %rsi    # 0x44a57f
leaq 0xb00(%rsp), %rdi
callq 0x118740
jmp 0x118985
leaq 0xb70(%rsp), %rdi
leaq 0xb00(%rsp), %rsi
leaq 0xb78(%rsp), %rdx
callq 0x119140
jmp 0x1189a4
leaq 0xb00(%rsp), %rdi
callq 0x111778
leaq 0xaff(%rsp), %rdi
callq 0x111760
leaq 0xad7(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x111640
movq 0x8(%rsp), %rdx
leaq 0x331baa(%rip), %rsi    # 0x44a586
leaq 0xad8(%rsp), %rdi
callq 0x118740
jmp 0x1189eb
leaq 0x91e(%rip), %rdx       # 0x119310
leaq 0xb70(%rsp), %rdi
leaq 0xad8(%rsp), %rsi
callq 0x1191e0
jmp 0x118a09
leaq 0xad8(%rsp), %rdi
callq 0x111778
leaq 0xad7(%rsp), %rdi
callq 0x111760
leaq 0xb70(%rsp), %rdi
callq 0x119340
jmp 0x118a32
leaq 0xab0(%rsp), %rdi
callq 0x1193a0
jmp 0x118a41
leaq 0xab0(%rsp), %rdi
leaq 0xb70(%rsp), %rsi
callq 0x119450
jmp 0x118a58
leaq 0x38(%rsp), %rdi
movl $0x7f, %esi
callq 0x119500
jmp 0x118a69
leaq 0x188(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x119630
jmp 0x118a7d
leaq 0x38(%rsp), %rdi
callq 0x119e60
leaq 0x188(%rsp), %rdi
leaq 0xbc8(%rsp), %rsi
leaq 0xab0(%rsp), %rdx
callq 0x119ed0
jmp 0x118aa6
leaq 0xab0(%rsp), %rdi
callq 0x11a760
movsd %xmm0, (%rsp)
jmp 0x118aba
movsd (%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x30(%rsp), %xmm0
leaq 0x331abe(%rip), %rdi    # 0x44a590
movb $0x1, %al
callq 0x111080
jmp 0x118adb
leaq 0x188(%rsp), %rdi
callq 0x11a780
leaq 0xab0(%rsp), %rdi
callq 0x11a980
leaq 0xb70(%rsp), %rdi
callq 0x11a9c0
leaq 0xb78(%rsp), %rdi
callq 0x11aa40
leaq 0xbc8(%rsp), %rdi
callq 0x111778
addq $0xbe8, %rsp            # imm = 0xBE8
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xbb8(%rsp)
movl %eax, 0xbb4(%rsp)
leaq 0xbc7(%rsp), %rdi
callq 0x111760
jmp 0x118d3e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xbb8(%rsp)
movl %eax, 0xbb4(%rsp)
jmp 0x118d31
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xbb8(%rsp)
movl %eax, 0xbb4(%rsp)
jmp 0x118d24
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xbb8(%rsp)
movl %eax, 0xbb4(%rsp)
jmp 0x118bb3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xbb8(%rsp)
movl %eax, 0xbb4(%rsp)
leaq 0xb50(%rsp), %rdi
callq 0x111778
leaq 0xb4f(%rsp), %rdi
callq 0x111760
jmp 0x118d17
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xbb8(%rsp)
movl %eax, 0xbb4(%rsp)
jmp 0x118bfc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xbb8(%rsp)
movl %eax, 0xbb4(%rsp)
leaq 0xb28(%rsp), %rdi
callq 0x111778
leaq 0xb27(%rsp), %rdi
callq 0x111760
jmp 0x118d17
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xbb8(%rsp)
movl %eax, 0xbb4(%rsp)
jmp 0x118c45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xbb8(%rsp)
movl %eax, 0xbb4(%rsp)
leaq 0xb00(%rsp), %rdi
callq 0x111778
leaq 0xaff(%rsp), %rdi
callq 0x111760
jmp 0x118d17
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xbb8(%rsp)
movl %eax, 0xbb4(%rsp)
jmp 0x118c8e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xbb8(%rsp)
movl %eax, 0xbb4(%rsp)
leaq 0xad8(%rsp), %rdi
callq 0x111778
leaq 0xad7(%rsp), %rdi
callq 0x111760
jmp 0x118d17
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xbb8(%rsp)
movl %eax, 0xbb4(%rsp)
jmp 0x118d17
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xbb8(%rsp)
movl %eax, 0xbb4(%rsp)
jmp 0x118d0a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xbb8(%rsp)
movl %eax, 0xbb4(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x119e60
jmp 0x118d0a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xbb8(%rsp)
movl %eax, 0xbb4(%rsp)
leaq 0x188(%rsp), %rdi
callq 0x11a780
leaq 0xab0(%rsp), %rdi
callq 0x11a980
leaq 0xb70(%rsp), %rdi
callq 0x11a9c0
leaq 0xb78(%rsp), %rdi
callq 0x11aa40
leaq 0xbc8(%rsp), %rdi
callq 0x111778
movq 0xbb8(%rsp), %rdi
callq 0x111440
nopl (%rax,%rax)