// File: bauerj4[P]Riemann1D/src/Fluxes.cpp
// Function: primativeTo1DConservative(std::vector<double, std::allocator<double>>)
vector<double> primativeTo1DConservative(vector<double> primative)
{
  if (primative.size()!=3)
    {
      printf("INCORRECT PRIMATIVE VARIABLE SIZE!\n");
      return primative;
    }
  double gamma = 1.4;
  double density = primative[0];
  double velocity = primative[1];
  double pressure = primative[2];
  double conservative_2 = density * velocity;
  //primative[1] *= primative[0];
  // Compute energy from pressure
  double int_energy = pressure / (density * (gamma - 1.));
  double kinetic_energy = 0.5 * velocity * velocity;

  double conservative_3 = density * (int_energy + kinetic_energy);
  vector<double> conservative(3,0.0);
  conservative[0] = density;
  conservative[1] = conservative_2;
  conservative[2] = conservative_3;
  //primative[2] = energy * primative[0] + pow(primative[1]/primative[0],2.0);
  return conservative;
}

// Assembly:
subq $0xb8, %rsp
movq %rsi, 0x28(%rsp)
movq %rdi, %rax
movq 0x28(%rsp), %rdi
movq %rax, 0x30(%rsp)
movq %rax, %rcx
movq %rcx, 0x38(%rsp)
movq %rax, 0xb0(%rsp)
movq %rdi, 0xa8(%rsp)
callq 0x12850
cmpq $0x3, %rax
je 0x534e
leaq 0x12fad(%rip), %rdi     # 0x182e0
movb $0x0, %al
callq 0x2040
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x12870
jmp 0x5536
movq 0x28(%rsp), %rdi
movabsq $0x3ff6666666666666, %rax # imm = 0x3FF6666666666666
movq %rax, 0xa0(%rsp)
xorl %eax, %eax
movl %eax, %esi
callq 0x4ff0
movq 0x28(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0x98(%rsp)
movl $0x1, %esi
callq 0x4ff0
movq 0x28(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0x90(%rsp)
movl $0x2, %esi
callq 0x4ff0
movsd (%rax), %xmm0
movsd %xmm0, 0x88(%rsp)
movsd 0x98(%rsp), %xmm0
movsd 0x90(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x80(%rsp)
movsd 0x88(%rsp), %xmm0
movsd 0x98(%rsp), %xmm1
movsd 0xa0(%rsp), %xmm2
movsd 0x12ed3(%rip), %xmm3    # 0x182c8
addsd %xmm3, %xmm2
mulsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x78(%rsp)
movsd 0x90(%rsp), %xmm1
movsd 0x12ea8(%rip), %xmm2    # 0x182c0
movaps %xmm1, %xmm0
mulsd %xmm2, %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x70(%rsp)
movsd 0x98(%rsp), %xmm0
movsd 0x78(%rsp), %xmm1
movsd 0x70(%rsp), %xmm2
addsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x68(%rsp)
movb $0x0, 0x67(%rsp)
movq $0x0, 0x58(%rsp)
leaq 0x57(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x128a0
movq 0x30(%rsp), %rdi
movq 0x20(%rsp), %rcx
movl $0x3, %esi
leaq 0x58(%rsp), %rdx
callq 0x128b0
jmp 0x5484
leaq 0x57(%rsp), %rdi
callq 0x12930
movq 0x30(%rsp), %rdi
movsd 0x98(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
xorl %eax, %eax
movl %eax, %esi
callq 0x4ff0
movsd 0x8(%rsp), %xmm0
movq 0x30(%rsp), %rdi
movsd %xmm0, (%rax)
movsd 0x80(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movl $0x1, %esi
callq 0x4ff0
movsd 0x10(%rsp), %xmm0
movq 0x30(%rsp), %rdi
movsd %xmm0, (%rax)
movsd 0x68(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movl $0x2, %esi
callq 0x4ff0
movsd 0x18(%rsp), %xmm0
movsd %xmm0, (%rax)
movb $0x1, 0x67(%rsp)
testb $0x1, 0x67(%rsp)
jne 0x5534
jmp 0x552a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x48(%rsp)
movl %eax, 0x44(%rsp)
leaq 0x57(%rsp), %rdi
callq 0x12930
jmp 0x5543
movq 0x30(%rsp), %rdi
callq 0x12940
jmp 0x5536
movq 0x38(%rsp), %rax
addq $0xb8, %rsp
retq
movq 0x48(%rsp), %rdi
callq 0x23d0
nopl (%rax)