#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*/ mat4f_identity(float *);
int /*<<< orphan*/ mat4f_mult_mat4f_new(float *, float *, float *);
int /*<<< orphan*/ mat4f_translateVec_new(float *, float *);
int /*<<< orphan*/ vec3f_cross_new(float *, float *, float const *);
int /*<<< orphan*/ vec3f_normalize(float *);
int /*<<< orphan*/ vec3f_scalarMult_new(float *, float const *, int);
int /*<<< orphan*/ vec3f_sub_new(float *, float const *, float const *);
void mat4f_lookatVec_new(float result[16], const float eye[3],
                         const float center[3], const float up[3]) {
  float look[3];
  vec3f_sub_new(look, center, eye);
  vec3f_normalize(look);
  float side[3];
  vec3f_cross_new(side, look, up);
  vec3f_normalize(side);
  float newUp[3];
  vec3f_cross_new(newUp, side, look);
  float rotationPart[16];
  mat4f_identity(rotationPart);
  rotationPart[0] = side[0];
  rotationPart[4] = side[1];
  rotationPart[8] = side[2];
  rotationPart[1] = newUp[0];
  rotationPart[5] = newUp[1];
  rotationPart[9] = newUp[2];
  rotationPart[2] = -look[0];
  rotationPart[6] = -look[1];
  rotationPart[10] = -look[2];
  float negEye[3];
  vec3f_scalarMult_new(negEye, eye, -1);
  float translationPart[16];
  mat4f_translateVec_new(translationPart, negEye);
  mat4f_mult_mat4f_new(result, rotationPart, translationPart);
}


x86 assembly (clang, -O0):
<mat4f_lookatVec_new>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x2c(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1040 <vec3f_sub_new@plt>
lea    -0x2c(%rbp),%rdi
call   1090 <vec3f_normalize@plt>
lea    -0x38(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1070 <vec3f_cross_new@plt>
lea    -0x38(%rbp),%rdi
call   1090 <vec3f_normalize@plt>
lea    -0x44(%rbp),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
call   1070 <vec3f_cross_new@plt>
lea    -0x90(%rbp),%rdi
call   1030 <mat4f_identity@plt>
movss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x90(%rbp)
ff
movss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x80(%rbp)
movss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x70(%rbp)
movss  -0x44(%rbp),%xmm0
movss  %xmm0,-0x8c(%rbp)
ff
movss  -0x40(%rbp),%xmm0
movss  %xmm0,-0x7c(%rbp)
movss  -0x3c(%rbp),%xmm0
movss  %xmm0,-0x6c(%rbp)
movss  -0x2c(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x88(%rbp)
ff
movss  -0x28(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x78(%rbp)
movss  -0x24(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x68(%rbp)
lea    -0x9c(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0xffffffff,%edx
call   1060 <vec3f_scalarMult_new@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x9c(%rbp),%rsi
call   1050 <mat4f_translateVec_new@plt>
mov    -0x8(%rbp),%rdi
lea    -0x90(%rbp),%rsi
lea    -0xe0(%rbp),%rdx
call   1080 <mat4f_mult_mat4f_new@plt>
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mat4f_lookatVec_new>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc0,%rsp
mov    %rcx,%r15
mov    %rsi,%r12
mov    %rdi,%r14
lea    0x24(%rsp),%r13
mov    %r13,%rdi
mov    %rdx,%rsi
mov    %r12,%rdx
call   1040 <vec3f_sub_new@plt>
mov    %r13,%rdi
call   1090 <vec3f_normalize@plt>
lea    0x18(%rsp),%rbx
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1070 <vec3f_cross_new@plt>
mov    %rbx,%rdi
call   1090 <vec3f_normalize@plt>
lea    0xc(%rsp),%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1070 <vec3f_cross_new@plt>
lea    0x30(%rsp),%r15
mov    %r15,%rdi
call   1030 <mat4f_identity@plt>
movss  0x18(%rsp),%xmm0
movss  0x1c(%rsp),%xmm1
movss  %xmm0,0x30(%rsp)
movss  %xmm1,0x40(%rsp)
movss  0x20(%rsp),%xmm0
movss  %xmm0,0x50(%rsp)
movss  0xc(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
movss  %xmm0,0x34(%rsp)
movss  %xmm1,0x44(%rsp)
movss  0x14(%rsp),%xmm0
movss  %xmm0,0x54(%rsp)
movaps 0xdd5(%rip),%xmm0
movss  0x24(%rsp),%xmm1
movss  0x28(%rsp),%xmm2
movss  0x2c(%rsp),%xmm3
xorps  %xmm0,%xmm1
movss  %xmm1,0x38(%rsp)
xorps  %xmm0,%xmm2
movss  %xmm2,0x48(%rsp)
xorps  %xmm0,%xmm3
movss  %xmm3,0x58(%rsp)
lea    0x74(%rsp),%r13
mov    %r13,%rdi
mov    %r12,%rsi
mov    $0xffffffff,%edx
call   1060 <vec3f_scalarMult_new@plt>
lea    0x80(%rsp),%rbx
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <mat4f_translateVec_new@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1080 <mat4f_mult_mat4f_new@plt>
add    $0xc0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @mat4f_lookatVec_new(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]
%12 = alloca [16 x float]
%13 = alloca [3 x float]
%14 = alloca [16 x float]
store float* %0, float** %5
store float* %1, float** %6
store float* %2, float** %7
store float* %3, float** %8
%15 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%16 = load float*, float** %7
%17 = load float*, float** %6
%18 = call i32 @vec3f_sub_new(float* %15, float* %16, float* %17)
%19 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%20 = call i32 @vec3f_normalize(float* %19)
%21 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 0
%22 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%23 = load float*, float** %8
%24 = call i32 @vec3f_cross_new(float* %21, float* %22, float* %23)
%25 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 0
%26 = call i32 @vec3f_normalize(float* %25)
%27 = getelementptr inbounds [3 x float], [3 x float]* %11, i64 0, i64 0
%28 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 0
%29 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%30 = call i32 @vec3f_cross_new(float* %27, float* %28, float* %29)
%31 = getelementptr inbounds [16 x float], [16 x float]* %12, i64 0, i64 0
%32 = call i32 @mat4f_identity(float* %31)
%33 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 0
%34 = load float, float* %33
%35 = getelementptr inbounds [16 x float], [16 x float]* %12, i64 0, i64 0
store float %34, float* %35
%36 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 1
%37 = load float, float* %36
%38 = getelementptr inbounds [16 x float], [16 x float]* %12, i64 0, i64 4
store float %37, float* %38
%39 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 2
%40 = load float, float* %39
%41 = getelementptr inbounds [16 x float], [16 x float]* %12, i64 0, i64 8
store float %40, float* %41
%42 = getelementptr inbounds [3 x float], [3 x float]* %11, i64 0, i64 0
%43 = load float, float* %42
%44 = getelementptr inbounds [16 x float], [16 x float]* %12, i64 0, i64 1
store float %43, float* %44
%45 = getelementptr inbounds [3 x float], [3 x float]* %11, i64 0, i64 1
%46 = load float, float* %45
%47 = getelementptr inbounds [16 x float], [16 x float]* %12, i64 0, i64 5
store float %46, float* %47
%48 = getelementptr inbounds [3 x float], [3 x float]* %11, i64 0, i64 2
%49 = load float, float* %48
%50 = getelementptr inbounds [16 x float], [16 x float]* %12, i64 0, i64 9
store float %49, float* %50
%51 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%52 = load float, float* %51
%53 = fneg float %52
%54 = getelementptr inbounds [16 x float], [16 x float]* %12, i64 0, i64 2
store float %53, float* %54
%55 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 1
%56 = load float, float* %55
%57 = fneg float %56
%58 = getelementptr inbounds [16 x float], [16 x float]* %12, i64 0, i64 6
store float %57, float* %58
%59 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 2
%60 = load float, float* %59
%61 = fneg float %60
%62 = getelementptr inbounds [16 x float], [16 x float]* %12, i64 0, i64 10
store float %61, float* %62
%63 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 0
%64 = load float*, float** %6
%65 = call i32 @vec3f_scalarMult_new(float* %63, float* %64, i32 -1)
%66 = getelementptr inbounds [16 x float], [16 x float]* %14, i64 0, i64 0
%67 = getelementptr inbounds [3 x float], [3 x float]* %13, i64 0, i64 0
%68 = call i32 @mat4f_translateVec_new(float* %66, float* %67)
%69 = load float*, float** %5
%70 = getelementptr inbounds [16 x float], [16 x float]* %12, i64 0, i64 0
%71 = getelementptr inbounds [16 x float], [16 x float]* %14, i64 0, i64 0
%72 = call i32 @mat4f_mult_mat4f_new(float* %69, float* %70, float* %71)
ret void
}

LLVM IR (-O2):
define void @mat4f_lookatVec_new(float* %0, float* %1, float* %2, float* %3) {
%5 = alloca [3 x float]
%6 = alloca [3 x float]
%7 = alloca [3 x float]
%8 = alloca [16 x float]
%9 = alloca [3 x float]
%10 = alloca [16 x float]
%11 = bitcast [3 x float]* %5 to i8*
%12 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 0
%13 = call i32 @vec3f_sub_new(float* %12, float* %2, float* %1)
%14 = call i32 @vec3f_normalize(float* %12)
%15 = bitcast [3 x float]* %6 to i8*
%16 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 0
%17 = call i32 @vec3f_cross_new(float* %16, float* %12, float* %3)
%18 = call i32 @vec3f_normalize(float* %16)
%19 = bitcast [3 x float]* %7 to i8*
%20 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%21 = call i32 @vec3f_cross_new(float* %20, float* %16, float* %12)
%22 = bitcast [16 x float]* %8 to i8*
%23 = getelementptr inbounds [16 x float], [16 x float]* %8, i64 0, i64 0
%24 = call i32 @mat4f_identity(float* %23)
%25 = load float, float* %16
store float %25, float* %23
%26 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 1
%27 = load float, float* %26
%28 = getelementptr inbounds [16 x float], [16 x float]* %8, i64 0, i64 4
store float %27, float* %28
%29 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 2
%30 = load float, float* %29
%31 = getelementptr inbounds [16 x float], [16 x float]* %8, i64 0, i64 8
store float %30, float* %31
%32 = load float, float* %20
%33 = getelementptr inbounds [16 x float], [16 x float]* %8, i64 0, i64 1
store float %32, float* %33
%34 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 1
%35 = load float, float* %34
%36 = getelementptr inbounds [16 x float], [16 x float]* %8, i64 0, i64 5
store float %35, float* %36
%37 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 2
%38 = load float, float* %37
%39 = getelementptr inbounds [16 x float], [16 x float]* %8, i64 0, i64 9
store float %38, float* %39
%40 = load float, float* %12
%41 = fneg float %40
%42 = getelementptr inbounds [16 x float], [16 x float]* %8, i64 0, i64 2
store float %41, float* %42
%43 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 1
%44 = load float, float* %43
%45 = fneg float %44
%46 = getelementptr inbounds [16 x float], [16 x float]* %8, i64 0, i64 6
store float %45, float* %46
%47 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 2
%48 = load float, float* %47
%49 = fneg float %48
%50 = getelementptr inbounds [16 x float], [16 x float]* %8, i64 0, i64 10
store float %49, float* %50
%51 = bitcast [3 x float]* %9 to i8*
%52 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%53 = call i32 @vec3f_scalarMult_new(float* %52, float* %1, i32 -1)
%54 = bitcast [16 x float]* %10 to i8*
%55 = getelementptr inbounds [16 x float], [16 x float]* %10, i64 0, i64 0
%56 = call i32 @mat4f_translateVec_new(float* %55, float* %52)
%57 = call i32 @mat4f_mult_mat4f_new(float* %0, float* %23, float* %55)
ret void
}