#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*/ mat4d_identity(double *);
int /*<<< orphan*/ mat4d_mult_mat4d_new(double *, double *, double *);
int /*<<< orphan*/ mat4d_translateVec_new(double *, double *);
int /*<<< orphan*/ vec3d_cross_new(double *, double *, double const *);
int /*<<< orphan*/ vec3d_normalize(double *);
int /*<<< orphan*/ vec3d_scalarMult_new(double *, double const *, int);
int /*<<< orphan*/ vec3d_sub_new(double *, double const *, double const *);
void mat4d_lookatVec_new(double result[16], const double eye[3],
                         const double center[3], const double up[3]) {
  double look[3];
  vec3d_sub_new(look, center, eye);
  vec3d_normalize(look);
  double side[3];
  vec3d_cross_new(side, look, up);
  vec3d_normalize(side);
  double newUp[3];
  vec3d_cross_new(newUp, side, look);
  double rotationPart[16];
  mat4d_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];
  double negEye[3];
  vec3d_scalarMult_new(negEye, eye, -1);
  double translationPart[16];
  mat4d_translateVec_new(translationPart, negEye);
  mat4d_mult_mat4d_new(result, rotationPart, translationPart);
}


x86 assembly (clang, -O0):
<mat4d_lookatVec_new>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1090 <vec3d_sub_new@plt>
lea    -0x40(%rbp),%rdi
call   1050 <vec3d_normalize@plt>
lea    -0x60(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <vec3d_cross_new@plt>
lea    -0x60(%rbp),%rdi
call   1050 <vec3d_normalize@plt>
lea    -0x80(%rbp),%rdi
lea    -0x60(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1060 <vec3d_cross_new@plt>
lea    -0x100(%rbp),%rdi
call   1080 <mat4d_identity@plt>
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x100(%rbp)
ff
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0xe0(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0xf8(%rbp)
ff
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0xd8(%rbp)
ff
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0xf0(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0xffffffff,%edx
call   1070 <vec3d_scalarMult_new@plt>
lea    -0x1a0(%rbp),%rdi
lea    -0x120(%rbp),%rsi
call   1030 <mat4d_translateVec_new@plt>
mov    -0x8(%rbp),%rdi
lea    -0x100(%rbp),%rsi
lea    -0x1a0(%rbp),%rdx
call   1040 <mat4d_mult_mat4d_new@plt>
add    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mat4d_lookatVec_new>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x180,%rsp
mov    %rcx,%r15
mov    %rsi,%r12
mov    %rdi,%r14
lea    0x40(%rsp),%r13
mov    %r13,%rdi
mov    %rdx,%rsi
mov    %r12,%rdx
call   1090 <vec3d_sub_new@plt>
mov    %r13,%rdi
call   1050 <vec3d_normalize@plt>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1060 <vec3d_cross_new@plt>
mov    %rbx,%rdi
call   1050 <vec3d_normalize@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1060 <vec3d_cross_new@plt>
lea    0x60(%rsp),%r15
mov    %r15,%rdi
call   1080 <mat4d_identity@plt>
movsd  0x20(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
movsd  %xmm0,0x60(%rsp)
movsd  %xmm1,0x80(%rsp)
movsd  0x30(%rsp),%xmm0
movsd  %xmm0,0xa0(%rsp)
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  %xmm0,0x68(%rsp)
movsd  %xmm1,0x88(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0xa8(%rsp)
movaps 0xdcc(%rip),%xmm0
movsd  0x40(%rsp),%xmm1
movsd  0x48(%rsp),%xmm2
movsd  0x50(%rsp),%xmm3
xorps  %xmm0,%xmm1
movlps %xmm1,0x70(%rsp)
xorps  %xmm0,%xmm2
movlps %xmm2,0x90(%rsp)
xorps  %xmm0,%xmm3
movlps %xmm3,0xb0(%rsp)
lea    0xe0(%rsp),%r13
mov    %r13,%rdi
mov    %r12,%rsi
mov    $0xffffffff,%edx
call   1070 <vec3d_scalarMult_new@plt>
lea    0x100(%rsp),%rbx
mov    %rbx,%rdi
mov    %r13,%rsi
call   1030 <mat4d_translateVec_new@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <mat4d_mult_mat4d_new@plt>
add    $0x180,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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