// File: /workspace/github_cpp_makefile_star2_O3/SpiritLooper[P]RDV_OBJRender/camera.cpp
// Function: Camera::lookat()
Matrix Camera::lookat() {
    Vec3f z = (eye-center).normalize();
    Vec3f x = (up^z).normalize();
    Vec3f y = (z^x).normalize();
    Matrix res = Matrix::identity(4);
    for (int i=0; i<3; i++) {
        res[0][i] = x[i];
        res[1][i] = y[i];
        res[2][i] = z[i];
        res[i][3] = -center[i];
    }
    return res;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movss 0x8(%rsi), %xmm0
subss 0x14(%rsi), %xmm0
movsd (%rsi), %xmm3
movsd 0xc(%rsi), %xmm1
subps %xmm1, %xmm3
movaps %xmm3, %xmm1
mulps %xmm3, %xmm1
shufps $0x55, %xmm1, %xmm1     # xmm1 = xmm1[1,1,1,1]
movaps %xmm3, %xmm2
mulss %xmm3, %xmm2
addss %xmm1, %xmm2
movaps %xmm0, %xmm1
mulss %xmm0, %xmm1
addss %xmm2, %xmm1
sqrtss %xmm1, %xmm4
movss 0x39f3(%rip), %xmm1     # 0x7040
movaps %xmm1, %xmm2
divss %xmm4, %xmm2
mulss %xmm2, %xmm0
shufps $0x0, %xmm2, %xmm2      # xmm2 = xmm2[0,0,0,0]
mulps %xmm3, %xmm2
movlps %xmm2, 0x38(%rsp)
movss %xmm0, 0x40(%rsp)
movaps %xmm2, %xmm4
shufps $0x55, %xmm2, %xmm4     # xmm4 = xmm4[1,1],xmm2[1,1]
movss 0x18(%rsi), %xmm3
movsd 0x1c(%rsi), %xmm6
movaps %xmm3, %xmm7
shufps $0xd4, %xmm6, %xmm7     # xmm7 = xmm7[0,1],xmm6[1,3]
shufps $0x52, %xmm6, %xmm7     # xmm7 = xmm7[2,0],xmm6[1,1]
movaps %xmm2, %xmm5
shufps $0xe1, %xmm2, %xmm5     # xmm5 = xmm5[1,0],xmm2[2,3]
movaps %xmm0, %xmm8
shufps $0xd4, %xmm2, %xmm8     # xmm8 = xmm8[0,1],xmm2[1,3]
shufps $0xe2, %xmm2, %xmm8     # xmm8 = xmm8[2,0],xmm2[2,3]
mulps %xmm7, %xmm8
movss %xmm0, %xmm5            # xmm5 = xmm0[0],xmm5[1,2,3]
mulps %xmm6, %xmm5
subps %xmm8, %xmm5
mulss %xmm2, %xmm6
mulss %xmm4, %xmm3
subss %xmm6, %xmm3
movaps %xmm5, %xmm6
mulps %xmm5, %xmm6
shufps $0x55, %xmm6, %xmm6     # xmm6 = xmm6[1,1,1,1]
movaps %xmm5, %xmm7
mulss %xmm5, %xmm7
addss %xmm6, %xmm7
movaps %xmm3, %xmm6
mulss %xmm3, %xmm6
addss %xmm7, %xmm6
xorps %xmm7, %xmm7
sqrtss %xmm6, %xmm7
movaps %xmm1, %xmm6
divss %xmm7, %xmm6
mulss %xmm6, %xmm3
shufps $0x0, %xmm6, %xmm6      # xmm6 = xmm6[0,0,0,0]
mulps %xmm5, %xmm6
movlps %xmm6, 0x28(%rsp)
movss %xmm3, 0x30(%rsp)
movaps %xmm6, %xmm5
shufps $0x55, %xmm6, %xmm5     # xmm5 = xmm5[1,1],xmm6[1,1]
movaps %xmm5, %xmm7
mulss %xmm0, %xmm7
mulss %xmm6, %xmm0
mulss %xmm4, %xmm6
mulss %xmm3, %xmm4
subss %xmm7, %xmm4
mulss %xmm2, %xmm3
subss %xmm3, %xmm0
mulss %xmm2, %xmm5
subss %xmm6, %xmm5
movaps %xmm0, %xmm2
mulss %xmm0, %xmm2
movaps %xmm4, %xmm3
mulss %xmm4, %xmm3
addss %xmm2, %xmm3
movaps %xmm5, %xmm2
mulss %xmm5, %xmm2
addss %xmm3, %xmm2
sqrtss %xmm2, %xmm2
divss %xmm2, %xmm1
mulss %xmm1, %xmm4
mulss %xmm1, %xmm0
unpcklps %xmm0, %xmm4            # xmm4 = xmm4[0],xmm0[0],xmm4[1],xmm0[1]
mulss %xmm5, %xmm1
movlps %xmm4, 0x18(%rsp)
movss %xmm1, 0x20(%rsp)
movl $0x4, %esi
callq 0x267c
xorl %r15d, %r15d
xorl %eax, %eax
cmpq $0x1, %r15
setne %al
testq %r15, %r15
leaq 0x4(,%rax,4), %r12
cmoveq %r15, %r12
movss 0x28(%rsp,%r12), %xmm0
movss %xmm0, (%rsp)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x26fe
movq (%rax), %rax
movss (%rsp), %xmm0
movss %xmm0, (%rax,%r15,4)
movss 0x18(%rsp,%r12), %xmm0
movss %xmm0, (%rsp)
movq %rbx, %rdi
movl $0x1, %esi
callq 0x26fe
movq (%rax), %rax
movss (%rsp), %xmm0
movss %xmm0, (%rax,%r15,4)
movss 0x38(%rsp,%r12), %xmm0
movss %xmm0, (%rsp)
movq %rbx, %rdi
movl $0x2, %esi
callq 0x26fe
movq (%rax), %rax
movss (%rsp), %xmm0
movss %xmm0, (%rax,%r15,4)
movss 0xc(%r14,%r12), %xmm0
movaps %xmm0, (%rsp)
movq %rbx, %rdi
movl %r15d, %esi
callq 0x26fe
movaps (%rsp), %xmm0
xorps 0x3811(%rip), %xmm0     # 0x7030
movq (%rax), %rax
movss %xmm0, 0xc(%rax)
incq %r15
cmpq $0x3, %r15
jne 0x3774
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %r14
movq %rbx, %rdi
callq 0x2f62
movq %r14, %rdi
callq 0x22d0