// File: /workspace/github_cpp_makefile_star2_O1/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 0x1b50cb(%rip), %r14    # 0x2ce400
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 0x119ba6
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 0x119ba6
movq 0x48(%rsp), %rax
movq 0x50(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movq %rcx, 0x10(%rsp)
movq %rcx, 0x18(%rsp)
movq %rax, 0x20(%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x28(%rsp)
xorl %eax, %eax
movq %rax, 0x38(%rsp)
movq %rax, 0x40(%rsp)
leaq 0x8(%rsp), %rdi
movl $0x1, %esi
callq 0x119bec
leaq 0x218(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x1b0396(%rip), %rsi    # 0x2c978c
leaq 0x1b0390(%rip), %rdx    # 0x2c978d
leaq 0x208(%rsp), %rdi
callq 0x119b16
leaq 0x8(%rsp), %r15
leaq 0x208(%rsp), %rsi
leaq 0x40(%rsp), %rdx
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x119c34
movq 0x208(%rsp), %rdi
cmpq %r13, %rdi
je 0x119443
movq 0x218(%rsp), %rsi
incq %rsi
callq 0x116090
leaq 0x208(%rsp), %rdi
movq %r13, (%rdi)
leaq 0x1b046c(%rip), %rsi    # 0x2c98c1
leaq 0x1b0466(%rip), %rdx    # 0x2c98c2
callq 0x119b16
movq 0x8(%rsp), %rax
testq %rax, %rax
je 0x119667
movq 0x8(%rax), %r12
testq %r12, %r12
je 0x119667
movq 0x210(%rsp), %rax
testq %rax, %rax
je 0x119667
movq 0x208(%rsp), %rcx
movb (%rcx), %dl
andb $-0x21, %dl
addb $-0x41, %dl
cmpb $0x19, %dl
ja 0x119667
cmpq $0x1, %rax
je 0x1194f7
leaq -0x1(%rax), %rsi
movl $0x1, %edi
xorl %edx, %edx
movb (%rcx,%rdi), %r8b
cmpb $0x5f, %r8b
je 0x1194e7
leal -0x30(%r8), %r9d
cmpb $0xa, %r9b
jb 0x1194e7
movl %r8d, %r9d
andb $-0x21, %r9b
addb $-0x41, %r9b
cmpb $0x1a, %r9b
jb 0x1194e7
cmpq %rsi, %rdi
jae 0x1194f2
cmpb $0x2e, %r8b
jne 0x1194f2
incq %rdi
cmpq %rax, %rdi
setae %dl
jne 0x1194b7
testb $0x1, %dl
je 0x119519
leaq 0x1f0(%r12), %rdi
leaq 0x208(%rsp), %rsi
callq 0x11c214
addq $0x1f8, %r12            # imm = 0x1F8
cmpq %rax, %r12
sete %dl
testb $0x1, %dl
je 0x119667
movq 0x8(%rsp), %rax
testq %rax, %rax
je 0x119637
movq 0x8(%rax), %r12
testq %r12, %r12
je 0x119637
cmpq $0x0, 0x210(%rsp)
je 0x119567
leaq 0x208(%rsp), %rsi
movq %r12, %rdi
callq 0x11c29e
addq $0x8, %r12
movb $0x1, %cl
cmpq %rax, %r12
jne 0x119639
cmpq $0x0, 0x210(%rsp)
je 0x1195a2
movq 0x8(%rsp), %rax
movq 0x8(%rax), %r12
leaq 0x188(%r12), %rdi
leaq 0x208(%rsp), %rsi
callq 0x11c4de
addq $0x190, %r12            # imm = 0x190
movb $0x1, %cl
cmpq %rax, %r12
jne 0x119639
cmpq $0x0, 0x210(%rsp)
je 0x1195d9
movq 0x8(%rsp), %rax
movq 0x8(%rax), %r12
leaq 0x150(%r12), %rdi
leaq 0x208(%rsp), %rsi
callq 0x11c71e
addq $0x158, %r12            # imm = 0x158
movb $0x1, %cl
cmpq %rax, %r12
jne 0x119639
cmpq $0x0, 0x210(%rsp)
je 0x11960a
movq 0x8(%rsp), %rax
movq 0x8(%rax), %r12
leaq 0x38(%r12), %rdi
leaq 0x208(%rsp), %rsi
callq 0x11c95e
addq $0x40, %r12
movb $0x1, %cl
cmpq %rax, %r12
jne 0x119639
movq 0x8(%rsp), %rax
movq 0x8(%rax), %r12
leaq 0x1f0(%r12), %rdi
leaq 0x208(%rsp), %rsi
callq 0x11c214
addq $0x1f8, %r12            # imm = 0x1F8
cmpq %rax, %r12
setne %cl
jmp 0x119639
xorl %ecx, %ecx
testb %cl, %cl
jne 0x119667
cmpq $0x0, 0x18(%rsp)
je 0x119667
movq 0x8(%rsp), %rax
movl $0x150, %edi            # imm = 0x150
addq 0x8(%rax), %rdi
leaq 0x208(%rsp), %rsi
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x11d98e
movq 0x208(%rsp), %rdi
cmpq %r13, %rdi
je 0x119684
movq 0x218(%rsp), %rsi
incq %rsi
callq 0x116090
leaq 0x60(%rsp), %rdi
callq 0x119da2
movq 0x68(%rsp), %rcx
movq 0x70(%rsp), %rax
subq %rcx, %rax
je 0x1196ea
sarq $0x3, %rax
cmpq $0x1, %rax
movq %rax, %rsi
adcq $0x0, %rsi
cmpq %r15, %rcx
je 0x1196f9
movq 0x8(%rsp), %rdx
cmpq (%rcx), %rdx
je 0x1196f9
addq $0x8, %rcx
movl $0x1, %edi
subq %rsi, %rdi
xorl %esi, %esi
cmpq %rsi, %rdi
je 0x1196ea
decq %rsi
cmpq %r15, %rcx
je 0x1196e2
leaq 0x8(%rcx), %r8
cmpq (%rcx), %rdx
movq %r8, %rcx
jne 0x1196c9
negq %rsi
cmpq %rax, %rsi
jb 0x1196f9
leaq 0x68(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x11f880
leaq 0xb8(%rsp), %rdi
movl $0x7f, %esi
callq 0x119e3c
leaq 0x208(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x119f3c
leaq 0x1b8(%rsp), %rdi
callq 0x11fa82
leaq 0x188(%rsp), %rdi
callq 0x11fa82
leaq 0x158(%rsp), %rdi
callq 0x11fa82
leaq 0x128(%rsp), %rdi
callq 0x11fa82
leaq 0xf8(%rsp), %rdi
callq 0x11fa82
leaq 0xc8(%rsp), %r15
movq %r15, %rdi
callq 0x11fa82
movq %r15, -0x10(%r15)
leaq 0x1b0147(%rip), %rsi    # 0x2c98c3
leaq 0x1b0177(%rip), %rdx    # 0x2c98fa
leaq 0xb8(%rsp), %rdi
callq 0x119b16
leaq 0x208(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x11a760
testb %al, %al
je 0x119882
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x119983
movl $0x1, %r12d
leaq 0x1b0148(%rip), %r13    # 0x2c9915
leaq -0x1(%r12), %rcx
cmpq %rax, %rcx
jae 0x1197dc
movq %r12, 0x18(%rsp)
testb $0x1, %r12b
movq %rbx, %rax
cmoveq %r14, %rax
movq (%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x28(%rsp), %rcx
cmpq 0x30(%rsp), %rcx
je 0x11981d
xorl %edx, %edx
movq (%rcx,%rdx,8), %rcx
movq %rax, (%rcx)
incq %rdx
movq 0x28(%rsp), %rcx
movq 0x30(%rsp), %rsi
subq %rcx, %rsi
sarq $0x3, %rsi
cmpq %rsi, %rdx
jb 0x1197fd
movq %r12, %xmm0
punpckldq 0x1ab7e6(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1ab7ee(%rip), %xmm0   # 0x2c5020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd %xmm1, 0x40(%rsp)
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
ucomisd 0x1ab835(%rip), %xmm0   # 0x2c5090
jne 0x11985f
jnp 0x11986c
movq %r13, %rdi
movl %r12d, %esi
xorl %eax, %eax
callq 0x116050
incq %r12
movq 0x10(%rsp), %rax
cmpq %rax, %r12
jbe 0x1197cd
jmp 0x119983
movq 0x520(%rsp), %rdi
cmpq %rdi, 0x540(%rsp)
je 0x1198d9
movq %rdi, %rcx
subq 0x528(%rsp), %rcx
movq %rcx, %rdx
sarq $0x3, %rdx
movabsq $-0x30c30c30c30c30c3, %rax # imm = 0xCF3CF3CF3CF3CF3D
imulq %rdx, %rax
cmpq $0x3, %rax
jb 0x119924
movq 0x538(%rsp), %rsi
testq %rcx, %rcx
jle 0x119900
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
mulq %rdx
shrq %rdx
jmp 0x119916
leaq 0xa8(%rsp), %rax
movq %rax, -0x10(%rax)
movabsq $0x726f727245206f4e, %rcx # imm = 0x726F727245206F4E
movq %rcx, (%rax)
movq $0x8, -0x8(%rax)
movb $0x0, 0x8(%rax)
jmp 0x119948
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 0x11bbe4
leaq 0xa8(%rsp), %rbx
movq -0x10(%rbx), %rsi
movq 0xb8(%rsp), %rdx
leaq 0x1aff98(%rip), %rdi    # 0x2c98fb
xorl %eax, %eax
callq 0x116050
movq -0x10(%rbx), %rdi
cmpq %rbx, %rdi
je 0x119983
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x116090
movq 0xb8(%rsp), %rdi
cmpq %r15, %rdi
je 0x1199a0
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x116090
leaq 0x208(%rsp), %rdi
callq 0x11b132
leaq 0x60(%rsp), %rdi
callq 0x11b3f4
leaq 0x8(%rsp), %rdi
callq 0x11b442
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x1199d8
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x116090
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x1199f5
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x116090
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x119a0c
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x116090
addq $0xb30, %rsp            # imm = 0xB30
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
jmp 0x119a45
jmp 0x119a76
jmp 0x119a3c
jmp 0x119a76
movq %rax, %rbx
jmp 0x119a96
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x11a718
jmp 0x119aa3
movq %rax, %rbx
jmp 0x119aa3
jmp 0x119a67
jmp 0x119a67
movq %rax, %rbx
movq 0x208(%rsp), %rdi
cmpq %r13, %rdi
je 0x119aad
movq 0x218(%rsp), %rsi
incq %rsi
callq 0x116090
jmp 0x119aad
movq %rax, %rbx
jmp 0x119aad
movq %rax, %rbx
jmp 0x119ab7
movq %rax, %rbx
jmp 0x119aeb
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r15, %rdi
je 0x119a96
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x116090
leaq 0x208(%rsp), %rdi
callq 0x11b132
leaq 0x60(%rsp), %rdi
callq 0x11b3f4
leaq 0x8(%rsp), %rdi
callq 0x11b442
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x119ace
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x116090
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x119aeb
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x116090
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x119b02
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x116090
movq %rbx, %rdi
callq 0x1162e0