// File: /workspace/github_cpp_makefile_star2_O3/yukimasano[P]cpp_matrix/Vector.cpp
// Function: operator+(Vector const&, Vector const&)
Vector operator+(const Vector& v1, 
                        const Vector& v2)
{
  int n;

  //  set n to be the length of the longest vector and create a vector
  //  of that length to be returned
  if (v1.mSize > v2.mSize)
    {
      n = v1.mSize;
    }
  else
    {
      n = v2.mSize;
    }
  Vector w(n);


  //  add the vectors
  //  if one vector is shorter than the other assume missing entries are 0
  if (v1.mSize == v2.mSize)
  {
      for (int i=0; i<v1.mSize; i++)
	{
	  w.mData[i] = v1.mData[i] + v2.mData[i];
	}
  }
  else if (v1.mSize > v2.mSize)
  {
      for (int i=0; i<v2.mSize; i++)
	{
	  w.mData[i] = v1.mData[i] + v2.mData[i];
	}
      for (int i=v2.mSize; i<v1.mSize; i++)
	{
	  w.mData[i] = v1.mData[i];
	}
      std::cerr<<"vector add - vectors different lengths\n";
      std::cerr<<"extra entries of shorter vector assumed to be 0.0\n";
  }

  else
  {
      for (int i=0; i<v1.mSize; i++)
	{
	  w.mData[i] = v1.mData[i] + v2.mData[i];
	}
      for (int i=v1.mSize; i<v2.mSize; i++)
	{
	  w.mData[i] = v2.mData[i];
	}
      std::cerr<<"vector add - vectors different lengths\n";
      std::cerr<<"extra entries of shorter vector assumed to be 0.0\n";
  }
  return w;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r12
movq %rsi, 0x8(%rsp)
movl 0x8(%rsi), %ebp
movq %rdx, (%rsp)
movl 0x8(%rdx), %r15d
cmpl %r15d, %ebp
movl %r15d, %ebx
cmovgl %ebp, %ebx
leaq (,%rbx,8), %r13
testl %ebx, %ebx
movq $-0x1, %rdi
cmovnsq %r13, %rdi
callq 0x2030
movq %rax, %r14
movq %rax, (%r12)
movq %r12, 0x10(%rsp)
movl %ebx, 0x8(%r12)
testl %ebx, %ebx
jle 0x82f1
movq %r14, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x20a0
cmpl %r15d, %ebp
jne 0x832c
testl %ebp, %ebp
jle 0x8401
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq (%rsp), %rcx
movq (%rcx), %rcx
xorl %edx, %edx
movsd (%rax,%rdx,8), %xmm0
addsd (%rcx,%rdx,8), %xmm0
movsd %xmm0, (%r14,%rdx,8)
incq %rdx
cmpq %rdx, %rbp
jne 0x830f
jmp 0x8401
movslq %r15d, %rax
cmpl %r15d, %ebp
jle 0x8382
testl %r15d, %r15d
jle 0x8362
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movq (%rsp), %rdx
movq (%rdx), %rdx
xorl %esi, %esi
movsd (%rcx,%rsi,8), %xmm0
addsd (%rdx,%rsi,8), %xmm0
movsd %xmm0, (%r14,%rsi,8)
incq %rsi
cmpq %rsi, %r15
jne 0x834a
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movslq %ebp, %rdx
movsd (%rcx,%rax,8), %xmm0
movsd %xmm0, (%r14,%rax,8)
incq %rax
cmpq %rax, %rdx
jne 0x836d
jmp 0x83d1
testl %ebp, %ebp
jle 0x83af
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movq (%rsp), %rdx
movq (%rdx), %rdx
xorl %esi, %esi
movsd (%rcx,%rsi,8), %xmm0
addsd (%rdx,%rsi,8), %xmm0
movsd %xmm0, (%r14,%rsi,8)
incq %rsi
cmpq %rsi, %rbp
jne 0x8397
cmpl %r15d, %ebp
jge 0x83d1
movslq %ebp, %rcx
movq (%rsp), %rdx
movq (%rdx), %rdx
movsd (%rdx,%rcx,8), %xmm0
movsd %xmm0, (%r14,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x83be
movq 0x4c18(%rip), %rdi      # 0xcff0
leaq 0x1131(%rip), %rsi      # 0x9510
movl $0x27, %edx
callq 0x2160
movq 0x4c00(%rip), %rdi      # 0xcff0
leaq 0x1141(%rip), %rsi      # 0x9538
movl $0x32, %edx
callq 0x2160
movq 0x10(%rsp), %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %r14, %rdi
callq 0x2170
movq %rbx, %rdi
callq 0x21f0