// File: 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 %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0xb8(%rbp)
movq %rdi, %rax
movq %rax, -0xe8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
movq %rdi, %rsi
addq $0xc, %rsi
callq 0x5cd0
movss %xmm1, -0x38(%rbp)
movlpd %xmm0, -0x40(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x28(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
leaq -0x30(%rbp), %rdi
movss 0x9f25(%rip), %xmm0     # 0xf004
movss %xmm0, -0xd4(%rbp)
callq 0x5d40
movq -0xe0(%rbp), %rdi
movl 0x8(%rax), %ecx
movl %ecx, -0x18(%rbp)
movq (%rax), %rax
movq %rax, -0x20(%rbp)
addq $0x18, %rdi
leaq -0x20(%rbp), %rsi
movq %rsi, -0xc0(%rbp)
callq 0x5db0
movaps %xmm0, %xmm2
movss -0xd4(%rbp), %xmm0
movaps %xmm2, -0xd0(%rbp)
movaps %xmm1, %xmm2
movaps -0xd0(%rbp), %xmm1
movss %xmm2, -0x68(%rbp)
movlpd %xmm1, -0x70(%rbp)
movl -0x68(%rbp), %eax
movl %eax, -0x58(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x60(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x5d40
movq -0xc0(%rbp), %rdi
movl 0x8(%rax), %ecx
movl %ecx, -0x48(%rbp)
movq (%rax), %rax
movq %rax, -0x50(%rbp)
leaq -0x50(%rbp), %rsi
callq 0x5db0
movss %xmm1, -0x90(%rbp)
movlpd %xmm0, -0x98(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0x88(%rbp)
movl -0x90(%rbp), %eax
movl %eax, -0x80(%rbp)
leaq -0x88(%rbp), %rdi
movss 0x9e60(%rip), %xmm0     # 0xf004
callq 0x5d40
movq -0xb8(%rbp), %rdi
movq (%rax), %rcx
movq %rcx, -0x7c(%rbp)
movl 0x8(%rax), %eax
movl %eax, -0x74(%rbp)
movb $0x0, -0x99(%rbp)
movl $0x4, %esi
callq 0x2780
movl $0x0, -0xa0(%rbp)
cmpl $0x3, -0xa0(%rbp)
jge 0x53bb
movslq -0xa0(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x5c40
movq %rax, -0xf0(%rbp)
jmp 0x51fe
movq -0xb8(%rbp), %rdi
movq -0xf0(%rbp), %rax
movss (%rax), %xmm0
movss %xmm0, -0xfc(%rbp)
xorl %esi, %esi
callq 0x2890
movq %rax, -0xf8(%rbp)
jmp 0x5228
movq -0xf8(%rbp), %rdi
movslq -0xa0(%rbp), %rsi
callq 0x33c0
movss -0xfc(%rbp), %xmm0
movss %xmm0, (%rax)
movslq -0xa0(%rbp), %rsi
leaq -0x7c(%rbp), %rdi
callq 0x5c40
movq %rax, -0x108(%rbp)
jmp 0x5260
movq -0xb8(%rbp), %rdi
movq -0x108(%rbp), %rax
movss (%rax), %xmm0
movss %xmm0, -0x114(%rbp)
movl $0x1, %esi
callq 0x2890
movq %rax, -0x110(%rbp)
jmp 0x528d
movq -0x110(%rbp), %rdi
movslq -0xa0(%rbp), %rsi
callq 0x33c0
movss -0x114(%rbp), %xmm0
movss %xmm0, (%rax)
movslq -0xa0(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x5c40
movq %rax, -0x120(%rbp)
jmp 0x52c5
movq -0xb8(%rbp), %rdi
movq -0x120(%rbp), %rax
movss (%rax), %xmm0
movss %xmm0, -0x12c(%rbp)
movl $0x2, %esi
callq 0x2890
movq %rax, -0x128(%rbp)
jmp 0x52f2
movq -0x128(%rbp), %rdi
movslq -0xa0(%rbp), %rsi
callq 0x33c0
movss -0x12c(%rbp), %xmm0
movq -0xe0(%rbp), %rdi
movss %xmm0, (%rax)
addq $0xc, %rdi
movslq -0xa0(%rbp), %rsi
callq 0x5c40
movq %rax, -0x138(%rbp)
jmp 0x5331
movq -0xb8(%rbp), %rdi
movq -0x138(%rbp), %rax
movss (%rax), %xmm0
movaps 0x9db6(%rip), %xmm1     # 0xf100
pxor %xmm1, %xmm0
movss %xmm0, -0x144(%rbp)
movl -0xa0(%rbp), %esi
callq 0x2890
movq %rax, -0x140(%rbp)
jmp 0x536a
movq -0x140(%rbp), %rdi
movl $0x3, %esi
callq 0x33c0
movss -0x144(%rbp), %xmm0
movss %xmm0, (%rax)
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
jmp 0x51d8
movq -0xb8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
callq 0x33e0
jmp 0x53e7
movb $0x1, -0x99(%rbp)
testb $0x1, -0x99(%rbp)
jne 0x53d7
movq -0xb8(%rbp), %rdi
callq 0x33e0
movq -0xe8(%rbp), %rax
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq -0xa8(%rbp), %rdi
callq 0x2380
nopw %cs:(%rax,%rax)