#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 */
scalar_t__ M_PI;
int /*<<< orphan*/ memset(float *, int /*<<< orphan*/, int);
float tanf(float);
void mtxProj(float *_result, float _fovy, float _aspect, float _near,
             float _far) {
  const float height = 1.0f / tanf(_fovy * ((float)M_PI / 180.0f) * 0.5f);
  const float width = height * 1.0f / _aspect;
  const float aa = _far / (_far - _near);
  const float bb = -_near * aa;
  memset(_result, 0, sizeof(float) * 16);
  _result[0] = width;
  _result[5] = height;
  _result[10] = aa;
  _result[11] = 1.0f;
  _result[14] = bb;
}


x86 assembly (clang, -O0):
<mtxProj>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  %xmm1,-0x10(%rbp)
movss  %xmm2,-0x14(%rbp)
movss  %xmm3,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
mov    0x2e9c(%rip),%rax
cvtsi2ssq (%rax),%xmm1
movss  0xeaf(%rip),%xmm2
divss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  0xe9b(%rip),%xmm1
mulss  %xmm1,%xmm0
call   1030 <tanf@plt>
movaps %xmm0,%xmm1
movss  0xe83(%rip),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  0xe72(%rip),%xmm0
mulss  -0x1c(%rbp),%xmm0
divss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x18(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
subss  -0x14(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x14(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
movss  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x1c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x14(%rax)
movss  -0x24(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x28(%rax)
mov    -0x8(%rbp),%rax
movss  0xdea(%rip),%xmm0
movss  %xmm0,0x2c(%rax)
movss  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x38(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mtxProj>:
push   %rbx
sub    $0x20,%rsp
mov    0x2ebc(%rip),%rax
cvtsi2ssq (%rax),%xmm4
divss  0xec7(%rip),%xmm4
movss  %xmm3,0x8(%rsp)
movaps %xmm2,0x10(%rsp)
movss  %xmm1,0x4(%rsp)
mov    %rdi,%rbx
mulss  %xmm4,%xmm0
mulss  0xeab(%rip),%xmm0
call   1030 <tanf@plt>
movss  0xea2(%rip),%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,0xc(%rsp)
divss  0x4(%rsp),%xmm1
movss  %xmm1,0x4(%rsp)
movss  0x8(%rsp),%xmm2
movaps %xmm2,%xmm0
movaps 0x10(%rsp),%xmm1
subss  %xmm1,%xmm0
divss  %xmm0,%xmm2
movss  %xmm2,0x8(%rsp)
xorps  0xe71(%rip),%xmm1
mulss  %xmm2,%xmm1
movaps %xmm1,0x10(%rsp)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
movss  0x4(%rsp),%xmm0
movss  %xmm0,(%rbx)
movss  0xc(%rsp),%xmm0
movss  %xmm0,0x14(%rbx)
movss  0x8(%rsp),%xmm0
movss  %xmm0,0x28(%rbx)
movl   $0x3f800000,0x2c(%rbx)
movaps 0x10(%rsp),%xmm0
movss  %xmm0,0x38(%rbx)
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@M_PI = global i64 0
define void @mtxProj(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
%13 = alloca float
%14 = 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
%15 = load float, float* %7
%16 = load i64, i64* @M_PI
%17 = sitofp i64 %16 to float
%18 = fdiv float %17, 1.800000e+02
%19 = fmul float %15, %18
%20 = fmul float %19, 5.000000e-01
%21 = call float @tanf(float %20)
%22 = fdiv float 1.000000e+00, %21
store float %22, float* %11
%23 = load float, float* %11
%24 = fmul float %23, 1.000000e+00
%25 = load float, float* %8
%26 = fdiv float %24, %25
store float %26, float* %12
%27 = load float, float* %10
%28 = load float, float* %10
%29 = load float, float* %9
%30 = fsub float %28, %29
%31 = fdiv float %27, %30
store float %31, float* %13
%32 = load float, float* %9
%33 = fneg float %32
%34 = load float, float* %13
%35 = fmul float %33, %34
store float %35, float* %14
%36 = load float*, float** %6
%37 = call i32 @memset(float* %36, i32 0, i32 64)
%38 = load float, float* %12
%39 = load float*, float** %6
%40 = getelementptr inbounds float, float* %39, i64 0
store float %38, float* %40
%41 = load float, float* %11
%42 = load float*, float** %6
%43 = getelementptr inbounds float, float* %42, i64 5
store float %41, float* %43
%44 = load float, float* %13
%45 = load float*, float** %6
%46 = getelementptr inbounds float, float* %45, i64 10
store float %44, float* %46
%47 = load float*, float** %6
%48 = getelementptr inbounds float, float* %47, i64 11
store float 1.000000e+00, float* %48
%49 = load float, float* %14
%50 = load float*, float** %6
%51 = getelementptr inbounds float, float* %50, i64 14
store float %49, float* %51
ret void
}

LLVM IR (-O2):
@M_PI = global i64 0
define void @mtxProj(float* %0, float %1, float %2, float %3, float %4) {
%6 = load i64, i64* @M_PI
%7 = sitofp i64 %6 to float
%8 = fdiv float %7, 1.800000e+02
%9 = fmul float %8, %1
%10 = fmul float %9, 5.000000e-01
%11 = tail call float @tanf(float %10)
%12 = fdiv float 1.000000e+00, %11
%13 = fdiv float %12, %2
%14 = fsub float %4, %3
%15 = fdiv float %4, %14
%16 = fneg float %3
%17 = fmul float %15, %16
%18 = tail call i32 @memset(float* %0, i32 0, i32 64)
store float %13, float* %0
%19 = getelementptr inbounds float, float* %0, i64 5
store float %12, float* %19
%20 = getelementptr inbounds float, float* %0, i64 10
store float %15, float* %20
%21 = getelementptr inbounds float, float* %0, i64 11
store float 1.000000e+00, float* %21
%22 = getelementptr inbounds float, float* %0, i64 14
store float %17, float* %22
ret void
}