#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ memset(float *, int /*<<< orphan*/, int);
int /*<<< orphan*/ vec3Cross(float *, float *, float *);
float vec3Dot(float *, float const *);
int /*<<< orphan*/ vec3Norm(float *, float *);
int /*<<< orphan*/ vec3Sub(float *, float const *, float const *);
void mtxLookAt(float *__restrict _result, const float *__restrict _eye,
               const float *__restrict _at) {
  float tmp[4];
  vec3Sub(tmp, _at, _eye);
  float view[4];
  vec3Norm(view, tmp);
  float up[3] = {0.0f, 1.0f, 0.0f};
  vec3Cross(tmp, up, view);
  float right[4];
  vec3Norm(right, tmp);
  vec3Cross(up, view, right);
  memset(_result, 0, sizeof(float) * 16);
  _result[0] = right[0];
  _result[1] = up[0];
  _result[2] = view[0];
  _result[4] = right[1];
  _result[5] = up[1];
  _result[6] = view[1];
  _result[8] = right[2];
  _result[9] = up[2];
  _result[10] = view[2];
  _result[12] = -vec3Dot(right, _eye);
  _result[13] = -vec3Dot(up, _eye);
  _result[14] = -vec3Dot(view, _eye);
  _result[15] = 1.0f;
}


x86 assembly (clang, -O0):
<mtxLookAt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1060 <vec3Sub@plt>
lea    -0x40(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1070 <vec3Norm@plt>
mov    0xe7b(%rip),%rax
mov    %rax,-0x4c(%rbp)
mov    0xe79(%rip),%eax
mov    %eax,-0x44(%rbp)
lea    -0x30(%rbp),%rdi
lea    -0x4c(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1030 <vec3Cross@plt>
lea    -0x60(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1070 <vec3Norm@plt>
lea    -0x4c(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   1030 <vec3Cross@plt>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1050 <memset@plt>
movss  -0x60(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x4c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x40(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
movss  -0x5c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x10(%rax)
movss  -0x48(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x14(%rax)
movss  -0x3c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x18(%rax)
movss  -0x58(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x20(%rax)
movss  -0x44(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x24(%rax)
movss  -0x38(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x28(%rax)
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <vec3Dot@plt>
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x30(%rax)
lea    -0x4c(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <vec3Dot@plt>
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x34(%rax)
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <vec3Dot@plt>
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x38(%rax)
mov    -0x8(%rbp),%rax
movss  0xd39(%rip),%xmm0
movss  %xmm0,0x3c(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mtxLookAt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
mov    %rdx,%rsi
mov    %r14,%rdx
call   1060 <vec3Sub@plt>
lea    0x20(%rsp),%r15
mov    %r15,%rdi
mov    %rbp,%rsi
call   1070 <vec3Norm@plt>
mov    0xe8b(%rip),%eax
mov    %eax,0x8(%rsp)
mov    0xe78(%rip),%rax
mov    %rax,(%rsp)
mov    %rsp,%r12
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1030 <vec3Cross@plt>
lea    0x10(%rsp),%r13
mov    %r13,%rdi
mov    %rbp,%rsi
call   1070 <vec3Norm@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
call   1030 <vec3Cross@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1050 <memset@plt>
movss  0x10(%rsp),%xmm0
movss  %xmm0,(%rbx)
movss  (%rsp),%xmm0
movss  %xmm0,0x4(%rbx)
movss  0x20(%rsp),%xmm0
movss  %xmm0,0x8(%rbx)
movss  0x14(%rsp),%xmm0
movss  %xmm0,0x10(%rbx)
movss  0x4(%rsp),%xmm0
movss  %xmm0,0x14(%rbx)
movss  0x24(%rsp),%xmm0
movss  %xmm0,0x18(%rbx)
movss  0x18(%rsp),%xmm0
movss  %xmm0,0x20(%rbx)
movss  0x8(%rsp),%xmm0
movss  %xmm0,0x24(%rbx)
movss  0x28(%rsp),%xmm0
movss  %xmm0,0x28(%rbx)
mov    %r13,%rdi
mov    %r14,%rsi
call   1040 <vec3Dot@plt>
xorps  0xdb3(%rip),%xmm0
movss  %xmm0,0x30(%rbx)
mov    %r12,%rdi
mov    %r14,%rsi
call   1040 <vec3Dot@plt>
xorps  0xd9c(%rip),%xmm0
movss  %xmm0,0x34(%rbx)
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <vec3Dot@plt>
xorps  0xd85(%rip),%xmm0
movss  %xmm0,0x38(%rbx)
movl   $0x3f800000,0x3c(%rbx)
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.mtxLookAt.up = [3 x float] [float 0.000000e+00, float 1.000000e+00, float 0.000000e+00]
define void @mtxLookAt(float* noalias %0, float* noalias %1, float* noalias %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca float*
%7 = alloca [4 x float]
%8 = alloca [4 x float]
%9 = alloca [3 x float]
%10 = alloca [4 x float]
store float* %0, float** %4
store float* %1, float** %5
store float* %2, float** %6
%11 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 0
%12 = load float*, float** %6
%13 = load float*, float** %5
%14 = call i32 @vec3Sub(float* %11, float* %12, float* %13)
%15 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 0
%16 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 0
%17 = call i32 @vec3Norm(float* %15, float* %16)
%18 = bitcast [3 x float]* %9 to i8*
%19 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 0
%20 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%21 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 0
%22 = call i32 @vec3Cross(float* %19, float* %20, float* %21)
%23 = getelementptr inbounds [4 x float], [4 x float]* %10, i64 0, i64 0
%24 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 0
%25 = call i32 @vec3Norm(float* %23, float* %24)
%26 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%27 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 0
%28 = getelementptr inbounds [4 x float], [4 x float]* %10, i64 0, i64 0
%29 = call i32 @vec3Cross(float* %26, float* %27, float* %28)
%30 = load float*, float** %4
%31 = call i32 @memset(float* %30, i32 0, i32 64)
%32 = getelementptr inbounds [4 x float], [4 x float]* %10, i64 0, i64 0
%33 = load float, float* %32
%34 = load float*, float** %4
%35 = getelementptr inbounds float, float* %34, i64 0
store float %33, float* %35
%36 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%37 = load float, float* %36
%38 = load float*, float** %4
%39 = getelementptr inbounds float, float* %38, i64 1
store float %37, float* %39
%40 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 0
%41 = load float, float* %40
%42 = load float*, float** %4
%43 = getelementptr inbounds float, float* %42, i64 2
store float %41, float* %43
%44 = getelementptr inbounds [4 x float], [4 x float]* %10, i64 0, i64 1
%45 = load float, float* %44
%46 = load float*, float** %4
%47 = getelementptr inbounds float, float* %46, i64 4
store float %45, float* %47
%48 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 1
%49 = load float, float* %48
%50 = load float*, float** %4
%51 = getelementptr inbounds float, float* %50, i64 5
store float %49, float* %51
%52 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 1
%53 = load float, float* %52
%54 = load float*, float** %4
%55 = getelementptr inbounds float, float* %54, i64 6
store float %53, float* %55
%56 = getelementptr inbounds [4 x float], [4 x float]* %10, i64 0, i64 2
%57 = load float, float* %56
%58 = load float*, float** %4
%59 = getelementptr inbounds float, float* %58, i64 8
store float %57, float* %59
%60 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 2
%61 = load float, float* %60
%62 = load float*, float** %4
%63 = getelementptr inbounds float, float* %62, i64 9
store float %61, float* %63
%64 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 2
%65 = load float, float* %64
%66 = load float*, float** %4
%67 = getelementptr inbounds float, float* %66, i64 10
store float %65, float* %67
%68 = getelementptr inbounds [4 x float], [4 x float]* %10, i64 0, i64 0
%69 = load float*, float** %5
%70 = call float @vec3Dot(float* %68, float* %69)
%71 = fneg float %70
%72 = load float*, float** %4
%73 = getelementptr inbounds float, float* %72, i64 12
store float %71, float* %73
%74 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%75 = load float*, float** %5
%76 = call float @vec3Dot(float* %74, float* %75)
%77 = fneg float %76
%78 = load float*, float** %4
%79 = getelementptr inbounds float, float* %78, i64 13
store float %77, float* %79
%80 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 0
%81 = load float*, float** %5
%82 = call float @vec3Dot(float* %80, float* %81)
%83 = fneg float %82
%84 = load float*, float** %4
%85 = getelementptr inbounds float, float* %84, i64 14
store float %83, float* %85
%86 = load float*, float** %4
%87 = getelementptr inbounds float, float* %86, i64 15
store float 1.000000e+00, float* %87
ret void
}

LLVM IR (-O2):
@__const.mtxLookAt.up = [3 x float] [float 0.000000e+00, float 1.000000e+00, float 0.000000e+00]
define void @mtxLookAt(float* noalias %0, float* noalias %1, float* noalias %2) {
%4 = alloca [4 x float]
%5 = alloca [4 x float]
%6 = alloca [3 x float]
%7 = alloca [4 x float]
%8 = bitcast [4 x float]* %4 to i8*
%9 = getelementptr inbounds [4 x float], [4 x float]* %4, i64 0, i64 0
%10 = call i32 @vec3Sub(float* %9, float* %2, float* %1)
%11 = bitcast [4 x float]* %5 to i8*
%12 = getelementptr inbounds [4 x float], [4 x float]* %5, i64 0, i64 0
%13 = call i32 @vec3Norm(float* %12, float* %9)
%14 = bitcast [3 x float]* %6 to i8*
%15 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 0
%16 = call i32 @vec3Cross(float* %9, float* %15, float* %12)
%17 = bitcast [4 x float]* %7 to i8*
%18 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 0
%19 = call i32 @vec3Norm(float* %18, float* %9)
%20 = call i32 @vec3Cross(float* %15, float* %12, float* %18)
%21 = call i32 @memset(float* %0, i32 0, i32 64)
%22 = load float, float* %18
store float %22, float* %0
%23 = load float, float* %15
%24 = getelementptr inbounds float, float* %0, i64 1
store float %23, float* %24
%25 = load float, float* %12
%26 = getelementptr inbounds float, float* %0, i64 2
store float %25, float* %26
%27 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 1
%28 = load float, float* %27
%29 = getelementptr inbounds float, float* %0, i64 4
store float %28, float* %29
%30 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 1
%31 = load float, float* %30
%32 = getelementptr inbounds float, float* %0, i64 5
store float %31, float* %32
%33 = getelementptr inbounds [4 x float], [4 x float]* %5, i64 0, i64 1
%34 = load float, float* %33
%35 = getelementptr inbounds float, float* %0, i64 6
store float %34, float* %35
%36 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 2
%37 = load float, float* %36
%38 = getelementptr inbounds float, float* %0, i64 8
store float %37, float* %38
%39 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 2
%40 = load float, float* %39
%41 = getelementptr inbounds float, float* %0, i64 9
store float %40, float* %41
%42 = getelementptr inbounds [4 x float], [4 x float]* %5, i64 0, i64 2
%43 = load float, float* %42
%44 = getelementptr inbounds float, float* %0, i64 10
store float %43, float* %44
%45 = call float @vec3Dot(float* %18, float* %1)
%46 = fneg float %45
%47 = getelementptr inbounds float, float* %0, i64 12
store float %46, float* %47
%48 = call float @vec3Dot(float* %15, float* %1)
%49 = fneg float %48
%50 = getelementptr inbounds float, float* %0, i64 13
store float %49, float* %50
%51 = call float @vec3Dot(float* %12, float* %1)
%52 = fneg float %51
%53 = getelementptr inbounds float, float* %0, i64 14
store float %52, float* %53
%54 = getelementptr inbounds float, float* %0, i64 15
store float 1.000000e+00, float* %54
ret void
}