// File: /workspace/github_c_makefile_star2_O2/AlexCharlton[P]Hyperscene/hypermath/src/hypermath.c
// Function: hpmLookAt
void hpmLookAt(float *eye, float *obj, float *up, float *mat){
    HPMmat4 *m = (HPMmat4 *) mat;
    HPMpoint f, r, u;
    initMat4(m);
    hpmSubVec(eye, obj, (float *) &f);
    hpmNormalize((float *) &f);
    hpmCross(up, (float *) &f, (float *) &r);
    hpmNormalize((float *) &r);
    hpmCross((float *) &f, (float *) &r, (float *) &u);

    m->_11 = r.x;
    m->_12 = r.y;
    m->_13 = r.z;
    m->_21 = u.x;
    m->_22 = u.y;
    m->_23 = u.z;
    m->_31 = f.x;
    m->_32 = f.y;
    m->_33 = f.z;
    m->_14 =-hpmDot((float *) &r, eye);
    m->_24 =-hpmDot((float *) &u, eye);
    m->_34 =-hpmDot((float *) &f, eye);
    m->_44 = 1.0;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x58, %rsp
movq %rcx, %rbx
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rcx)
movups %xmm0, 0x20(%rcx)
movups %xmm0, 0x10(%rcx)
movups %xmm0, (%rcx)
movss 0x8(%rdi), %xmm2
movaps %xmm2, 0x30(%rsp)
subss 0x8(%rsi), %xmm2
movsd (%rdi), %xmm3
movaps %xmm3, 0x20(%rsp)
movsd (%rsi), %xmm0
subps %xmm0, %xmm3
movaps %xmm3, %xmm0
mulps %xmm3, %xmm0
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movaps %xmm3, %xmm1
mulss %xmm3, %xmm1
addss %xmm0, %xmm1
movaps %xmm2, %xmm0
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
sqrtss %xmm0, %xmm0
divss %xmm0, %xmm2
movaps %xmm2, (%rsp)
shufps $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
divps %xmm0, %xmm3
movaps %xmm3, 0x10(%rsp)
leaq 0x40(%rsp), %rsi
movlps %xmm3, (%rsi)
movss %xmm2, 0x8(%rsi)
leaq 0x4c(%rsp), %r14
movq %rdx, %rdi
movq %r14, %rdx
callq 0x4440
movss (%r14), %xmm2
movss 0x4(%r14), %xmm1
movaps %xmm1, %xmm0
mulss %xmm1, %xmm0
movaps %xmm2, %xmm3
mulss %xmm2, %xmm3
addss %xmm0, %xmm3
movss 0x8(%r14), %xmm0
movaps %xmm0, %xmm4
mulss %xmm0, %xmm4
addss %xmm3, %xmm4
sqrtss %xmm4, %xmm3
divss %xmm3, %xmm2
divss %xmm3, %xmm1
divss %xmm3, %xmm0
movaps %xmm1, %xmm3
movaps (%rsp), %xmm8
mulss %xmm8, %xmm3
movaps 0x10(%rsp), %xmm9
movaps %xmm9, %xmm4
shufps $0x55, %xmm9, %xmm4     # xmm4 = xmm4[1,1],xmm9[1,1]
movaps %xmm2, %xmm5
mulss %xmm4, %xmm5
movaps %xmm4, %xmm6
mulss %xmm0, %xmm6
subss %xmm3, %xmm6
movaps %xmm0, %xmm3
mulss %xmm9, %xmm3
movaps %xmm8, %xmm7
mulss %xmm2, %xmm7
subss %xmm3, %xmm7
movaps %xmm9, %xmm3
mulss %xmm1, %xmm3
subss %xmm5, %xmm3
movss %xmm2, (%rbx)
movss %xmm1, 0x10(%rbx)
movss %xmm0, 0x20(%rbx)
movss %xmm6, 0x4(%rbx)
movss %xmm7, 0x14(%rbx)
movss %xmm3, 0x24(%rbx)
movss %xmm9, 0x8(%rbx)
movss %xmm4, 0x18(%rbx)
movss %xmm8, 0x28(%rbx)
movaps 0x20(%rsp), %xmm5
movaps %xmm5, %xmm4
shufps $0x55, %xmm5, %xmm4     # xmm4 = xmm4[1,1],xmm5[1,1]
unpcklps %xmm7, %xmm1            # xmm1 = xmm1[0],xmm7[0],xmm1[1],xmm7[1]
mulps %xmm4, %xmm1
unpcklps %xmm6, %xmm2            # xmm2 = xmm2[0],xmm6[0],xmm2[1],xmm6[1]
movaps %xmm5, %xmm4
shufps $0x0, %xmm5, %xmm4      # xmm4 = xmm4[0,0],xmm5[0,0]
mulps %xmm2, %xmm4
addps %xmm1, %xmm4
unpcklps %xmm3, %xmm0            # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movaps 0x30(%rsp), %xmm1
mulss %xmm1, %xmm8
unpcklps %xmm1, %xmm1            # xmm1 = xmm1[0,0,1,1]
mulps %xmm0, %xmm1
addps %xmm4, %xmm1
movaps 0x351d(%rip), %xmm0     # 0xa040
xorps %xmm0, %xmm1
movlps %xmm1, 0x30(%rbx)
movaps %xmm5, %xmm1
movaps %xmm9, %xmm2
mulps %xmm9, %xmm1
shufps $0x55, %xmm1, %xmm1     # xmm1 = xmm1[1,1,1,1]
mulss %xmm5, %xmm2
addss %xmm1, %xmm2
addss %xmm8, %xmm2
xorps %xmm0, %xmm2
movss %xmm2, 0x38(%rbx)
movl $0x3f800000, 0x3c(%rbx) # imm = 0x3F800000
addq $0x58, %rsp
popq %rbx
popq %r14
retq