// File: /workspace/github_cpp_makefile_star2_O3/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 0x193174(%rip), %r14    # 0x2aa450
leaq 0x208(%rsp), %rax
movl $0xf, %ecx
movq %rax, %rdi
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x48(%rsp), %rbx
leaq 0xb8(%rsp), %rcx
movl $0xf, %edx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x117944
leaq 0x208(%rsp), %rax
movl $0xf, %ecx
movq %rax, %rdi
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x80(%rsp), %r14
leaq 0xb8(%rsp), %rcx
movl $0xf, %edx
movq %r14, %rdi
movq %rax, %rsi
callq 0x117944
movq 0x48(%rsp), %rax
movq 0x50(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movq %rcx, 0x18(%rsp)
movq %rcx, 0x20(%rsp)
movq %rax, 0x28(%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x30(%rsp)
xorl %eax, %eax
movq %rax, 0x40(%rsp)
movq %rax, 0x10(%rsp)
leaq 0x8(%rsp), %rdi
movl $0x1, %esi
callq 0x11798a
leaq 0x218(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x18e466(%rip), %rsi    # 0x2a5804
leaq 0x18e460(%rip), %rdx    # 0x2a5805
leaq 0x208(%rsp), %rdi
callq 0x1178ae
leaq 0x8(%rsp), %rdi
leaq 0x208(%rsp), %rsi
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x1179d2
movq 0x208(%rsp), %rdi
cmpq %r12, %rdi
je 0x1173e8
movq 0x218(%rsp), %rsi
incq %rsi
callq 0x114090
leaq 0x208(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x18e53f(%rip), %rsi    # 0x2a5939
leaq 0x18e539(%rip), %rdx    # 0x2a593a
callq 0x1178ae
leaq 0x8(%rsp), %r15
leaq 0x208(%rsp), %rsi
leaq 0x18(%rsp), %rdx
movq %r15, %rdi
callq 0x117b22
movq 0x208(%rsp), %rdi
cmpq %r12, %rdi
je 0x11743d
movq 0x218(%rsp), %rsi
incq %rsi
callq 0x114090
leaq 0x60(%rsp), %rdi
callq 0x117cf0
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rcx
subq %rax, %rcx
je 0x11747a
sarq $0x3, %rcx
movq 0x8(%rsp), %rdx
cmpq $0x1, %rcx
adcq $0x0, %rcx
cmpq %r15, %rax
je 0x117489
cmpq (%rax), %rdx
je 0x117489
addq $0x8, %rax
decq %rcx
jne 0x117467
leaq 0x68(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x11cac2
leaq 0xb8(%rsp), %rdi
movl $0x7f, %esi
callq 0x117d7c
leaq 0x208(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x117e7c
leaq 0x1b8(%rsp), %rdi
callq 0x11ccc4
leaq 0x188(%rsp), %rdi
callq 0x11ccc4
leaq 0x158(%rsp), %rdi
callq 0x11ccc4
leaq 0x128(%rsp), %rdi
callq 0x11ccc4
leaq 0xf8(%rsp), %rdi
callq 0x11ccc4
leaq 0xc8(%rsp), %r15
movq %r15, %rdi
callq 0x11ccc4
movq %r15, -0x10(%r15)
leaq 0x18e42f(%rip), %rsi    # 0x2a593b
leaq 0x18e45f(%rip), %rdx    # 0x2a5972
leaq 0xb8(%rsp), %rdi
callq 0x1178ae
leaq 0x208(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x1186a0
testb %al, %al
je 0x117612
movq 0x18(%rsp), %rax
testq %rax, %rax
je 0x11771b
movl $0x1, %r12d
leaq 0x18e430(%rip), %r13    # 0x2a598d
leaq -0x1(%r12), %rcx
cmpq %rax, %rcx
jae 0x11756c
movq %r12, 0x20(%rsp)
testb $0x1, %r12b
movq %rbx, %rax
cmoveq %r14, %rax
movq (%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x30(%rsp), %rcx
cmpq 0x38(%rsp), %rcx
je 0x1175ad
xorl %edx, %edx
movq (%rcx,%rdx,8), %rcx
movq %rax, (%rcx)
incq %rdx
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %rsi
subq %rcx, %rsi
sarq $0x3, %rsi
cmpq %rsi, %rdx
jb 0x11758d
movq %r12, %xmm0
punpckldq 0x189a56(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x189a5e(%rip), %xmm0   # 0x2a1020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
ucomisd 0x189ab5(%rip), %xmm0   # 0x2a10a0
jne 0x1175ef
jnp 0x1175fc
movq %r13, %rdi
movl %r12d, %esi
xorl %eax, %eax
callq 0x114050
incq %r12
movq 0x18(%rsp), %rax
cmpq %rax, %r12
jbe 0x11755d
jmp 0x11771b
movq 0x520(%rsp), %rdi
cmpq %rdi, 0x540(%rsp)
je 0x11766d
movq 0x538(%rsp), %rsi
movq %rdi, %rcx
subq 0x528(%rsp), %rcx
movq %rcx, %rdx
sarq $0x3, %rdx
movabsq $-0x30c30c30c30c30c3, %rax # imm = 0xCF3CF3CF3CF3CF3D
imulq %rdx, %rax
cmpq $-0xa7, %rcx
jl 0x117694
cmpq $0x3, %rax
jb 0x1176b8
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
mulq %rdx
shrq %rdx
jmp 0x1176aa
leaq 0xa8(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movabsq $0x726f727245206f4e, %rax # imm = 0x726F727245206F4E
movq %rax, (%rsi)
movq $0x8, -0x8(%rsi)
movb $0x0, 0x8(%rsi)
jmp 0x1176e4
notq %rax
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
mulq %rdx
shrq %rdx
notq %rdx
imulq $-0x1f8, %rdx, %rdi     # imm = 0xFE08
addq (%rsi,%rdx,8), %rdi
addq %rcx, %rdi
leaq 0xa8(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x38(%rdi), %rsi
movq 0x40(%rdi), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %rdi
callq 0x119ce4
movq 0x98(%rsp), %rsi
movq 0xb8(%rsp), %rdx
leaq 0x18e280(%rip), %rdi    # 0x2a5973
xorl %eax, %eax
callq 0x114050
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x11771b
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x114090
movq 0xb8(%rsp), %rdi
cmpq %r15, %rdi
je 0x117738
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x114090
leaq 0x208(%rsp), %rdi
callq 0x11923c
leaq 0x60(%rsp), %rdi
callq 0x1194fe
leaq 0x8(%rsp), %rdi
callq 0x11954c
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x117770
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x114090
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x11778d
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x114090
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x1177a4
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x114090
addq $0xb30, %rsp            # imm = 0xB30
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
jmp 0x11780e
jmp 0x1177d2
jmp 0x11780e
movq %rax, %rbx
jmp 0x11782e
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x118658
jmp 0x11783b
movq %rax, %rbx
jmp 0x11783b
jmp 0x1177ff
jmp 0x1177dd
jmp 0x1177ff
movq %rax, %rbx
movq 0x208(%rsp), %rdi
cmpq %r12, %rdi
je 0x117845
movq 0x218(%rsp), %rsi
incq %rsi
callq 0x114090
jmp 0x117845
movq %rax, %rbx
jmp 0x117845
movq %rax, %rbx
jmp 0x11784f
movq %rax, %rbx
jmp 0x117883
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r15, %rdi
je 0x11782e
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x114090
leaq 0x208(%rsp), %rdi
callq 0x11923c
leaq 0x60(%rsp), %rdi
callq 0x1194fe
leaq 0x8(%rsp), %rdi
callq 0x11954c
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x117866
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x114090
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x117883
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x114090
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x11789a
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x114090
movq %rbx, %rdi
callq 0x1142e0