// File: jamesgrimmett[P]orbital_determination/ex10-1_linear_least_squares.cc
// Function: dot_product(std::vector<std::vector<double, std::allocator<double>>, std::allocator<std::vector<double, std::allocator<double>>>>, std::vector<double, std::allocator<double>>)
std::vector<double> dot_product(std::vector<std::vector<double> > a_, 
                                  std::vector<double> b_) {
  // calculate the dot production of a 2x2 matrix with a 1x2 vector
                          
  std::vector<double> result_ = {0.0, 0.0};
  std::vector<double> a0_ = {a_[0][0], a_[0][1]};
  std::vector<double> a1_ = {a_[1][0], a_[1][1]};

  result_[0] = std::inner_product(a0_.begin(),a0_.end(),b_.begin(),0.0);
  result_[1] = std::inner_product(a1_.begin(),a1_.end(),b_.begin(),0.0);

  return result_;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdx, -0x130(%rbp)
movq %rsi, -0x128(%rbp)
movq %rdi, -0x118(%rbp)
movq %rdi, %rax
movq %rax, -0x120(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movb $0x0, -0x19(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x38(%rbp)
leaq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
movq $0x2, -0x28(%rbp)
leaq -0x41(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x2580
movq -0x118(%rbp), %rdi
movq -0x110(%rbp), %rcx
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x25a0
jmp 0x2127
leaq -0x41(%rbp), %rdi
callq 0x2620
movq -0x128(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movq %rsi, -0x140(%rbp)
callq 0x2760
movq -0x140(%rbp), %rsi
movq %rax, %rdi
callq 0x2780
movq -0x128(%rbp), %rdi
movq -0x140(%rbp), %rsi
movsd (%rax), %xmm0
movsd %xmm0, -0x90(%rbp)
callq 0x2760
movq %rax, %rdi
movl $0x1, %esi
callq 0x2780
movsd (%rax), %xmm0
movsd %xmm0, -0x88(%rbp)
leaq -0x90(%rbp), %rax
movq %rax, -0x80(%rbp)
movq $0x2, -0x78(%rbp)
leaq -0x91(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x2580
movq -0x138(%rbp), %rcx
movq -0x80(%rbp), %rsi
movq -0x78(%rbp), %rdx
leaq -0x70(%rbp), %rdi
callq 0x25a0
jmp 0x21ce
leaq -0x91(%rbp), %rdi
callq 0x2620
movq -0x128(%rbp), %rdi
movl $0x1, %esi
movq %rsi, -0x150(%rbp)
callq 0x2760
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2780
movq -0x128(%rbp), %rdi
movq -0x150(%rbp), %rsi
movsd (%rax), %xmm0
movsd %xmm0, -0xd0(%rbp)
callq 0x2760
movq -0x150(%rbp), %rsi
movq %rax, %rdi
callq 0x2780
movsd (%rax), %xmm0
movsd %xmm0, -0xc8(%rbp)
leaq -0xd0(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq $0x2, -0xb8(%rbp)
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0x2580
movq -0x148(%rbp), %rcx
movq -0xc0(%rbp), %rsi
movq -0xb8(%rbp), %rdx
leaq -0xb0(%rbp), %rdi
callq 0x25a0
jmp 0x2287
leaq -0xd1(%rbp), %rdi
callq 0x2620
leaq -0x70(%rbp), %rdi
movq %rdi, -0x160(%rbp)
callq 0x2ad0
movq -0x160(%rbp), %rdi
movq %rax, -0xe0(%rbp)
callq 0x2b00
movq -0x130(%rbp), %rdi
movq %rax, -0xe8(%rbp)
callq 0x2ad0
movq %rax, -0xf0(%rbp)
movq -0xe0(%rbp), %rdi
movq -0xe8(%rbp), %rsi
movq -0xf0(%rbp), %rdx
xorps %xmm0, %xmm0
callq 0x2a40
movsd %xmm0, -0x158(%rbp)
jmp 0x22f7
movq -0x118(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2780
movsd -0x158(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq -0xb0(%rbp), %rdi
movq %rdi, -0x170(%rbp)
callq 0x2ad0
movq -0x170(%rbp), %rdi
movq %rax, -0xf8(%rbp)
callq 0x2b00
movq -0x130(%rbp), %rdi
movq %rax, -0x100(%rbp)
callq 0x2ad0
movq %rax, -0x108(%rbp)
movq -0xf8(%rbp), %rdi
movq -0x100(%rbp), %rsi
movq -0x108(%rbp), %rdx
xorps %xmm0, %xmm0
callq 0x2a40
movsd %xmm0, -0x168(%rbp)
jmp 0x237a
movq -0x118(%rbp), %rdi
movl $0x1, %esi
callq 0x2780
movsd -0x168(%rbp), %xmm0
movsd %xmm0, (%rax)
movb $0x1, -0x19(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x2700
leaq -0x70(%rbp), %rdi
callq 0x2700
testb $0x1, -0x19(%rbp)
jne 0x2432
jmp 0x2426
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x41(%rbp), %rdi
callq 0x2620
jmp 0x244e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x91(%rbp), %rdi
callq 0x2620
jmp 0x2442
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xd1(%rbp), %rdi
callq 0x2620
jmp 0x241b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x2700
leaq -0x70(%rbp), %rdi
callq 0x2700
jmp 0x2442
movq -0x118(%rbp), %rdi
callq 0x2700
movq -0x120(%rbp), %rax
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
movq -0x118(%rbp), %rdi
callq 0x2700
movq -0x50(%rbp), %rdi
callq 0x1120
nopw (%rax,%rax)