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

   const std::string base_expression_string =
      "x := "
      "((1 /1) * sin( 2 * pi * f * t) + (1 /3) * sin( 6 * pi * f * t)+"
      " (1 /5) * sin(10 * pi * f * t) + (1 /7) * sin(14 * pi * f * t)+"
      " (1 /9) * sin(18 * pi * f * t) + (1/11) * sin(22 * pi * f * t)+"
      " (1/13) * sin(26 * pi * f * t) + (1/15) * sin(30 * pi * f * t)+"
      " (1/17) * sin(34 * pi * f * t) + (1/19) * sin(38 * pi * f * t)+"
      " (1/21) * sin(42 * pi * f * t) + (1/23) * sin(46 * pi * f * t)+"
      " (1/25) * sin(50 * pi * f * t) + (1/27) * sin(54 * pi * f * t));";

   std::string large_expression_string = "var x := 0;";

   for (std::size_t i = 0; i < 60000; ++i)
   {
      large_expression_string += base_expression_string;
   }

   static const T pi = T(3.141592653589793238462643383279502);

   const T f = pi / T(10);
   const T a = T(10);
         T t = T(0);

   symbol_table_t symbol_table;
   symbol_table.add_variable("t",t);
   symbol_table.add_constant("f",f);
   symbol_table.add_constant("a",a);
   symbol_table.add_constants();

   expression_t expression;
   expression.register_symbol_table(symbol_table);

   compilation_timeout_check compilation_timeout_chck;

   parser_t parser;
   parser.register_compilation_timeout_check(compilation_timeout_chck);

   const auto max_duration = std::chrono::seconds(8);
   const auto timeout_tp   = std::chrono::steady_clock::now() + max_duration;
   compilation_timeout_chck.set_timeout_time(timeout_tp);

   if (!parser.compile(large_expression_string, expression))
   {
      printf("Error: %s\t\n", parser.error().c_str());
      return;
   }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0xb10, %rsp            # imm = 0xB10
leaq 0x12adef(%rip), %rsi    # 0x23b105
leaq 0x78(%rsp), %rdi
leaq 0x1e8(%rsp), %rdx
callq 0x1102c8
leaq 0x12af96(%rip), %rsi    # 0x23b2c5
leaq 0x58(%rsp), %rdi
leaq 0x1e8(%rsp), %rdx
callq 0x1102c8
movl $0xea60, %r15d          # imm = 0xEA60
leaq 0x58(%rsp), %rbx
leaq 0x78(%rsp), %r14
subq $0x1, %r15
jb 0x110364
movq %rbx, %rdi
movq %r14, %rsi
callq 0x10e410
jmp 0x110351
movabsq $0x3fd41b2f769cf0e0, %rax # imm = 0x3FD41B2F769CF0E0
movq %rax, 0x18(%rsp)
movabsq $0x4024000000000000, %rax # imm = 0x4024000000000000
movq %rax, 0x10(%rsp)
andq $0x0, 0x8(%rsp)
movq %rsp, %rdi
pushq $0x1
popq %rsi
callq 0x11069a
leaq 0x12b60f(%rip), %rsi    # 0x23b9a9
leaq 0x1e8(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0x1102c8
movq %rsp, %rdi
leaq 0x1e8(%rsp), %rsi
leaq 0x8(%rsp), %rdx
xorl %ecx, %ecx
callq 0x1106be
leaq 0x1e8(%rsp), %rdi
callq 0x10e5c8
leaq 0x12ac98(%rip), %rsi    # 0x23b072
leaq 0x1e8(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0x1102c8
movq %rsp, %rdi
leaq 0x1e8(%rsp), %rsi
leaq 0x18(%rsp), %rdx
callq 0x11072a
leaq 0x1e8(%rsp), %rdi
callq 0x10e5c8
leaq 0x12c0f2(%rip), %rsi    # 0x23c50a
leaq 0x1e8(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0x1102c8
movq %rsp, %rdi
leaq 0x1e8(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x11072a
leaq 0x1e8(%rsp), %rdi
callq 0x10e5c8
movq %rsp, %rdi
callq 0x1107a6
leaq 0x38(%rsp), %rdi
callq 0x1107cc
leaq 0x38(%rsp), %rdi
movq %rsp, %rsi
callq 0x11082c
leaq 0x24f343(%rip), %rax    # 0x35f7b8
movq %rax, 0x20(%rsp)
movq $0x2710, 0x28(%rsp)     # imm = 0x2710
andq $0x0, 0x30(%rsp)
leaq 0x98(%rsp), %rdi
pushq $0x7f
popq %rsi
callq 0x110888
leaq 0x1e8(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x110998
leaq 0x98(%rsp), %rdi
callq 0x110fb0
leaq 0x20(%rsp), %r14
leaq 0x1e8(%rsp), %rbx
movq %r14, 0x8e8(%rbx)
callq 0x10e4b0
movabsq $0x1dcd65000, %rcx      # imm = 0x1DCD65000
addq %rax, %rcx
movq %rcx, 0x10(%r14)
leaq 0x58(%rsp), %rsi
leaq 0x38(%rsp), %rdx
movq %rbx, %rdi
callq 0x110ff8
testb %al, %al
jne 0x110531
leaq 0x98(%rsp), %rdi
leaq 0x1e8(%rsp), %rsi
callq 0x11147a
leaq 0x98(%rsp), %rbx
movq (%rbx), %rsi
leaq 0x12adaf(%rip), %rdi    # 0x23b2d1
xorl %eax, %eax
callq 0x10e060
movq %rbx, %rdi
callq 0x10e5c8
leaq 0x1e8(%rsp), %rdi
callq 0x1114ce
leaq 0x38(%rsp), %rdi
callq 0x11160a
movq %rsp, %rdi
callq 0x111620
leaq 0x58(%rsp), %rdi
callq 0x10e5c8
leaq 0x78(%rsp), %rdi
callq 0x10e5c8
addq $0xb10, %rsp            # imm = 0xB10
popq %rbx
popq %r14
popq %r15
retq
jmp 0x110573
movq %rax, %rbx
leaq 0x1e8(%rsp), %rdi
callq 0x1114ce
jmp 0x11059c
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x110fb0
jmp 0x11059c
jmp 0x110599
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x11160a
jmp 0x1105c9
jmp 0x1105c6
jmp 0x1105c6
jmp 0x1105b4
jmp 0x1105c6
jmp 0x1105b4
jmp 0x1105c6
movq %rax, %rbx
leaq 0x1e8(%rsp), %rdi
callq 0x10e5c8
jmp 0x1105c9
movq %rax, %rbx
movq %rsp, %rdi
callq 0x111620
jmp 0x1105dd
jmp 0x1105da
movq %rax, %rbx
jmp 0x1105e7
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x10e5c8
leaq 0x78(%rsp), %rdi
callq 0x10e5c8
movq %rbx, %rdi
callq 0x10e310