// File: /workspace/github_cpp_makefile_star2_O1/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, (%rsp)
movl 0x8(%rsi), %r13d
movq %rdx, 0x8(%rsp)
movl 0x8(%rdx), %ebp
cmpl %ebp, %r13d
movl %ebp, %ebx
cmovgl %r13d, %ebx
movslq %ebx, %r15
leaq (,%r15,8), %rax
testl %r15d, %r15d
movq $-0x1, %rdi
cmovnsq %rax, %rdi
callq 0x2030
movq %rax, %r14
movq %rax, (%r12)
movq %r12, 0x10(%rsp)
movl %r15d, 0x8(%r12)
testl %r15d, %r15d
jle 0x838b
movl %ebx, %edx
shlq $0x3, %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x20a0
cmpl %ebp, %r13d
jne 0x83c7
testl %r13d, %r13d
jle 0x84a1
movq (%rsp), %rax
movq (%rax), %rax
movq 0x8(%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, %r13
jne 0x83aa
jmp 0x84a1
movslq %ebp, %rax
cmpl %ebp, %r13d
jle 0x8420
testl %ebp, %ebp
jle 0x83fc
movq (%rsp), %rcx
movq (%rcx), %rcx
movq 0x8(%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 0x83e4
cmpl %r13d, %ebp
jge 0x8471
movq (%rsp), %rcx
movq (%rcx), %rcx
movslq %r13d, %rdx
movsd (%rcx,%rax,8), %xmm0
movsd %xmm0, (%r14,%rax,8)
incq %rax
cmpq %rax, %rdx
jne 0x840b
jmp 0x8471
testl %r13d, %r13d
jle 0x844e
movq (%rsp), %rcx
movq (%rcx), %rcx
movq 0x8(%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, %r13
jne 0x8436
cmpl %ebp, %r13d
jge 0x8471
movslq %r13d, %rcx
movq 0x8(%rsp), %rdx
movq (%rdx), %rdx
movsd (%rdx,%rcx,8), %xmm0
movsd %xmm0, (%r14,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x845e
movq 0x5b78(%rip), %rdi      # 0xdff0
leaq 0x2091(%rip), %rsi      # 0xa510
movl $0x27, %edx
callq 0x2160
movq 0x5b60(%rip), %rdi      # 0xdff0
leaq 0x20a1(%rip), %rsi      # 0xa538
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