// File: /workspace/github_cpp_makefile_star2_O2/ArashPartow[P]exprtk-extras/exprtk_extract_dependents.cpp
// Function: void extract_expression_dependents<double>()
void extract_expression_dependents()
{
   const std::string expression = "a * sin(3x) + foo(abs(y - z) / w)";

   exprtk::symbol_table<T> symbol_table;

   /*
      Note: Add any functions that are not part of the standard set
            of ExprTk functions
   */
   symbol_table.add_function("foo",[](T /*t*/)->T { return T(0); });

   std::deque<std::string> variable_list;
   std::deque<std::string> function_list;

   if (!exprtk::collect_variables(expression, symbol_table, variable_list))
   {
      printf("Error: Failed to collect variables for expression: %s\n",expression.c_str());
      variable_list.clear();
   }

   if (!exprtk::collect_functions(expression, symbol_table, function_list))
   {
      printf("Error: Failed to collect functions for expression: %s\n",expression.c_str());
      function_list.clear();
   }

   for (const auto& var : variable_list)
   {
      printf("variable: %s\n",var.c_str());
   }

   for (const auto& func : function_list)
   {
      printf("function: %s\n",func.c_str());
   }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd0, %rsp
leaq 0x12cdf7(%rip), %rsi    # 0x23d101
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x1102b8
leaq 0x8(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x1105b4
leaq 0x12cdf6(%rip), %rsi    # 0x23d123
leaq 0x30(%rsp), %rdi
leaq 0x80(%rsp), %rdx
callq 0x1102b8
leaq 0x1d26(%rip), %rdx      # 0x11206c
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x1105d8
leaq 0x30(%rsp), %rdi
callq 0x10e5b8
leaq 0x30(%rsp), %rdi
callq 0x112070
leaq 0x80(%rsp), %rdi
callq 0x112070
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0x11068c
testb %al, %al
jne 0x1103ab
movq 0x10(%rsp), %rsi
leaq 0x12cd8d(%rip), %rdi    # 0x23d127
xorl %eax, %eax
callq 0x10e060
leaq 0x30(%rsp), %rdi
callq 0x110742
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x80(%rsp), %rdx
callq 0x11076a
testb %al, %al
jne 0x1103e6
movq 0x10(%rsp), %rsi
leaq 0x12cd8c(%rip), %rdi    # 0x23d15e
xorl %eax, %eax
callq 0x10e060
leaq 0x80(%rsp), %rdi
callq 0x110742
movq 0x40(%rsp), %r14
movq 0x50(%rsp), %r13
movq 0x58(%rsp), %r15
movq 0x60(%rsp), %r12
leaq 0x12cd94(%rip), %rbx    # 0x23d195
cmpq %r12, %r14
je 0x11042d
movq (%r14), %rsi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10e060
addq $0x20, %r14
cmpq %r13, %r14
jne 0x110401
movq 0x8(%r15), %r14
addq $0x8, %r15
leaq 0x200(%r14), %r13
jmp 0x110401
movq 0x90(%rsp), %r14
movq 0xa0(%rsp), %r13
movq 0xa8(%rsp), %r15
movq 0xb0(%rsp), %r12
leaq 0x12cd4f(%rip), %rbx    # 0x23d1a3
cmpq %r12, %r14
je 0x110480
movq (%r14), %rsi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10e060
addq $0x20, %r14
cmpq %r13, %r14
jne 0x110454
movq 0x8(%r15), %r14
addq $0x8, %r15
leaq 0x200(%r14), %r13
jmp 0x110454
leaq 0x80(%rsp), %rdi
callq 0x110820
leaq 0x30(%rsp), %rdi
callq 0x110820
leaq 0x8(%rsp), %rdi
callq 0x11086c
leaq 0x10(%rsp), %rdi
callq 0x10e5b8
addq $0xd0, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rbx
jmp 0x1104ec
jmp 0x1104d2
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x10e5b8
jmp 0x1104f6
movq %rax, %rbx
jmp 0x1104f6
movq %rax, %rbx
jmp 0x110500
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x110820
leaq 0x30(%rsp), %rdi
callq 0x110820
leaq 0x8(%rsp), %rdi
callq 0x11086c
leaq 0x10(%rsp), %rdi
callq 0x10e5b8
movq %rbx, %rdi
callq 0x10e310