// File: /workspace/github_cpp_makefile_star2_O2/ArashPartow[P]exprtk-extras/exprtk_gcd.cpp
// Function: void gcd<double>()
void gcd()
{
   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;
   symbol_table.add_function("println",gcd_println);

   compositor_t compositor(symbol_table);

   // define function: gcd(x,y)
   compositor.add(
      function_t("gcd")
      .vars("x","y")
      .expression
      (
         " switch                         "
         " {                              "
         "    case 0 = x : 0;             "
         "    case 0 = y : x;             "
         "    case x = y : x;             "
         "    case x > y : gcd(x - y, y); "
         "    default    : gcd(x, y - x); "
         " }                              "
      ));

   const std::string gcd_program =
      " i := 0;                        "
      " while ((i += 1) < 100)         "
      " {                              "
      "    j := 0;                     "
      "    repeat                      "
      "       println(i, j, gcd(i,j)); "
      "    until ((j += 1) >= 100);    "
      " };                             ";

   expression_t expression;
   expression.register_symbol_table(symbol_table);

   parser_t parser;
   parser.enable_unknown_symbol_resolver();
   parser.compile(gcd_program,expression);

   expression.value();
}

// Assembly:
pushq %rbx
subq $0x14d0, %rsp           # imm = 0x14D0
leaq 0x8(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x113682
leaq 0x130dfe(%rip), %rsi    # 0x24411d
leaq 0xae8(%rsp), %rdi
leaq 0x1c0(%rsp), %rdx
callq 0x1132c8
leaq 0x41f(%rip), %rdx       # 0x11375a
leaq 0x8(%rsp), %rdi
leaq 0xae8(%rsp), %rsi
callq 0x1136a6
leaq 0xae8(%rsp), %rdi
callq 0x1115c8
leaq 0xae8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x11377c
leaq 0x130db2(%rip), %rsi    # 0x244125
leaq 0x70(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x1132c8
leaq 0x1c0(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x11389a
leaq 0x130cda(%rip), %rsi    # 0x244075
leaq 0x30(%rsp), %rdi
leaq 0x6(%rsp), %rdx
callq 0x1132c8
leaq 0x131156(%rip), %rsi    # 0x244507
leaq 0x10(%rsp), %rdi
leaq 0x5(%rsp), %rdx
callq 0x1132c8
leaq 0x1c0(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x1138e6
movq %rax, %rbx
leaq 0x130d48(%rip), %rsi    # 0x244129
leaq 0x50(%rsp), %rdi
leaq 0x4(%rsp), %rdx
callq 0x1132c8
leaq 0x20(%rbx), %rdi
leaq 0x50(%rsp), %rsi
callq 0x111550
leaq 0xae8(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x11388a
leaq 0x50(%rsp), %rdi
callq 0x1115c8
leaq 0x10(%rsp), %rdi
callq 0x1115c8
leaq 0x30(%rsp), %rdi
callq 0x1115c8
leaq 0x1c0(%rsp), %rdi
callq 0x113912
leaq 0x70(%rsp), %rdi
callq 0x1115c8
leaq 0x130dde(%rip), %rsi    # 0x24422a
leaq 0x30(%rsp), %rdi
leaq 0x1c0(%rsp), %rdx
callq 0x1132c8
leaq 0x10(%rsp), %rdi
callq 0x113932
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x113992
leaq 0x70(%rsp), %rdi
pushq $0x7f
popq %rsi
callq 0x1139ee
leaq 0x1c0(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x113afe
leaq 0x70(%rsp), %rdi
callq 0x114116
leaq 0x5a0(%rsp), %rax
movb $0x1, -0x18(%rax)
movq %rax, -0x8(%rax)
leaq 0x1c0(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x11415e
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
leaq 0x1c0(%rsp), %rdi
callq 0x1145e0
leaq 0x10(%rsp), %rdi
callq 0x11471a
leaq 0x30(%rsp), %rdi
callq 0x1115c8
leaq 0xae8(%rsp), %rdi
callq 0x114730
leaq 0x8(%rsp), %rdi
callq 0x114784
addq $0x14d0, %rsp           # imm = 0x14D0
popq %rbx
retq
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x114116
jmp 0x113578
jmp 0x113528
movq %rax, %rbx
jmp 0x113578
movq %rax, %rbx
jmp 0x113582
jmp 0x11354a
jmp 0x113536
movq %rax, %rbx
jmp 0x113596
movq %rax, %rbx
jmp 0x1135a0
movq %rax, %rbx
jmp 0x1135aa
movq %rax, %rbx
jmp 0x1135b7
movq %rax, %rbx
jmp 0x1135c1
jmp 0x113563
movq %rax, %rbx
leaq 0xae8(%rsp), %rdi
callq 0x1115c8
jmp 0x1135ce
movq %rax, %rbx
jmp 0x1135ce
movq %rax, %rbx
leaq 0x1c0(%rsp), %rdi
callq 0x1145e0
leaq 0x10(%rsp), %rdi
callq 0x11471a
leaq 0x30(%rsp), %rdi
jmp 0x1135bc
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x1115c8
leaq 0x10(%rsp), %rdi
callq 0x1115c8
leaq 0x30(%rsp), %rdi
callq 0x1115c8
leaq 0x1c0(%rsp), %rdi
callq 0x113912
leaq 0x70(%rsp), %rdi
callq 0x1115c8
leaq 0xae8(%rsp), %rdi
callq 0x114730
leaq 0x8(%rsp), %rdi
callq 0x114784
movq %rbx, %rdi
callq 0x111310