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

   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());

   T n = T(0);

   symbol_table_t symbol_table;
   symbol_table.add_variable("n", n);
   symbol_table.add_vector  ("v", vv);

   expression_t expression;
   expression.register_symbol_table(symbol_table);

   parser_t parser;

   const std::string vector_resize_expression =
      " sum(v) == ((v[]^2 + v[]) / 2) and sum(2v) == (n^2 + n)";

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

   for (std::size_t i = 1; i <= vv.base_size(); ++i)
   {
      vv.set_size(i);
      vv.rebase(i % 2 ? v0.data() : v1.data());

      n = T(i);

      const T result = expression.value();

      if (result != T(1))
      {
         printf("Error: vector size: %d\n", static_cast<unsigned int>(i));
      }
   }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb30, %rsp            # imm = 0xB30
leaq 0x12f976(%rip), %rbx    # 0x23fc80
pushq $0xf
popq %r14
leaq 0x208(%rsp), %rax
movq %r14, %rcx
movq %rax, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x38(%rsp), %rdi
leaq 0xb8(%rsp), %rcx
movq %rax, %rsi
movq %r14, %rdx
callq 0x11072a
leaq 0x208(%rsp), %rax
movq %r14, %rcx
movq %rax, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x80(%rsp), %rbx
leaq 0xb8(%rsp), %rcx
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x11072a
leaq 0x38(%rsp), %r14
movq 0x8(%r14), %rdx
subq (%r14), %rdx
sarq $0x3, %rdx
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x110760
andq $0x0, 0x10(%rsp)
leaq 0x8(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x110790
leaq 0x12ac27(%rip), %rsi    # 0x23afcc
leaq 0x208(%rsp), %rdi
leaq 0xb8(%rsp), %rdx
callq 0x1102b8
leaq 0x8(%rsp), %rdi
leaq 0x208(%rsp), %rsi
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x1107b4
leaq 0x208(%rsp), %rdi
callq 0x10e5b8
leaq 0x12ad1a(%rip), %rsi    # 0x23b101
leaq 0x208(%rsp), %rdi
leaq 0xb8(%rsp), %rdx
callq 0x1102b8
leaq 0x8(%rsp), %rdi
leaq 0x208(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x110820
leaq 0x208(%rsp), %rdi
callq 0x10e5b8
leaq 0x18(%rsp), %rdi
callq 0x110888
leaq 0x18(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x1108e8
leaq 0xb8(%rsp), %rdi
pushq $0x7f
popq %rsi
callq 0x110944
leaq 0x208(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x110a54
leaq 0xb8(%rsp), %rdi
callq 0x11106c
leaq 0x12ac91(%rip), %rsi    # 0x23b103
leaq 0xb8(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0x1102b8
leaq 0x208(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
leaq 0x18(%rsp), %rdx
callq 0x1110b4
testb %al, %al
je 0x110542
pushq $0x1
popq %r15
leaq 0x50(%rsp), %r12
leaq 0x12ac9c(%rip), %r13    # 0x23b155
movq 0x50(%rsp), %rax
cmpq %rax, %r15
ja 0x110580
leaq -0x1(%r15), %rcx
cmpq %rax, %rcx
jae 0x1104d5
movq %r15, 0x58(%rsp)
testb $0x1, %r15b
movq %r14, %rax
cmoveq %rbx, %rax
movq (%rax), %rsi
movq %r12, %rdi
callq 0x11158a
movq %r15, %xmm0
punpckldq 0x125b18(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x125b20(%rip), %xmm0   # 0x236020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
ucomisd 0x125b47(%rip), %xmm0   # 0x236070
jne 0x11052d
jnp 0x11053a
movq %r13, %rdi
movl %r15d, %esi
xorl %eax, %eax
callq 0x10e060
incq %r15
jmp 0x1104b9
leaq 0x98(%rsp), %rdi
leaq 0x208(%rsp), %rsi
callq 0x111536
leaq 0x98(%rsp), %rbx
movq (%rbx), %rsi
movq 0xb8(%rsp), %rdx
leaq 0x12abca(%rip), %rdi    # 0x23b13b
xorl %eax, %eax
callq 0x10e060
movq %rbx, %rdi
callq 0x10e5b8
leaq 0xb8(%rsp), %rdi
callq 0x10e5b8
leaq 0x208(%rsp), %rdi
callq 0x1115be
leaq 0x18(%rsp), %rdi
callq 0x1116f8
leaq 0x8(%rsp), %rdi
callq 0x11170e
leaq 0x68(%rsp), %rdi
callq 0x1118d6
leaq 0x80(%rsp), %rdi
callq 0x1117ac
leaq 0x38(%rsp), %rdi
callq 0x1117ac
addq $0xb30, %rsp            # imm = 0xB30
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
jmp 0x11062e
jmp 0x11062e
movq %rax, %rbx
jmp 0x11063e
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x11106c
jmp 0x11064b
jmp 0x1105fd
movq %rax, %rbx
jmp 0x11064b
jmp 0x11061a
jmp 0x110608
jmp 0x11061a
movq %rax, %rbx
leaq 0x208(%rsp), %rdi
callq 0x10e5b8
jmp 0x110655
movq %rax, %rbx
jmp 0x110655
movq %rax, %rbx
jmp 0x11065f
movq %rax, %rbx
jmp 0x110669
movq %rax, %rbx
jmp 0x110676
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x10e5b8
leaq 0x208(%rsp), %rdi
callq 0x1115be
leaq 0x18(%rsp), %rdi
callq 0x1116f8
leaq 0x8(%rsp), %rdi
callq 0x11170e
leaq 0x68(%rsp), %rdi
callq 0x1118d6
leaq 0x80(%rsp), %rdi
callq 0x1117ac
leaq 0x38(%rsp), %rdi
callq 0x1117ac
movq %rbx, %rdi
callq 0x10e310