// File: jamesgrimmett[P]orbital_determination/ex10-1_linear_least_squares.cc
// Function: inverse(std::vector<std::vector<double, std::allocator<double>>, std::allocator<std::vector<double, std::allocator<double>>>>)
std::vector<std::vector<double> > inverse(std::vector<std::vector<double> > arr_) {
  // Calculate the inverse of a 2x2 matrix

  int i, j;
  // tmp variable to store matrix elements
  std::vector<std::vector<double> > inv_ = arr_;
  
  double det_ = determinant(arr_);

  inv_[0][0] = arr_[1][1];
  inv_[1][1] = arr_[0][0];
  inv_[0][1] = -arr_[1][0];
  inv_[1][0] = -arr_[0][1];


  for ( i = 0; i < 2; i++ ) {
    for ( j = 0; j < 2; j++ ) {
      inv_[i][j] = inv_[i][j] / det_;
    }
  }

  return inv_;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rsi, -0x58(%rbp)
movq %rdi, -0x68(%rbp)
movq %rdi, %rax
movq %rax, -0x60(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, -0x19(%rbp)
callq 0x27a0
movq -0x58(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x27a0
jmp 0x1e5a
leaq -0x40(%rbp), %rdi
callq 0x2460
movsd %xmm0, -0x90(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x28c0
movsd -0x90(%rbp), %xmm0
movq -0x58(%rbp), %rdi
movsd %xmm0, -0x28(%rbp)
movl $0x1, %esi
callq 0x2760
movq %rax, %rdi
movl $0x1, %esi
callq 0x2780
movq -0x68(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x88(%rbp)
xorl %eax, %eax
movl %eax, %esi
callq 0x2760
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2780
movsd -0x88(%rbp), %xmm0
movq -0x58(%rbp), %rdi
movsd %xmm0, (%rax)
xorl %eax, %eax
movl %eax, %esi
callq 0x2760
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2780
movq -0x68(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x80(%rbp)
movl $0x1, %esi
callq 0x2760
movq %rax, %rdi
movl $0x1, %esi
callq 0x2780
movsd -0x80(%rbp), %xmm0
movq -0x58(%rbp), %rdi
movsd %xmm0, (%rax)
movl $0x1, %esi
callq 0x2760
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2780
movq -0x68(%rbp), %rdi
movsd (%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x78(%rbp)
xorl %eax, %eax
movl %eax, %esi
callq 0x2760
movq %rax, %rdi
movl $0x1, %esi
callq 0x2780
movsd -0x78(%rbp), %xmm0
movq -0x58(%rbp), %rdi
movsd %xmm0, (%rax)
xorl %eax, %eax
movl %eax, %esi
callq 0x2760
movq %rax, %rdi
movl $0x1, %esi
callq 0x2780
movq -0x68(%rbp), %rdi
movsd (%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x70(%rbp)
movl $0x1, %esi
callq 0x2760
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2780
movsd -0x70(%rbp), %xmm0
movsd %xmm0, (%rax)
movl $0x0, -0x14(%rbp)
cmpl $0x2, -0x14(%rbp)
jge 0x206c
movl $0x0, -0x18(%rbp)
cmpl $0x2, -0x18(%rbp)
jge 0x205c
movq -0x68(%rbp), %rdi
movslq -0x14(%rbp), %rsi
callq 0x2760
movq %rax, %rdi
movslq -0x18(%rbp), %rsi
callq 0x2780
movq -0x68(%rbp), %rdi
movsd (%rax), %xmm0
divsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
movslq -0x14(%rbp), %rsi
callq 0x2760
movq %rax, %rdi
movslq -0x18(%rbp), %rsi
callq 0x2780
movsd -0x98(%rbp), %xmm0
movsd %xmm0, (%rax)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1fe5
movq -0x68(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
callq 0x28c0
jmp 0x208c
jmp 0x205e
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1fd4
movb $0x1, -0x19(%rbp)
testb $0x1, -0x19(%rbp)
jne 0x207f
movq -0x68(%rbp), %rdi
callq 0x28c0
movq -0x60(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x1120
nopw %cs:(%rax,%rax)