// File: XuhuiSun95[P]My-OpenGL/myGL.cpp
// Function: myLookAt(double, double, double, double, double, double, double, double, double)
void myLookAt(double eyeX, double eyeY, double eyeZ, double centerX, double centerY, double centerZ, double upX, double upY, double upZ){
    double fx, fy, fz;
    double rlf, rls;
    double sx, sy, sz;
    double ux, uy, uz;
    fx = centerX - eyeX;
    fy = centerY - eyeY;
    fz = centerZ - eyeZ;
    
    rlf = 1.0f / sqrt(fx * fx + fy * fy + fz * fz);
    fx *= rlf;
    fy *= rlf;
    fz *= rlf;
    
    sx = fy * upZ - fz * upY;
    sy = fz * upX - fx * upZ;
    sz = fx * upY - fy * upX;
    
    rls = 1.0f / sqrt(sx * sx + sy * sy + sz * sz);
    sx *= rls;
    sy *= rls;
    sz *= rls;
    
    ux = sy * fz - sz * fy;
    uy = sz * fx - sx * fz;
    uz = sx * fy - sy * fx;
    
    double matrix[4][4], omatrix[4][4];
    matrix[0][0] = sx; matrix[0][1] = sy; matrix[0][2] = sz; matrix[0][3] = 0;
    matrix[1][0] = ux; matrix[1][1] = uy; matrix[1][2] = uz; matrix[1][3] = 0;
    matrix[2][0] = -fx; matrix[2][1] = -fy; matrix[2][2] = -fz; matrix[2][3] = 0;
    matrix[3][0] = 0; matrix[3][1] = 0; matrix[3][2] = 0; matrix[3][3] = 1;
    multiMatrix(modelMatrix, matrix, omatrix);
    for(int i = 0; i < 4; i ++){
        for(int j = 0; j < 4; j ++)
            modelMatrix[i][j] = omatrix[i][j];
    }
    myTranslated(-eyeX, -eyeY, -eyeZ);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movsd 0x10(%rbp), %xmm8
movsd %xmm0, -0x8(%rbp)
movsd %xmm1, -0x10(%rbp)
movsd %xmm2, -0x18(%rbp)
movsd %xmm3, -0x20(%rbp)
movsd %xmm4, -0x28(%rbp)
movsd %xmm5, -0x30(%rbp)
movsd %xmm6, -0x38(%rbp)
movsd %xmm7, -0x40(%rbp)
movsd -0x20(%rbp), %xmm0
subsd -0x8(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x28(%rbp), %xmm0
subsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x30(%rbp), %xmm0
subsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x48(%rbp), %xmm1
movsd -0x48(%rbp), %xmm2
movsd -0x50(%rbp), %xmm0
mulsd -0x50(%rbp), %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd -0x58(%rbp), %xmm0
movsd -0x58(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x10e0
movaps %xmm0, %xmm1
movsd 0x981c(%rip), %xmm0     # 0xe040
divsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x60(%rbp), %xmm0
mulsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x60(%rbp), %xmm0
mulsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x60(%rbp), %xmm0
mulsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x50(%rbp), %xmm0
movsd 0x10(%rbp), %xmm2
movsd -0x58(%rbp), %xmm1
mulsd -0x40(%rbp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x58(%rbp), %xmm0
movsd -0x38(%rbp), %xmm2
movsd -0x48(%rbp), %xmm1
mulsd 0x10(%rbp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x48(%rbp), %xmm0
movsd -0x40(%rbp), %xmm2
movsd -0x50(%rbp), %xmm1
mulsd -0x38(%rbp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0x70(%rbp), %xmm1
movsd -0x70(%rbp), %xmm2
movsd -0x78(%rbp), %xmm0
mulsd -0x78(%rbp), %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd -0x80(%rbp), %xmm0
movsd -0x80(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x10e0
movaps %xmm0, %xmm1
movsd 0x9700(%rip), %xmm0     # 0xe040
divsd %xmm1, %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x68(%rbp), %xmm0
mulsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x68(%rbp), %xmm0
mulsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x68(%rbp), %xmm0
mulsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0x78(%rbp), %xmm0
movsd -0x58(%rbp), %xmm2
movsd -0x80(%rbp), %xmm1
mulsd -0x50(%rbp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0x80(%rbp), %xmm0
movsd -0x48(%rbp), %xmm2
movsd -0x70(%rbp), %xmm1
mulsd -0x58(%rbp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x70(%rbp), %xmm0
movsd -0x50(%rbp), %xmm2
movsd -0x78(%rbp), %xmm1
mulsd -0x48(%rbp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x98(%rbp)
movsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x120(%rbp)
movsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x118(%rbp)
movsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x110(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x108(%rbp)
movsd -0x88(%rbp), %xmm0
movsd %xmm0, -0x100(%rbp)
movsd -0x90(%rbp), %xmm0
movsd %xmm0, -0xf8(%rbp)
movsd -0x98(%rbp), %xmm0
movsd %xmm0, -0xf0(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0xe8(%rbp)
movsd -0x48(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0xe0(%rbp)
movsd -0x50(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0xd8(%rbp)
movsd -0x58(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0xd0(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0xc8(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0xc0(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0xb8(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd 0x950c(%rip), %xmm0     # 0xe040
movsd %xmm0, -0xa8(%rbp)
leaq -0x120(%rbp), %rsi
leaq -0x1a0(%rbp), %rdx
leaq 0xf62f(%rip), %rdi      # 0x14180
callq 0x9c60
movl $0x0, -0x1a4(%rbp)
cmpl $0x4, -0x1a4(%rbp)
jge 0x4be5
movl $0x0, -0x1a8(%rbp)
cmpl $0x4, -0x1a8(%rbp)
jge 0x4bcf
movslq -0x1a4(%rbp), %rcx
leaq -0x1a0(%rbp), %rax
shlq $0x5, %rcx
addq %rcx, %rax
movslq -0x1a8(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movslq -0x1a4(%rbp), %rcx
leaq 0xf5d5(%rip), %rax      # 0x14180
shlq $0x5, %rcx
addq %rcx, %rax
movslq -0x1a8(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x1a8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1a8(%rbp)
jmp 0x4b73
jmp 0x4bd1
movl -0x1a4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1a4(%rbp)
jmp 0x4b60
movsd -0x8(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd -0x10(%rbp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
movsd -0x18(%rbp), %xmm2
movq %xmm2, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm2
callq 0x4c50
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
nopw (%rax,%rax)