// File: 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);


//  subtract 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 subtract - 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 subtract - vectors different lengths\n";
      std::cerr<<"extra entries of shorter vector assumed to be 0.0\n";
    }
  return w;
}

// Assembly:
subq $0x58, %rsp
movq %rdi, (%rsp)
movq %rdi, %rax
movq %rax, 0x8(%rsp)
movq %rdi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movq %rdx, 0x40(%rsp)
movq 0x48(%rsp), %rax
movl 0x8(%rax), %eax
movq 0x40(%rsp), %rcx
cmpl 0x8(%rcx), %eax
jle 0xd4af
movq 0x48(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, 0x3c(%rsp)
jmp 0xd4bb
movq 0x40(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, 0x3c(%rsp)
movq (%rsp), %rdi
movb $0x0, 0x3b(%rsp)
movl 0x3c(%rsp), %esi
callq 0xd040
movq 0x48(%rsp), %rax
movl 0x8(%rax), %eax
movq 0x40(%rsp), %rcx
cmpl 0x8(%rcx), %eax
jne 0xd53c
movl $0x0, 0x34(%rsp)
movl 0x34(%rsp), %eax
movq 0x48(%rsp), %rcx
cmpl 0x8(%rcx), %eax
jge 0xd537
movq (%rsp), %rax
movq 0x48(%rsp), %rcx
movq (%rcx), %rcx
movslq 0x34(%rsp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x40(%rsp), %rcx
movq (%rcx), %rcx
movslq 0x34(%rsp), %rdx
subsd (%rcx,%rdx,8), %xmm0
movq (%rax), %rax
movslq 0x34(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0xd4e7
jmp 0xd70f
movq 0x48(%rsp), %rax
movl 0x8(%rax), %eax
movq 0x40(%rsp), %rcx
cmpl 0x8(%rcx), %eax
jle 0xd63f
movl $0x0, 0x30(%rsp)
movl 0x30(%rsp), %eax
movq 0x40(%rsp), %rcx
cmpl 0x8(%rcx), %eax
jge 0xd5aa
movq (%rsp), %rax
movq 0x48(%rsp), %rcx
movq (%rcx), %rcx
movslq 0x30(%rsp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x40(%rsp), %rcx
movq (%rcx), %rcx
movslq 0x30(%rsp), %rdx
subsd (%rcx,%rdx,8), %xmm0
movq (%rax), %rax
movslq 0x30(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
jmp 0xd55a
movq 0x40(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, 0x2c(%rsp)
movl 0x2c(%rsp), %eax
movq 0x48(%rsp), %rcx
cmpl 0x8(%rcx), %eax
jge 0xd5f4
movq (%rsp), %rax
movq 0x48(%rsp), %rcx
movq (%rcx), %rcx
movslq 0x2c(%rsp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq (%rax), %rax
movslq 0x2c(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0xd5b6
movq 0x49f5(%rip), %rdi      # 0x11ff0
leaq 0x1f39(%rip), %rsi      # 0xf53b
callq 0x2110
jmp 0xd609
movq 0x49e0(%rip), %rdi      # 0x11ff0
leaq 0x1ef1(%rip), %rsi      # 0xf508
callq 0x2110
jmp 0xd61e
jmp 0xd70d
movq (%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x20(%rsp)
movl %eax, 0x1c(%rsp)
callq 0xd170
jmp 0xd72e
movl $0x0, 0x18(%rsp)
movl 0x18(%rsp), %eax
movq 0x48(%rsp), %rcx
cmpl 0x8(%rcx), %eax
jge 0xd697
movq (%rsp), %rax
movq 0x48(%rsp), %rcx
movq (%rcx), %rcx
movslq 0x18(%rsp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x40(%rsp), %rcx
movq (%rcx), %rcx
movslq 0x18(%rsp), %rdx
subsd (%rcx,%rdx,8), %xmm0
movq (%rax), %rax
movslq 0x18(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18(%rsp)
jmp 0xd647
movq 0x48(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, 0x14(%rsp)
movl 0x14(%rsp), %eax
movq 0x40(%rsp), %rcx
cmpl 0x8(%rcx), %eax
jge 0xd6e1
movq (%rsp), %rax
movq 0x40(%rsp), %rcx
movq (%rcx), %rcx
movslq 0x14(%rsp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq (%rax), %rax
movslq 0x14(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0xd6a3
movq 0x4908(%rip), %rdi      # 0x11ff0
leaq 0x1e4c(%rip), %rsi      # 0xf53b
callq 0x2110
jmp 0xd6f6
movq 0x48f3(%rip), %rdi      # 0x11ff0
leaq 0x1e04(%rip), %rsi      # 0xf508
callq 0x2110
jmp 0xd70b
jmp 0xd70d
jmp 0xd70f
movb $0x1, 0x3b(%rsp)
testb $0x1, 0x3b(%rsp)
jne 0xd724
movq (%rsp), %rdi
callq 0xd170
movq 0x8(%rsp), %rax
addq $0x58, %rsp
retq
movq 0x20(%rsp), %rdi
callq 0x21e0
nopl (%rax,%rax)