// File: /workspace/github_c_makefile_star2_O0/archer1357[P]Offline-Raytracer/math.c
// Function: mat4_lookAt
void mat4_lookAt(float *out,
                 float px,float py,float pz,
                 float ax,float ay,float az,
                 float ux,float uy,float uz) {
  //untested

  float eye[3]={px,py,pz};
  float at[3]={ax,ay,az};
  float up[3]={ux,uy,uz};

  float zaxis[3],xaxis[3],yaxis[3];

  vec3_sub(zaxis,at,eye);
  vec3_normal(zaxis,zaxis);

  vec3_cross(xaxis,zaxis,up);
  vec3_normal(xaxis,xaxis);

  vec3_cross(yaxis,xaxis,zaxis);
  vec3_normal(yaxis,yaxis);

  out[0]=xaxis[0];
  out[1]=yaxis[0];
  out[2]=zaxis[0];
  out[3]=0.0f;

  out[4]=xaxis[1];
  out[5]=yaxis[1];
  out[6]=zaxis[1];
  out[7]=0.0f;


  out[8]=xaxis[2];
  out[9]=yaxis[2];
  out[10]=zaxis[2];
  out[11]=0.0f;

  out[12]=-vec3_dot(xaxis,eye);
  out[13]=-vec3_dot(yaxis,eye);
  out[14]=-vec3_dot(zaxis,eye);
  out[15]=1.0f;

  //wrong handed? row major?
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movss 0x10(%rbp), %xmm8
movq %rdi, -0x8(%rbp)
movss %xmm0, -0xc(%rbp)
movss %xmm1, -0x10(%rbp)
movss %xmm2, -0x14(%rbp)
movss %xmm3, -0x18(%rbp)
movss %xmm4, -0x1c(%rbp)
movss %xmm5, -0x20(%rbp)
movss %xmm6, -0x24(%rbp)
movss %xmm7, -0x28(%rbp)
movss -0xc(%rbp), %xmm0
movss %xmm0, -0x34(%rbp)
movss -0x10(%rbp), %xmm0
movss %xmm0, -0x30(%rbp)
movss -0x14(%rbp), %xmm0
movss %xmm0, -0x2c(%rbp)
movss -0x18(%rbp), %xmm0
movss %xmm0, -0x40(%rbp)
movss -0x1c(%rbp), %xmm0
movss %xmm0, -0x3c(%rbp)
movss -0x20(%rbp), %xmm0
movss %xmm0, -0x38(%rbp)
movss -0x24(%rbp), %xmm0
movss %xmm0, -0x4c(%rbp)
movss -0x28(%rbp), %xmm0
movss %xmm0, -0x48(%rbp)
movss 0x10(%rbp), %xmm0
movss %xmm0, -0x44(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x40(%rbp), %rsi
leaq -0x34(%rbp), %rdx
callq 0x40cae0
leaq -0x58(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x40ca00
leaq -0x64(%rbp), %rdi
leaq -0x58(%rbp), %rsi
leaq -0x4c(%rbp), %rdx
callq 0x40c890
leaq -0x64(%rbp), %rdi
leaq -0x64(%rbp), %rsi
callq 0x40ca00
leaq -0x70(%rbp), %rdi
leaq -0x64(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0x40c890
leaq -0x70(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x40ca00
movss -0x64(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, (%rax)
movss -0x70(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x4(%rax)
movss -0x58(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x8(%rax)
movq -0x8(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0xc(%rax)
movss -0x60(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x10(%rax)
movss -0x6c(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x14(%rax)
movss -0x54(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x18(%rax)
movq -0x8(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x1c(%rax)
movss -0x5c(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x20(%rax)
movss -0x68(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x24(%rax)
movss -0x50(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x28(%rax)
movq -0x8(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x2c(%rax)
leaq -0x64(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0x40c970
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x30(%rax)
leaq -0x70(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0x40c970
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x34(%rax)
leaq -0x58(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0x40c970
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x38(%rax)
movq -0x8(%rbp), %rax
movss 0xd3cc0(%rip), %xmm0    # 0x4e3484
movss %xmm0, 0x3c(%rax)
addq $0x70, %rsp
popq %rbp
retq
nop