#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*/ genZeroMatrix(float *);
int tanf(float);
void genPerspectiveMatrix(float fovY, float aspect, float zNear, float zFar,
                          float matrix[16]) {
  float f;
  f = 1 / tanf(fovY / 2);
  genZeroMatrix(matrix);
  matrix[0] = f / aspect;
  matrix[5] = f;
  matrix[10] = (zFar + zNear) / (zNear - zFar);
  matrix[11] = 2 * zFar * zNear / (zNear - zFar);
  matrix[14] = -1;
}


x86 assembly (clang, -O0):
<genPerspectiveMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  %xmm3,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
movss  0xeb7(%rip),%xmm1
divss  %xmm1,%xmm0
call   1030 <tanf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <genZeroMatrix@plt>
movss  -0x1c(%rbp),%xmm0
divss  -0x8(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x1c(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x14(%rax)
movss  -0x10(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
subss  -0x10(%rbp),%xmm1
divss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x28(%rax)
movss  0xe49(%rip),%xmm0
mulss  -0x10(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
subss  -0x10(%rbp),%xmm1
divss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x2c(%rax)
mov    -0x18(%rbp),%rax
movss  0xe18(%rip),%xmm0
movss  %xmm0,0x38(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genPerspectiveMatrix>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movss  %xmm3,0xc(%rsp)
movss  %xmm2,0x8(%rsp)
movss  %xmm1,0x4(%rsp)
mulss  0xebe(%rip),%xmm0
call   1030 <tanf@plt>
lea    0x1(%rax),%ecx
xor    %edx,%edx
cmp    $0x3,%ecx
cmovb  %eax,%edx
xorps  %xmm0,%xmm0
cvtsi2ss %edx,%xmm0
movss  %xmm0,(%rsp)
mov    %rbx,%rdi
call   1040 <genZeroMatrix@plt>
movss  (%rsp),%xmm1
movaps %xmm1,%xmm0
divss  0x4(%rsp),%xmm0
movss  %xmm0,(%rbx)
movss  %xmm1,0x14(%rbx)
movss  0x8(%rsp),%xmm3
movaps %xmm3,%xmm0
movss  0xc(%rsp),%xmm2
addss  %xmm2,%xmm0
movaps %xmm3,%xmm1
subss  %xmm2,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,0x28(%rbx)
addss  %xmm2,%xmm2
mulss  %xmm3,%xmm2
divss  %xmm1,%xmm2
movss  %xmm2,0x2c(%rbx)
movl   $0xbf800000,0x38(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define void @genPerspectiveMatrix(float %0, float %1, float %2, float %3, float* %4) {
%6 = fmul float %0, 5.000000e-01
%7 = tail call i32 @tanf(float %6)
%8 = add i32 %7, 1
%9 = icmp ult i32 %8, 3
%10 = select i1 %9, i32 %7, i32 0
%11 = sitofp i32 %10 to float
%12 = tail call i32 @genZeroMatrix(float* %4)
%13 = fdiv float %11, %1
store float %13, float* %4
%14 = getelementptr inbounds float, float* %4, i64 5
store float %11, float* %14
%15 = fadd float %2, %3
%16 = fsub float %2, %3
%17 = fdiv float %15, %16
%18 = getelementptr inbounds float, float* %4, i64 10
store float %17, float* %18
%19 = fmul float %3, 2.000000e+00
%20 = fmul float %19, %2
%21 = fdiv float %20, %16
%22 = getelementptr inbounds float, float* %4, i64 11
store float %21, float* %22
%23 = getelementptr inbounds float, float* %4, i64 14
store float -1.000000e+00, float* %23
ret void
}