#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*/ mat3f_from_mat4f(float *, float const *);
int /*<<< orphan*/ mat4f_from_mat3f(float *, float *);
int /*<<< orphan*/ mat4f_getColumn(float *, float *, int);
int /*<<< orphan*/ mat4f_getRow(float *, float const *, int);
int /*<<< orphan*/ mat4f_invert(float *);
int /*<<< orphan*/ mat4f_mult_mat4f_new(float *, float *, float const *);
int /*<<< orphan*/ vec3f_copy(float *, float *);
int /*<<< orphan*/ vec3f_scalarMult_new(float *, float *, int);
int /*<<< orphan*/ vec3f_sub_new(float *, float *, float *);
void mat4f_viewmat_to_lookatVec(const float viewmat[16], float eye[3],
                                float center[3], float up[3]) {
  float rotation3[9], rotation4[16];
  mat3f_from_mat4f(rotation3, viewmat);
  mat4f_from_mat3f(rotation4, rotation3);
  mat4f_invert(rotation4);
  float transOnly[16];
  mat4f_mult_mat4f_new(transOnly, rotation4, viewmat);
  float transVec[4];
  mat4f_getColumn(transVec, transOnly, 3);
  vec3f_scalarMult_new(eye, transVec, -1);
  float upVec[4];
  mat4f_getRow(upVec, viewmat, 1);
  vec3f_copy(up, upVec);
  float lookVec[4];
  mat4f_getRow(lookVec, viewmat, 2);
  vec3f_sub_new(center, eye, lookVec);
}


x86 assembly (clang, -O0):
<mat4f_viewmat_to_lookatVec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   10b0 <mat3f_from_mat4f@plt>
lea    -0x90(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1090 <mat4f_from_mat3f@plt>
lea    -0x90(%rbp),%rdi
call   1050 <mat4f_invert@plt>
lea    -0xd0(%rbp),%rdi
lea    -0x90(%rbp),%rsi
mov    -0x8(%rbp),%rdx
call   1080 <mat4f_mult_mat4f_new@plt>
lea    -0xe0(%rbp),%rdi
lea    -0xd0(%rbp),%rsi
mov    $0x3,%edx
call   10a0 <mat4f_getColumn@plt>
mov    -0x10(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
mov    $0xffffffff,%edx
call   1060 <vec3f_scalarMult_new@plt>
lea    -0xf0(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x1,%edx
call   1070 <mat4f_getRow@plt>
mov    -0x20(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
call   1030 <vec3f_copy@plt>
lea    -0x100(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x2,%edx
call   1070 <mat4f_getRow@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x100(%rbp),%rdx
call   1040 <vec3f_sub_new@plt>
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mat4f_viewmat_to_lookatVec>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0x30(%rsp),%r13
mov    %r13,%rdi
mov    %rbx,%rsi
call   10b0 <mat3f_from_mat4f@plt>
lea    0xa0(%rsp),%rbp
mov    %rbp,%rdi
mov    %r13,%rsi
call   1090 <mat4f_from_mat3f@plt>
mov    %rbp,%rdi
call   1050 <mat4f_invert@plt>
lea    0x60(%rsp),%r13
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1080 <mat4f_mult_mat4f_new@plt>
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    %r13,%rsi
mov    $0x3,%edx
call   10a0 <mat4f_getColumn@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    $0xffffffff,%edx
call   1060 <vec3f_scalarMult_new@plt>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1070 <mat4f_getRow@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
call   1030 <vec3f_copy@plt>
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1070 <mat4f_getRow@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1040 <vec3f_sub_new@plt>
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @mat4f_viewmat_to_lookatVec(float* %0, float* %1, float* %2, float* %3) {
%5 = alloca float*
%6 = alloca float*
%7 = alloca float*
%8 = alloca float*
%9 = alloca [9 x float]
%10 = alloca [16 x float]
%11 = alloca [16 x float]
%12 = alloca [4 x float]
%13 = alloca [4 x float]
%14 = alloca [4 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 [9 x float], [9 x float]* %9, i64 0, i64 0
%16 = load float*, float** %5
%17 = call i32 @mat3f_from_mat4f(float* %15, float* %16)
%18 = getelementptr inbounds [16 x float], [16 x float]* %10, i64 0, i64 0
%19 = getelementptr inbounds [9 x float], [9 x float]* %9, i64 0, i64 0
%20 = call i32 @mat4f_from_mat3f(float* %18, float* %19)
%21 = getelementptr inbounds [16 x float], [16 x float]* %10, i64 0, i64 0
%22 = call i32 @mat4f_invert(float* %21)
%23 = getelementptr inbounds [16 x float], [16 x float]* %11, i64 0, i64 0
%24 = getelementptr inbounds [16 x float], [16 x float]* %10, i64 0, i64 0
%25 = load float*, float** %5
%26 = call i32 @mat4f_mult_mat4f_new(float* %23, float* %24, float* %25)
%27 = getelementptr inbounds [4 x float], [4 x float]* %12, i64 0, i64 0
%28 = getelementptr inbounds [16 x float], [16 x float]* %11, i64 0, i64 0
%29 = call i32 @mat4f_getColumn(float* %27, float* %28, i32 3)
%30 = load float*, float** %6
%31 = getelementptr inbounds [4 x float], [4 x float]* %12, i64 0, i64 0
%32 = call i32 @vec3f_scalarMult_new(float* %30, float* %31, i32 -1)
%33 = getelementptr inbounds [4 x float], [4 x float]* %13, i64 0, i64 0
%34 = load float*, float** %5
%35 = call i32 @mat4f_getRow(float* %33, float* %34, i32 1)
%36 = load float*, float** %8
%37 = getelementptr inbounds [4 x float], [4 x float]* %13, i64 0, i64 0
%38 = call i32 @vec3f_copy(float* %36, float* %37)
%39 = getelementptr inbounds [4 x float], [4 x float]* %14, i64 0, i64 0
%40 = load float*, float** %5
%41 = call i32 @mat4f_getRow(float* %39, float* %40, i32 2)
%42 = load float*, float** %7
%43 = load float*, float** %6
%44 = getelementptr inbounds [4 x float], [4 x float]* %14, i64 0, i64 0
%45 = call i32 @vec3f_sub_new(float* %42, float* %43, float* %44)
ret void
}

LLVM IR (-O2):
define void @mat4f_viewmat_to_lookatVec(float* %0, float* %1, float* %2, float* %3) {
%5 = alloca [9 x float]
%6 = alloca [16 x float]
%7 = alloca [16 x float]
%8 = alloca [4 x float]
%9 = alloca [4 x float]
%10 = alloca [4 x float]
%11 = bitcast [9 x float]* %5 to i8*
%12 = bitcast [16 x float]* %6 to i8*
%13 = getelementptr inbounds [9 x float], [9 x float]* %5, i64 0, i64 0
%14 = call i32 @mat3f_from_mat4f(float* %13, float* %0)
%15 = getelementptr inbounds [16 x float], [16 x float]* %6, i64 0, i64 0
%16 = call i32 @mat4f_from_mat3f(float* %15, float* %13)
%17 = call i32 @mat4f_invert(float* %15)
%18 = bitcast [16 x float]* %7 to i8*
%19 = getelementptr inbounds [16 x float], [16 x float]* %7, i64 0, i64 0
%20 = call i32 @mat4f_mult_mat4f_new(float* %19, float* %15, float* %0)
%21 = bitcast [4 x float]* %8 to i8*
%22 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 0
%23 = call i32 @mat4f_getColumn(float* %22, float* %19, i32 3)
%24 = call i32 @vec3f_scalarMult_new(float* %1, float* %22, i32 -1)
%25 = bitcast [4 x float]* %9 to i8*
%26 = getelementptr inbounds [4 x float], [4 x float]* %9, i64 0, i64 0
%27 = call i32 @mat4f_getRow(float* %26, float* %0, i32 1)
%28 = call i32 @vec3f_copy(float* %3, float* %26)
%29 = bitcast [4 x float]* %10 to i8*
%30 = getelementptr inbounds [4 x float], [4 x float]* %10, i64 0, i64 0
%31 = call i32 @mat4f_getRow(float* %30, float* %0, i32 2)
%32 = call i32 @vec3f_sub_new(float* %2, float* %1, float* %30)
ret void
}