#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 */
float cosf(float);
float sinf(float);
float *mat4_perspective_fov(float *result, float fov, float w, float h, float n,
                            float f) {
  float h2 = cosf(fov * 0.5f) / sinf(fov * 0.5f);
  float w2 = h2 * h / w;
  result[0] = w2;
  result[1] = 0.0f;
  result[2] = 0.0f;
  result[3] = 0.0f;
  result[4] = 0.0f;
  result[5] = h2;
  result[6] = 0.0f;
  result[7] = 0.0f;
  result[8] = 0.0f;
  result[9] = 0.0f;
  result[10] = f / (n - f);
  result[11] = -1.0f;
  result[12] = 0.0f;
  result[13] = 0.0f;
  result[14] = -(f * n) / (f - n);
  result[15] = 0.0f;
  return result;
}


x86 assembly (clang, -O0):
<mat4_perspective_fov>:
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  %xmm4,-0x1c(%rbp)
movss  0xeb7(%rip),%xmm0
mulss  -0xc(%rbp),%xmm0
call   1040 <cosf@plt>
movss  %xmm0,-0x28(%rbp)
movss  0xea0(%rip),%xmm0
mulss  -0xc(%rbp),%xmm0
call   1030 <sinf@plt>
movaps %xmm0,%xmm1
movss  -0x28(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
divss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%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  -0x20(%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  -0x1c(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
subss  -0x1c(%rbp),%xmm1
divss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x28(%rax)
mov    -0x8(%rbp),%rax
movss  0xdca(%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  -0x1c(%rbp),%xmm0
mulss  -0x18(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  -0x1c(%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)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mat4_perspective_fov>:
push   %rbx
sub    $0x30,%rsp
movaps %xmm4,0x20(%rsp)
movss  %xmm3,0x1c(%rsp)
movss  %xmm2,0x14(%rsp)
movss  %xmm1,0x18(%rsp)
mov    %rdi,%rbx
mulss  0xeb9(%rip),%xmm0
movss  %xmm0,0xc(%rsp)
call   1040 <cosf@plt>
movss  %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <sinf@plt>
movss  0x10(%rsp),%xmm1
divss  %xmm0,%xmm1
movss  0x14(%rsp),%xmm0
mulss  %xmm1,%xmm0
divss  0x18(%rsp),%xmm0
movss  %xmm0,(%rbx)
xorps  %xmm0,%xmm0
movups %xmm0,0x4(%rbx)
movss  %xmm1,0x14(%rbx)
movss  0x1c(%rsp),%xmm4
movaps %xmm4,%xmm1
movaps 0x20(%rsp),%xmm3
subss  %xmm3,%xmm1
movaps %xmm3,%xmm2
divss  %xmm1,%xmm2
movups %xmm0,0x18(%rbx)
movss  %xmm2,0x28(%rbx)
mov    $0xbf800000,%eax
mov    %rax,0x2c(%rbx)
movl   $0x0,0x34(%rbx)
movaps 0xe4a(%rip),%xmm0
xorps  %xmm3,%xmm0
mulss  %xmm4,%xmm0
subss  %xmm4,%xmm3
divss  %xmm3,%xmm0
movss  %xmm0,0x38(%rbx)
movl   $0x0,0x3c(%rbx)
mov    %rbx,%rax
add    $0x30,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define float* @mat4_perspective_fov(float* returned writeonly %0, float %1, float %2, float %3, float %4, float %5) {
%7 = fmul float %1, 5.000000e-01
%8 = tail call float @cosf(float %7)
%9 = tail call float @sinf(float %7)
%10 = fdiv float %8, %9
%11 = fmul float %10, %3
%12 = fdiv float %11, %2
store float %12, float* %0
%13 = getelementptr inbounds float, float* %0, i64 1
%14 = getelementptr inbounds float, float* %0, i64 5
%15 = bitcast float* %13 to i8*
store float %10, float* %14
%16 = getelementptr inbounds float, float* %0, i64 6
%17 = fsub float %4, %5
%18 = fdiv float %5, %17
%19 = getelementptr inbounds float, float* %0, i64 10
%20 = bitcast float* %16 to i8*
store float %18, float* %19
%21 = getelementptr inbounds float, float* %0, i64 11
store float -1.000000e+00, float* %21
%22 = getelementptr inbounds float, float* %0, i64 12
store float 0.000000e+00, float* %22
%23 = getelementptr inbounds float, float* %0, i64 13
store float 0.000000e+00, float* %23
%24 = fneg float %5
%25 = fmul float %24, %4
%26 = fsub float %5, %4
%27 = fdiv float %25, %26
%28 = getelementptr inbounds float, float* %0, i64 14
store float %27, float* %28
%29 = getelementptr inbounds float, float* %0, i64 15
store float 0.000000e+00, float* %29
ret float* %0
}