// File: /workspace/github_cpp_makefile_star2_O2/ArashPartow[P]exprtk-extras/exprtk_sumofprimes.cpp
// Function: void sum_of_primes<double>()
void sum_of_primes()
{
   typedef exprtk::symbol_table<T>         symbol_table_t;
   typedef exprtk::expression<T>           expression_t;
   typedef exprtk::parser<T>               parser_t;
   typedef exprtk::function_compositor<T>  compositor_t;
   typedef typename compositor_t::function function_t;

   symbol_table_t symbol_table;

   compositor_t compositor(symbol_table);

   // define function: sum_of_primes(z)
   compositor.add(
      function_t("sum_of_primes")
        .var("z")
        .expression(
          " var i     := 2;      "
          " var total := 0;      "
          " while (z > 1)        "
          " {                    "
          "    if (0 == (z % i)) "
          "    {                 "
          "       total += i;    "
          "       z /= i;        "
          "    }                 "
          "    else              "
          "       i += 1;        "
          " };                   "
          " total;               "));

   exprtk::rtl::io::println<T> println;

   symbol_table.add_function("println",println);

   const std::string sum_of_prime_factors_program =
      " for (var i := 1; i <= 100; i += 1) "
      " {                                  "
      "    println(i, sum_of_primes(i));   "
      " }                                  ";

   expression_t expression;
   expression.register_symbol_table(symbol_table);

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

   expression.value();
}

// Assembly:
pushq %rbx
subq $0x1520, %rsp           # imm = 0x1520
leaq 0x10(%rsp), %rbx
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x1136cc
leaq 0xb38(%rsp), %rdi
movq %rbx, %rsi
callq 0x1136f0
leaq 0x130ddf(%rip), %rsi    # 0x244121
leaq 0xc0(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x1132d8
leaq 0x210(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x11380e
leaq 0x130dbf(%rip), %rsi    # 0x24412f
leaq 0x58(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x1132d8
leaq 0x250(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x11df26
leaq 0x130d99(%rip), %rsi    # 0x244131
leaq 0x18(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0x1132d8
leaq 0x230(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x111550
leaq 0xb38(%rsp), %rdi
leaq 0x210(%rsp), %rsi
xorl %edx, %edx
callq 0x1137fe
leaq 0x18(%rsp), %rdi
callq 0x1115d8
leaq 0x58(%rsp), %rdi
callq 0x1115d8
leaq 0x210(%rsp), %rdi
callq 0x11385a
leaq 0xc0(%rsp), %rdi
callq 0x1115d8
leaq 0x130e4b(%rip), %rsi    # 0x244250
leaq 0x210(%rsp), %rdi
leaq 0xc0(%rsp), %rdx
callq 0x1132d8
leaq 0x58(%rsp), %rdi
leaq 0x210(%rsp), %rsi
callq 0x11387a
leaq 0x210(%rsp), %rdi
callq 0x1115d8
leaq 0x130e17(%rip), %rsi    # 0x244257
leaq 0x210(%rsp), %rdi
leaq 0xc0(%rsp), %rdx
callq 0x1132d8
leaq 0x10(%rsp), %rdi
leaq 0x210(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x11390c
leaq 0x210(%rsp), %rdi
callq 0x1115d8
leaq 0x130ddf(%rip), %rsi    # 0x24425f
leaq 0x18(%rsp), %rdi
leaq 0x210(%rsp), %rdx
callq 0x1132d8
leaq 0x38(%rsp), %rdi
callq 0x1139d4
leaq 0x38(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x113a34
leaq 0xc0(%rsp), %rdi
pushq $0x7f
popq %rsi
callq 0x113a90
leaq 0x210(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x113ba0
leaq 0xc0(%rsp), %rdi
callq 0x1141b8
leaq 0x210(%rsp), %rdi
leaq 0x18(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x114200
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
leaq 0x210(%rsp), %rdi
callq 0x114682
leaq 0x38(%rsp), %rdi
callq 0x1147bc
leaq 0x18(%rsp), %rdi
callq 0x1115d8
leaq 0x58(%rsp), %rdi
callq 0x1147d2
leaq 0xb38(%rsp), %rdi
callq 0x1147e8
leaq 0x10(%rsp), %rdi
callq 0x11483c
addq $0x1520, %rsp           # imm = 0x1520
popq %rbx
retq
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x1141b8
jmp 0x1135ba
jmp 0x113562
movq %rax, %rbx
jmp 0x1135ba
movq %rax, %rbx
jmp 0x1135c4
jmp 0x11357b
movq %rax, %rbx
leaq 0x210(%rsp), %rdi
jmp 0x1135c9
movq %rax, %rbx
jmp 0x1135ce
movq %rax, %rbx
leaq 0x210(%rsp), %rdi
jmp 0x113606
jmp 0x1135a0
jmp 0x113591
movq %rax, %rbx
jmp 0x1135e7
movq %rax, %rbx
jmp 0x1135f1
movq %rax, %rbx
jmp 0x1135fe
movq %rax, %rbx
jmp 0x11360b
movq %rax, %rbx
jmp 0x113618
movq %rax, %rbx
leaq 0x210(%rsp), %rdi
callq 0x114682
leaq 0x38(%rsp), %rdi
callq 0x1147bc
leaq 0x18(%rsp), %rdi
callq 0x1115d8
leaq 0x58(%rsp), %rdi
callq 0x1147d2
jmp 0x11360b
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x1115d8
leaq 0x58(%rsp), %rdi
callq 0x1115d8
leaq 0x210(%rsp), %rdi
callq 0x11385a
leaq 0xc0(%rsp), %rdi
callq 0x1115d8
leaq 0xb38(%rsp), %rdi
callq 0x1147e8
leaq 0x10(%rsp), %rdi
callq 0x11483c
movq %rbx, %rdi
callq 0x111310