// File: /workspace/github_cpp_makefile_star2_O3/ArashPartow[P]exprtk-extras/exprtk_e_10kdigits.cpp
// Function: void e_10k_digits<double>()
void e_10k_digits()
{
   typedef exprtk::symbol_table<T> symbol_table_t;
   typedef exprtk::expression<T>   expression_t;
   typedef exprtk::parser<T>       parser_t;

   symbol_table_t symbol_table;

   symbol_table.add_function("print",
                             [](T t) -> T
                             {
                                printf("%1d",static_cast<int>(t));
                                return T(1);
                             });

   const std::string e_10k_digits_spigot =
      " const var num_digits := 10000;                       "
      " var a[num_digits] := [2:1];                          "
      " var b[num_digits] := [1];                            "
      "                                                      "
      " print(2);                                            "
      "                                                      "
      " for (var digit := 0; digit < num_digits; digit += 1) "
      " {                                                    "
      "    b *= 10;                                          "
      "                                                      "
      "    for (var i := (b[] - 1); i > 0; i -= 1)           "
      "    {                                                 "
      "       var q := floor(b[i] / a[i]);                   "
      "       var r := floor(b[i] % a[i]);                   "
      "       b[i - 1] := b[i - 1] + q;                      "
      "       b[i] := r;                                     "
      "    };                                                "
      "                                                      "
      "    print(floor(b[0] / a[0]));                        "
      "                                                      "
      "    b[0] %= a[0];                                     "
      " }                                                    ";

   expression_t expression;
   expression.register_symbol_table(symbol_table);

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

   expression.value();
}

// Assembly:
pushq %r14
pushq %rbx
subq $0xac8, %rsp            # imm = 0xAC8
leaq 0x8(%rsp), %rdi
movl $0x1, %esi
callq 0x1175b0
leaq 0x1b0(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x18e638(%rip), %rsi    # 0x2a5939
leaq 0x18e636(%rip), %rdx    # 0x2a593e
leaq 0x1a0(%rsp), %rdi
callq 0x11751a
leaq 0x3b86(%rip), %rdx      # 0x11aea2
leaq 0x8(%rsp), %rbx
leaq 0x1a0(%rsp), %rsi
movq %rbx, %rdi
callq 0x1175f8
movq 0x1a0(%rsp), %rdi
cmpq %r14, %rdi
je 0x11734e
movq 0x1b0(%rsp), %rsi
incq %rsi
callq 0x114090
leaq 0x40(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x18e5e1(%rip), %rsi    # 0x2a593f
leaq 0x18ea7e(%rip), %rdx    # 0x2a5de3
leaq 0x30(%rsp), %rdi
callq 0x11751a
leaq 0x10(%rsp), %rdi
callq 0x11774e
movq 0x18(%rsp), %rax
movq 0x20(%rsp), %rcx
subq %rax, %rcx
je 0x1173ac
sarq $0x3, %rcx
movq 0x8(%rsp), %rdx
cmpq $0x1, %rcx
adcq $0x0, %rcx
cmpq %rbx, %rax
je 0x1173bb
cmpq (%rax), %rdx
je 0x1173bb
addq $0x8, %rax
decq %rcx
jne 0x117399
leaq 0x18(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x11bb96
leaq 0x50(%rsp), %rdi
movl $0x7f, %esi
callq 0x1177da
leaq 0x1a0(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x1178da
leaq 0x150(%rsp), %rdi
callq 0x11bd98
leaq 0x120(%rsp), %rdi
callq 0x11bd98
leaq 0xf0(%rsp), %rdi
callq 0x11bd98
leaq 0xc0(%rsp), %rdi
callq 0x11bd98
leaq 0x90(%rsp), %rdi
callq 0x11bd98
leaq 0x60(%rsp), %rdi
callq 0x11bd98
leaq 0x1a0(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x1180fe
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
leaq 0x1a0(%rsp), %rdi
callq 0x118c9a
leaq 0x10(%rsp), %rdi
callq 0x118f5c
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
je 0x11747b
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x114090
leaq 0x8(%rsp), %rdi
callq 0x118faa
addq $0xac8, %rsp            # imm = 0xAC8
popq %rbx
popq %r14
retq
jmp 0x1174a1
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x1180b6
jmp 0x1174dc
movq %rax, %rbx
jmp 0x1174dc
movq %rax, %rbx
jmp 0x1174e6
jmp 0x1174c7
movq %rax, %rbx
movq 0x1a0(%rsp), %rdi
cmpq %r14, %rdi
je 0x1174fd
movq 0x1b0(%rsp), %rsi
jmp 0x1174f5
movq %rax, %rbx
jmp 0x1174fd
movq %rax, %rbx
leaq 0x1a0(%rsp), %rdi
callq 0x118c9a
leaq 0x10(%rsp), %rdi
callq 0x118f5c
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
je 0x1174fd
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x114090
leaq 0x8(%rsp), %rdi
callq 0x118faa
movq %rbx, %rdi
callq 0x1142e0