#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 M_PI;
float tanf(float);
void mtxLoadPerspective(float *mtx, float fov, float aspect, float nearZ,
                        float farZ) {
  float f = 1.0f / tanf((fov * (M_PI / 180)) / 2.0f);
  mtx[0] = f / aspect;
  mtx[1] = 0.0f;
  mtx[2] = 0.0f;
  mtx[3] = 0.0f;
  mtx[4] = 0.0f;
  mtx[5] = f;
  mtx[6] = 0.0f;
  mtx[7] = 0.0f;
  mtx[8] = 0.0f;
  mtx[9] = 0.0f;
  mtx[10] = (farZ + nearZ) / (nearZ - farZ);
  mtx[11] = -1.0f;
  mtx[12] = 0.0f;
  mtx[13] = 0.0f;
  mtx[14] = 2 * farZ * nearZ / (nearZ - farZ);
  mtx[15] = 0.0f;
}


x86 assembly (clang, -O0):
<mtxLoadPerspective>:
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  -0xc(%rbp),%xmm0
mov    0x2eac(%rip),%rax
mov    (%rax),%eax
mov    $0xb4,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
movss  0xeaa(%rip),%xmm1
divss  %xmm1,%xmm0
call   1030 <tanf@plt>
movaps %xmm0,%xmm1
movss  0xe9e(%rip),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
divss  -0x10(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x10(%rax)
movss  -0x1c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x14(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x18(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x1c(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x20(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x24(%rax)
movss  -0x18(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
subss  -0x18(%rbp),%xmm1
divss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x28(%rax)
mov    -0x8(%rbp),%rax
movss  0xde4(%rip),%xmm0
movss  %xmm0,0x2c(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x30(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x34(%rax)
movss  0xdbb(%rip),%xmm0
mulss  -0x18(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
subss  -0x18(%rbp),%xmm1
divss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x38(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x3c(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mtxLoadPerspective>:
push   %rbx
sub    $0x10,%rsp
mov    0x2ecc(%rip),%rax
movslq (%rax),%rax
imul   $0xffffffffb60b60b7,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
sar    $0x7,%ecx
add    %eax,%ecx
cvtsi2ss %ecx,%xmm4
movss  %xmm3,0xc(%rsp)
movss  %xmm2,0x8(%rsp)
movss  %xmm1,0x4(%rsp)
mov    %rdi,%rbx
mulss  %xmm4,%xmm0
mulss  0xea5(%rip),%xmm0
call   1030 <tanf@plt>
movss  0xe9c(%rip),%xmm1
divss  %xmm0,%xmm1
movaps %xmm1,%xmm0
divss  0x4(%rsp),%xmm0
movss  %xmm0,(%rbx)
xorps  %xmm0,%xmm0
movups %xmm0,0x4(%rbx)
movss  %xmm1,0x14(%rbx)
movss  0x8(%rsp),%xmm4
movaps %xmm4,%xmm1
movss  0xc(%rsp),%xmm3
addss  %xmm3,%xmm1
movaps %xmm4,%xmm2
subss  %xmm3,%xmm2
divss  %xmm2,%xmm1
movups %xmm0,0x18(%rbx)
movss  %xmm1,0x28(%rbx)
mov    $0xbf800000,%eax
mov    %rax,0x2c(%rbx)
movl   $0x0,0x34(%rbx)
addss  %xmm3,%xmm3
mulss  %xmm4,%xmm3
divss  %xmm2,%xmm3
movss  %xmm3,0x38(%rbx)
movl   $0x0,0x3c(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@M_PI = global i32 0
define void @mtxLoadPerspective(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
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
%12 = load float, float* %7
%13 = load i32, i32* @M_PI
%14 = sdiv i32 %13, 180
%15 = sitofp i32 %14 to float
%16 = fmul float %12, %15
%17 = fdiv float %16, 2.000000e+00
%18 = call float @tanf(float %17)
%19 = fdiv float 1.000000e+00, %18
store float %19, float* %11
%20 = load float, float* %11
%21 = load float, float* %8
%22 = fdiv float %20, %21
%23 = load float*, float** %6
%24 = getelementptr inbounds float, float* %23, i64 0
store float %22, float* %24
%25 = load float*, float** %6
%26 = getelementptr inbounds float, float* %25, i64 1
store float 0.000000e+00, float* %26
%27 = load float*, float** %6
%28 = getelementptr inbounds float, float* %27, i64 2
store float 0.000000e+00, float* %28
%29 = load float*, float** %6
%30 = getelementptr inbounds float, float* %29, i64 3
store float 0.000000e+00, float* %30
%31 = load float*, float** %6
%32 = getelementptr inbounds float, float* %31, i64 4
store float 0.000000e+00, float* %32
%33 = load float, float* %11
%34 = load float*, float** %6
%35 = getelementptr inbounds float, float* %34, i64 5
store float %33, float* %35
%36 = load float*, float** %6
%37 = getelementptr inbounds float, float* %36, i64 6
store float 0.000000e+00, float* %37
%38 = load float*, float** %6
%39 = getelementptr inbounds float, float* %38, i64 7
store float 0.000000e+00, float* %39
%40 = load float*, float** %6
%41 = getelementptr inbounds float, float* %40, i64 8
store float 0.000000e+00, float* %41
%42 = load float*, float** %6
%43 = getelementptr inbounds float, float* %42, i64 9
store float 0.000000e+00, float* %43
%44 = load float, float* %10
%45 = load float, float* %9
%46 = fadd float %44, %45
%47 = load float, float* %9
%48 = load float, float* %10
%49 = fsub float %47, %48
%50 = fdiv float %46, %49
%51 = load float*, float** %6
%52 = getelementptr inbounds float, float* %51, i64 10
store float %50, float* %52
%53 = load float*, float** %6
%54 = getelementptr inbounds float, float* %53, i64 11
store float -1.000000e+00, float* %54
%55 = load float*, float** %6
%56 = getelementptr inbounds float, float* %55, i64 12
store float 0.000000e+00, float* %56
%57 = load float*, float** %6
%58 = getelementptr inbounds float, float* %57, i64 13
store float 0.000000e+00, float* %58
%59 = load float, float* %10
%60 = fmul float 2.000000e+00, %59
%61 = load float, float* %9
%62 = fmul float %60, %61
%63 = load float, float* %9
%64 = load float, float* %10
%65 = fsub float %63, %64
%66 = fdiv float %62, %65
%67 = load float*, float** %6
%68 = getelementptr inbounds float, float* %67, i64 14
store float %66, float* %68
%69 = load float*, float** %6
%70 = getelementptr inbounds float, float* %69, i64 15
store float 0.000000e+00, float* %70
ret void
}

LLVM IR (-O2):
@M_PI = global i32 0
define void @mtxLoadPerspective(float* nocapture writeonly %0, float %1, float %2, float %3, float %4) {
%6 = load i32, i32* @M_PI
%7 = sdiv i32 %6, 180
%8 = sitofp i32 %7 to float
%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
store float %13, float* %0
%14 = getelementptr inbounds float, float* %0, i64 1
%15 = getelementptr inbounds float, float* %0, i64 5
%16 = bitcast float* %14 to i8*
store float %12, float* %15
%17 = getelementptr inbounds float, float* %0, i64 6
%18 = fadd float %3, %4
%19 = fsub float %3, %4
%20 = fdiv float %18, %19
%21 = getelementptr inbounds float, float* %0, i64 10
%22 = bitcast float* %17 to i8*
store float %20, float* %21
%23 = getelementptr inbounds float, float* %0, i64 11
store float -1.000000e+00, float* %23
%24 = getelementptr inbounds float, float* %0, i64 12
store float 0.000000e+00, float* %24
%25 = getelementptr inbounds float, float* %0, i64 13
store float 0.000000e+00, float* %25
%26 = fmul float %4, 2.000000e+00
%27 = fmul float %26, %3
%28 = fdiv float %27, %19
%29 = getelementptr inbounds float, float* %0, i64 14
store float %28, float* %29
%30 = getelementptr inbounds float, float* %0, i64 15
store float 0.000000e+00, float* %30
ret void
}