#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*/ CrossProd3fv(float *, float const *, float *);
int /*<<< orphan*/ Normalize3fv(float *);
int /*<<< orphan*/ Subtract3fv(float *, float const *, float const *);
float *invLookAt(float *M, const float Eye[3], const float LookAtPt[3],
                 const float ViewUp[3]) {
  float X[3], Y[3], Z[3];
  Subtract3fv(Z, Eye, LookAtPt);
  Normalize3fv(Z);
  CrossProd3fv(X, ViewUp, Z);
  Normalize3fv(X);
  CrossProd3fv(Y, Z, X);
  Normalize3fv(Y);
  M[0] = X[0];
  M[4] = Y[0];
  M[8] = Z[0];
  M[12] = Eye[0];
  M[1] = X[1];
  M[5] = Y[1];
  M[9] = Z[1];
  M[13] = Eye[1];
  M[2] = X[2];
  M[6] = Y[2];
  M[10] = Z[2];
  M[14] = Eye[2];
  M[3] = 0;
  M[7] = 0;
  M[11] = 0;
  M[15] = 1;
  return (M);
}


x86 assembly (clang, -O0):
<invLookAt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x44(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <Subtract3fv@plt>
lea    -0x44(%rbp),%rdi
call   1050 <Normalize3fv@plt>
lea    -0x2c(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x44(%rbp),%rdx
call   1040 <CrossProd3fv@plt>
lea    -0x2c(%rbp),%rdi
call   1050 <Normalize3fv@plt>
lea    -0x38(%rbp),%rdi
lea    -0x44(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
call   1040 <CrossProd3fv@plt>
lea    -0x38(%rbp),%rdi
call   1050 <Normalize3fv@plt>
movss  -0x2c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x38(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x10(%rax)
movss  -0x44(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x20(%rax)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x30(%rax)
movss  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x34(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x14(%rax)
movss  -0x40(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x24(%rax)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x34(%rax)
movss  -0x24(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
movss  -0x30(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x18(%rax)
movss  -0x3c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x28(%rax)
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x38(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x1c(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x2c(%rax)
mov    -0x8(%rbp),%rax
movss  0xd88(%rip),%xmm0
movss  %xmm0,0x3c(%rax)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<invLookAt>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30,%rsp
mov    %rcx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xc(%rsp),%r12
mov    %r12,%rdi
call   1030 <Subtract3fv@plt>
mov    %r12,%rdi
call   1050 <Normalize3fv@plt>
lea    0x24(%rsp),%r13
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1040 <CrossProd3fv@plt>
mov    %r13,%rdi
call   1050 <Normalize3fv@plt>
lea    0x18(%rsp),%r15
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1040 <CrossProd3fv@plt>
mov    %r15,%rdi
call   1050 <Normalize3fv@plt>
movss  0x24(%rsp),%xmm0
movss  %xmm0,(%rbx)
movss  0x18(%rsp),%xmm0
movss  %xmm0,0x10(%rbx)
movss  0xc(%rsp),%xmm0
movss  %xmm0,0x20(%rbx)
movss  (%r14),%xmm0
movss  %xmm0,0x30(%rbx)
movss  0x28(%rsp),%xmm0
movss  %xmm0,0x4(%rbx)
movss  0x1c(%rsp),%xmm0
movss  %xmm0,0x14(%rbx)
movss  0x10(%rsp),%xmm0
movss  %xmm0,0x24(%rbx)
movss  0x4(%r14),%xmm0
movss  %xmm0,0x34(%rbx)
movss  0x2c(%rsp),%xmm0
movss  %xmm0,0x8(%rbx)
movss  0x20(%rsp),%xmm0
movss  %xmm0,0x18(%rbx)
movss  0x14(%rsp),%xmm0
movss  %xmm0,0x28(%rbx)
movss  0x8(%r14),%xmm0
movss  %xmm0,0x38(%rbx)
movl   $0x0,0xc(%rbx)
movl   $0x0,0x1c(%rbx)
movl   $0x0,0x2c(%rbx)
movl   $0x3f800000,0x3c(%rbx)
mov    %rbx,%rax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define float* @invLookAt(float* returned writeonly %0, float* %1, float* %2, float* %3) {
%5 = alloca [3 x float]
%6 = alloca [3 x float]
%7 = alloca [3 x float]
%8 = bitcast [3 x float]* %5 to i8*
%9 = bitcast [3 x float]* %6 to i8*
%10 = bitcast [3 x float]* %7 to i8*
%11 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%12 = call i32 @Subtract3fv(float* %11, float* %1, float* %2)
%13 = call i32 @Normalize3fv(float* %11)
%14 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 0
%15 = call i32 @CrossProd3fv(float* %14, float* %3, float* %11)
%16 = call i32 @Normalize3fv(float* %14)
%17 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 0
%18 = call i32 @CrossProd3fv(float* %17, float* %11, float* %14)
%19 = call i32 @Normalize3fv(float* %17)
%20 = load float, float* %14
store float %20, float* %0
%21 = load float, float* %17
%22 = getelementptr inbounds float, float* %0, i64 4
store float %21, float* %22
%23 = load float, float* %11
%24 = getelementptr inbounds float, float* %0, i64 8
store float %23, float* %24
%25 = load float, float* %1
%26 = getelementptr inbounds float, float* %0, i64 12
store float %25, float* %26
%27 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 1
%28 = load float, float* %27
%29 = getelementptr inbounds float, float* %0, i64 1
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 [3 x float], [3 x float]* %7, i64 0, i64 1
%34 = load float, float* %33
%35 = getelementptr inbounds float, float* %0, i64 9
store float %34, float* %35
%36 = getelementptr inbounds float, float* %1, i64 1
%37 = load float, float* %36
%38 = getelementptr inbounds float, float* %0, i64 13
store float %37, float* %38
%39 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 2
%40 = load float, float* %39
%41 = getelementptr inbounds float, float* %0, i64 2
store float %40, float* %41
%42 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 2
%43 = load float, float* %42
%44 = getelementptr inbounds float, float* %0, i64 6
store float %43, float* %44
%45 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 2
%46 = load float, float* %45
%47 = getelementptr inbounds float, float* %0, i64 10
store float %46, float* %47
%48 = getelementptr inbounds float, float* %1, i64 2
%49 = load float, float* %48
%50 = getelementptr inbounds float, float* %0, i64 14
store float %49, float* %50
%51 = getelementptr inbounds float, float* %0, i64 3
store float 0.000000e+00, float* %51
%52 = getelementptr inbounds float, float* %0, i64 7
store float 0.000000e+00, float* %52
%53 = getelementptr inbounds float, float* %0, i64 11
store float 0.000000e+00, float* %53
%54 = getelementptr inbounds float, float* %0, i64 15
store float 1.000000e+00, float* %54
ret float* %0
}