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

   const std::string inline_resize_expression =
      " var vec_original_size := v[];                                     "
      "                                                                   "
      " for (var i := 1; i <= 2 * vec_original_size; i += 1)              "
      " {                                                                 "
      "    if (resize(v,i) == true and v[] == i and sum(2v) == (i^2 + i)) "
      "    {                                                              "
      "       println('Success: set size: ', i ,'  v[] = ', v[]);         "
      "    }                                                              "
      "    else                                                           "
      "    {                                                              "
      "       println('Error: Failed to resize vector v to size: ', i);   "
      "    }                                                              "
      " };                                                                ";

   std::vector<T> v0 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
   std::vector<T> v1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };

   exprtk::vector_view<T> vv = exprtk::make_vector_view(v0, v0.size());


   exprtk::rtl::io::package<T> io_package;

   my_vv_size_handler_t<T> vv_size_handler;
   vv_size_handler.register_vector_view(vv);

   symbol_table_t symbol_table;
   symbol_table.add_vector  ("v", vv);
   symbol_table.add_function("resize", vv_size_handler);
   symbol_table.add_package (io_package);

   expression_t expression;
   expression.register_symbol_table(symbol_table);

   parser_t parser;

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

   vv.rebase(v0.data());
   vv_size_handler.register_vector_view(vv);
   expression.value();

   vv.rebase(v1.data());
   vv_size_handler.register_vector_view(vv);
   expression.value();
}

// Assembly:
pushq %rbx
subq $0xc70, %rsp            # imm = 0xC70
leaq 0x12bdef(%rip), %rsi    # 0x23c101
leaq 0x60(%rsp), %rdi
leaq 0x348(%rsp), %rdx
callq 0x1102c8
leaq 0x130d45(%rip), %rsi    # 0x241070
pushq $0xf
popq %rdx
leaq 0x348(%rsp), %rax
movq %rdx, %rcx
movq %rax, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x30(%rsp), %rdi
leaq 0x128(%rsp), %rcx
movq %rax, %rsi
callq 0x11075e
leaq 0x130d15(%rip), %rsi    # 0x241070
pushq $0xf
popq %rdx
leaq 0x348(%rsp), %rax
movq %rdx, %rcx
movq %rax, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x48(%rsp), %rdi
leaq 0x128(%rsp), %rcx
movq %rax, %rsi
callq 0x11075e
leaq 0x30(%rsp), %rsi
movq 0x8(%rsi), %rdx
subq (%rsi), %rdx
sarq $0x3, %rdx
leaq 0x80(%rsp), %rdi
xorl %ecx, %ecx
callq 0x110794
leaq 0x278(%rsp), %rdi
callq 0x1107c4
leaq 0xb0(%rsp), %rdi
callq 0x110868
leaq 0xb0(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x1108e4
leaq 0x8(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x11090a
leaq 0x12c083(%rip), %rsi    # 0x23c469
leaq 0x348(%rsp), %rdi
leaq 0x128(%rsp), %rdx
callq 0x1102c8
leaq 0x8(%rsp), %rdi
leaq 0x348(%rsp), %rsi
leaq 0x80(%rsp), %rdx
callq 0x11092e
leaq 0x348(%rsp), %rdi
callq 0x10e5c8
leaq 0x12c042(%rip), %rsi    # 0x23c46b
leaq 0x348(%rsp), %rdi
leaq 0x128(%rsp), %rdx
callq 0x1102c8
leaq 0x8(%rsp), %rdi
leaq 0x348(%rsp), %rsi
leaq 0xb0(%rsp), %rdx
callq 0x110996
leaq 0x348(%rsp), %rdi
callq 0x10e5c8
leaq 0x278(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x1140dc
leaq 0x10(%rsp), %rdi
callq 0x110a5e
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x110abe
leaq 0x128(%rsp), %rdi
pushq $0x7f
popq %rsi
callq 0x110b1a
leaq 0x348(%rsp), %rdi
leaq 0x128(%rsp), %rsi
callq 0x110c2a
leaq 0x128(%rsp), %rdi
callq 0x111242
leaq 0x348(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x11128a
testb %al, %al
je 0x110547
movq 0x30(%rsp), %rsi
leaq 0x80(%rsp), %rbx
movq %rbx, %rdi
callq 0x111760
leaq 0xb0(%rsp), %rdi
movq %rbx, %rsi
callq 0x1108e4
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movq 0x48(%rsp), %rsi
leaq 0x80(%rsp), %rbx
movq %rbx, %rdi
callq 0x111760
leaq 0xb0(%rsp), %rdi
movq %rbx, %rsi
callq 0x1108e4
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
jmp 0x110582
leaq 0x128(%rsp), %rdi
leaq 0x348(%rsp), %rsi
callq 0x11170c
leaq 0x128(%rsp), %rbx
movq (%rbx), %rsi
movq 0x60(%rsp), %rdx
leaq 0x12beff(%rip), %rdi    # 0x23c472
xorl %eax, %eax
callq 0x10e060
movq %rbx, %rdi
callq 0x10e5c8
leaq 0x348(%rsp), %rdi
callq 0x111794
leaq 0x10(%rsp), %rdi
callq 0x1118ce
leaq 0x8(%rsp), %rdi
callq 0x1118e4
leaq 0xb0(%rsp), %rdi
callq 0x111926
leaq 0x278(%rsp), %rdi
callq 0x11193c
leaq 0x98(%rsp), %rdi
callq 0x111ad8
leaq 0x48(%rsp), %rdi
callq 0x1119ae
leaq 0x30(%rsp), %rdi
callq 0x1119ae
leaq 0x60(%rsp), %rdi
callq 0x10e5c8
addq $0xc70, %rsp            # imm = 0xC70
popq %rbx
retq
jmp 0x11064b
movq %rax, %rbx
leaq 0x128(%rsp), %rdi
callq 0x111242
jmp 0x11065b
jmp 0x110607
movq %rax, %rbx
jmp 0x11065b
jmp 0x110626
jmp 0x110626
jmp 0x110614
jmp 0x110626
movq %rax, %rbx
leaq 0x348(%rsp), %rdi
callq 0x10e5c8
jmp 0x110665
movq %rax, %rbx
jmp 0x110665
jmp 0x11062d
movq %rax, %rbx
jmp 0x11066f
movq %rax, %rbx
jmp 0x11067c
movq %rax, %rbx
jmp 0x110689
movq %rax, %rbx
jmp 0x110696
movq %rax, %rbx
jmp 0x1106a0
movq %rax, %rbx
jmp 0x1106aa
movq %rax, %rbx
leaq 0x348(%rsp), %rdi
callq 0x111794
leaq 0x10(%rsp), %rdi
callq 0x1118ce
leaq 0x8(%rsp), %rdi
callq 0x1118e4
leaq 0xb0(%rsp), %rdi
callq 0x111926
leaq 0x278(%rsp), %rdi
callq 0x11193c
leaq 0x98(%rsp), %rdi
callq 0x111ad8
leaq 0x48(%rsp), %rdi
callq 0x1119ae
leaq 0x30(%rsp), %rdi
callq 0x1119ae
leaq 0x60(%rsp), %rdi
callq 0x10e5c8
movq %rbx, %rdi
callq 0x10e310