#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 tanf(float);
float *mat4_perspective_infinite(float *result, float fov_y, float aspect,
                                 float n) {
  float range = tanf(fov_y * 0.5f) * n;
  float left = -range * aspect;
  float right = range * aspect;
  float top = range;
  float bottom = -range;
  result[0] = 2.0f * n / (right - left);
  result[1] = 0.0f;
  result[2] = 0.0f;
  result[3] = 0.0f;
  result[4] = 0.0f;
  result[5] = 2.0f * n / (top - bottom);
  result[6] = 0.0f;
  result[7] = 0.0f;
  result[8] = 0.0f;
  result[9] = 0.0f;
  result[10] = -1.0f;
  result[11] = -1.0f;
  result[12] = 0.0f;
  result[13] = 0.0f;
  result[14] = -2.0f * n;
  result[15] = 0.0f;
  return result;
}


x86 assembly (clang, -O0):
<mat4_perspective_infinite>:
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  0xed9(%rip),%xmm0
mulss  -0xc(%rbp),%xmm0
call   1030 <tanf@plt>
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x18(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  0xe6d(%rip),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  -0x20(%rbp),%xmm1
subss  -0x1c(%rbp),%xmm1
divss  %xmm1,%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  0xe1a(%rip),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  -0x24(%rbp),%xmm1
subss  -0x28(%rbp),%xmm1
divss  %xmm1,%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)
mov    -0x8(%rbp),%rax
movss  0xdbe(%rip),%xmm0
movss  %xmm0,0x28(%rax)
mov    -0x8(%rbp),%rax
movss  0xdad(%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  0xd84(%rip),%xmm0
mulss  -0x14(%rbp),%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_infinite>:
push   %rbx
sub    $0x10,%rsp
movss  %xmm2,0x8(%rsp)
movss  %xmm1,0xc(%rsp)
mov    %rdi,%rbx
mulss  0xed4(%rip),%xmm0
call   1030 <tanf@plt>
movss  0x8(%rsp),%xmm2
mulss  %xmm2,%xmm0
movss  0xc(%rsp),%xmm4
mulss  %xmm0,%xmm4
movaps %xmm2,%xmm1
movaps %xmm2,%xmm3
addss  %xmm2,%xmm1
addss  %xmm4,%xmm4
movaps %xmm1,%xmm2
divss  %xmm4,%xmm2
movss  %xmm2,(%rbx)
addss  %xmm0,%xmm0
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
movups %xmm0,0x4(%rbx)
movss  %xmm1,0x14(%rbx)
movups %xmm0,0x18(%rbx)
movaps 0xe93(%rip),%xmm0
movups %xmm0,0x28(%rbx)
mulss  0xe7b(%rip),%xmm3
movss  %xmm3,0x38(%rbx)
movl   $0x0,0x3c(%rbx)
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define float* @mat4_perspective_infinite(float* returned writeonly %0, float %1, float %2, float %3) {
%5 = fmul float %1, 5.000000e-01
%6 = tail call float @tanf(float %5)
%7 = fmul float %6, %3
%8 = fmul float %7, %2
%9 = fmul float %3, 2.000000e+00
%10 = fadd float %8, %8
%11 = fdiv float %9, %10
store float %11, float* %0
%12 = getelementptr inbounds float, float* %0, i64 1
%13 = fadd float %7, %7
%14 = fdiv float %9, %13
%15 = getelementptr inbounds float, float* %0, i64 5
%16 = bitcast float* %12 to i8*
store float %14, float* %15
%17 = getelementptr inbounds float, float* %0, i64 6
%18 = getelementptr inbounds float, float* %0, i64 10
%19 = bitcast float* %17 to i8*
%20 = bitcast float* %18 to <4 x float>*
store <4 x float> <float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 0.000000e+00>, <4 x float>* %20
%21 = fmul float %3, -2.000000e+00
%22 = getelementptr inbounds float, float* %0, i64 14
store float %21, float* %22
%23 = getelementptr inbounds float, float* %0, i64 15
store float 0.000000e+00, float* %23
ret float* %0
}