#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);
double tan(float);
void t_matrix_fov_projection(float res[], float fov, float aspect, float near,
                             float far) {
  float depth = near - far;
  float invDepth = 1 / depth;
  memset(res, 0, sizeof *res * 16);
  res[5] = 1.0 / tan(0.5f * fov);
  res[0] = res[5] / aspect;
  res[10] = (far + near) * invDepth;
  res[11] = -1.0;
  res[14] = (2.0 * far * near) * invDepth;
}


x86 assembly (clang, -O0):
<t_matrix_fov_projection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  %xmm1,-0x10(%rbp)
movss  %xmm2,-0x14(%rbp)
movss  %xmm3,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
subss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  0xec1(%rip),%xmm0
divss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1030 <memset@plt>
movss  0xe9b(%rip),%xmm0
mulss  -0xc(%rbp),%xmm0
call   1040 <tan@plt>
movaps %xmm0,%xmm1
movsd  0xe7a(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x14(%rax)
mov    -0x8(%rbp),%rax
movss  0x14(%rax),%xmm0
divss  -0x10(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x18(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
mulss  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x28(%rax)
mov    -0x8(%rbp),%rax
movss  0xe37(%rip),%xmm0
movss  %xmm0,0x2c(%rax)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe11(%rip),%xmm0
mulsd  %xmm1,%xmm0
movss  -0x14(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
movss  -0x20(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x38(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<t_matrix_fov_projection>:
push   %rbx
sub    $0x20,%rsp
movss  %xmm3,0x18(%rsp)
movss  %xmm2,0x10(%rsp)
movss  %xmm1,0x1c(%rsp)
movss  %xmm0,0xc(%rsp)
mov    %rdi,%rbx
movaps %xmm2,%xmm0
subss  %xmm3,%xmm0
movss  0xeb1(%rip),%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,0x14(%rsp)
xor    %esi,%esi
mov    $0x40,%edx
call   1030 <memset@plt>
movss  0xc(%rsp),%xmm0
mulss  0xe91(%rip),%xmm0
call   1040 <tan@plt>
movsd  0xe88(%rip),%xmm1
divsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,0x14(%rbx)
divss  0x1c(%rsp),%xmm0
movss  %xmm0,(%rbx)
movss  0x10(%rsp),%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
movss  0x18(%rsp),%xmm1
addss  %xmm1,%xmm2
movss  0x14(%rsp),%xmm3
mulss  %xmm3,%xmm2
movss  %xmm2,0x28(%rbx)
movl   $0xbf800000,0x2c(%rbx)
cvtss2sd %xmm1,%xmm1
addsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm3,%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x38(%rbx)
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @t_matrix_fov_projection(float* %0, float %1, float %2, float %3, float %4) {
%6 = alloca float*
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
store float* %0, float** %6
store float %1, float* %7
store float %2, float* %8
store float %3, float* %9
store float %4, float* %10
%13 = load float, float* %9
%14 = load float, float* %10
%15 = fsub float %13, %14
store float %15, float* %11
%16 = load float, float* %11
%17 = fdiv float 1.000000e+00, %16
store float %17, float* %12
%18 = load float*, float** %6
%19 = call i32 @memset(float* %18, i32 0, i32 64)
%20 = load float, float* %7
%21 = fmul float 5.000000e-01, %20
%22 = call double @tan(float %21)
%23 = fdiv double 1.000000e+00, %22
%24 = fptrunc double %23 to float
%25 = load float*, float** %6
%26 = getelementptr inbounds float, float* %25, i64 5
store float %24, float* %26
%27 = load float*, float** %6
%28 = getelementptr inbounds float, float* %27, i64 5
%29 = load float, float* %28
%30 = load float, float* %8
%31 = fdiv float %29, %30
%32 = load float*, float** %6
%33 = getelementptr inbounds float, float* %32, i64 0
store float %31, float* %33
%34 = load float, float* %10
%35 = load float, float* %9
%36 = fadd float %34, %35
%37 = load float, float* %12
%38 = fmul float %36, %37
%39 = load float*, float** %6
%40 = getelementptr inbounds float, float* %39, i64 10
store float %38, float* %40
%41 = load float*, float** %6
%42 = getelementptr inbounds float, float* %41, i64 11
store float -1.000000e+00, float* %42
%43 = load float, float* %10
%44 = fpext float %43 to double
%45 = fmul double 2.000000e+00, %44
%46 = load float, float* %9
%47 = fpext float %46 to double
%48 = fmul double %45, %47
%49 = load float, float* %12
%50 = fpext float %49 to double
%51 = fmul double %48, %50
%52 = fptrunc double %51 to float
%53 = load float*, float** %6
%54 = getelementptr inbounds float, float* %53, i64 14
store float %52, float* %54
ret void
}

LLVM IR (-O2):
define void @t_matrix_fov_projection(float* %0, float %1, float %2, float %3, float %4) {
%6 = fsub float %3, %4
%7 = fdiv float 1.000000e+00, %6
%8 = tail call i32 @memset(float* %0, i32 0, i32 64)
%9 = fmul float %1, 5.000000e-01
%10 = tail call double @tan(float %9)
%11 = fdiv double 1.000000e+00, %10
%12 = fptrunc double %11 to float
%13 = getelementptr inbounds float, float* %0, i64 5
store float %12, float* %13
%14 = fdiv float %12, %2
store float %14, float* %0
%15 = fadd float %3, %4
%16 = fmul float %15, %7
%17 = getelementptr inbounds float, float* %0, i64 10
store float %16, float* %17
%18 = getelementptr inbounds float, float* %0, i64 11
store float -1.000000e+00, float* %18
%19 = fpext float %4 to double
%20 = fmul double %19, 2.000000e+00
%21 = fpext float %3 to double
%22 = fmul double %20, %21
%23 = fpext float %7 to double
%24 = fmul double %22, %23
%25 = fptrunc double %24 to float
%26 = getelementptr inbounds float, float* %0, i64 14
store float %25, float* %26
ret void
}