#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__ calloc(int, int);
float *PerspectiveMatrix(float right, float left, float top, float bottom,
                         float far, float near) {
  float *r;
  float zdifference, ydifference, xdifference;
  float double_near;
  r = (float *)calloc(sizeof(float), 16);
  zdifference = far - near;
  ydifference = top - bottom;
  xdifference = right - left;
  double_near = 2.0 * near;
  r[0] = double_near / xdifference;
  r[1] = 0.0;
  r[2] = 0.0;
  r[3] = 0.0;
  r[4] = 0.0;
  r[5] = double_near / ydifference;
  r[6] = 0.0;
  r[7] = 0.0;
  r[8] = (right + left) / xdifference;
  r[9] = (top + bottom) / ydifference;
  r[10] = -1.0 * ((far + near) / zdifference);
  r[11] = -1.0;
  r[12] = 0.0;
  r[13] = 0.0;
  r[14] = (-2.0 * far * near) / zdifference;
  r[15] = 0.0;
  return r;
}


x86 assembly (clang, -O0):
<PerspectiveMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  %xmm3,-0x10(%rbp)
movss  %xmm4,-0x14(%rbp)
movss  %xmm5,-0x18(%rbp)
mov    $0x4,%edi
mov    $0x10,%esi
call   1030 <calloc@plt>
mov    %rax,-0x20(%rbp)
movss  -0x14(%rbp),%xmm0
subss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0xc(%rbp),%xmm0
subss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x4(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe89(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x30(%rbp),%xmm0
divss  -0x2c(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x10(%rax)
movss  -0x30(%rbp),%xmm0
divss  -0x28(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,0x14(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x18(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x1c(%rax)
movss  -0x4(%rbp),%xmm0
addss  -0x8(%rbp),%xmm0
divss  -0x2c(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,0x20(%rax)
movss  -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
divss  -0x28(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,0x24(%rax)
movss  -0x14(%rbp),%xmm0
addss  -0x18(%rbp),%xmm0
divss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xdbc(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,0x28(%rax)
mov    -0x20(%rbp),%rax
movss  0xdaf(%rip),%xmm0
movss  %xmm0,0x2c(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x30(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x34(%rax)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xd69(%rip),%xmm0
mulsd  %xmm1,%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
movss  -0x24(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,0x38(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x3c(%rax)
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PerspectiveMatrix>:
sub    $0x38,%rsp
movaps %xmm5,0x20(%rsp)
movss  %xmm4,0x14(%rsp)
movss  %xmm3,0x1c(%rsp)
movss  %xmm2,0x10(%rsp)
movss  %xmm1,0x18(%rsp)
movss  %xmm0,0xc(%rsp)
mov    $0x4,%edi
mov    $0x10,%esi
call   1030 <calloc@plt>
movss  0x14(%rsp),%xmm10
movaps %xmm10,%xmm0
movaps 0x20(%rsp),%xmm5
subss  %xmm5,%xmm0
movss  0x10(%rsp),%xmm11
movaps %xmm11,%xmm2
movss  0x1c(%rsp),%xmm1
subss  %xmm1,%xmm2
movss  0xc(%rsp),%xmm6
movaps %xmm6,%xmm3
movss  0x18(%rsp),%xmm7
subss  %xmm7,%xmm3
cvtss2sd %xmm5,%xmm8
movaps %xmm5,%xmm4
movaps %xmm5,%xmm9
addss  %xmm5,%xmm4
movaps %xmm4,%xmm5
divss  %xmm3,%xmm5
movss  %xmm5,(%rax)
divss  %xmm2,%xmm4
xorps  %xmm5,%xmm5
movups %xmm5,0x4(%rax)
movss  %xmm4,0x14(%rax)
movq   $0x0,0x18(%rax)
movaps %xmm6,%xmm4
addss  %xmm7,%xmm4
divss  %xmm3,%xmm4
movss  %xmm4,0x20(%rax)
movaps %xmm11,%xmm3
addss  %xmm1,%xmm3
divss  %xmm2,%xmm3
movaps %xmm3,%xmm4
movaps %xmm9,%xmm3
addss  %xmm10,%xmm3
xorps  0xe1c(%rip),%xmm3
movss  %xmm4,0x24(%rax)
divss  %xmm0,%xmm3
movss  %xmm3,0x28(%rax)
mov    $0xbf800000,%ecx
mov    %rcx,0x2c(%rax)
xorps  %xmm2,%xmm2
cvtss2sd %xmm10,%xmm2
mulsd  0xe05(%rip),%xmm2
movl   $0x0,0x34(%rax)
mulsd  %xmm8,%xmm2
cvtss2sd %xmm0,%xmm0
divsd  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtsd2ss %xmm2,%xmm0
movss  %xmm0,0x38(%rax)
movl   $0x0,0x3c(%rax)
add    $0x38,%rsp
ret

LLVM IR (-O0):
define float* @PerspectiveMatrix(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
%15 = alloca float
%16 = alloca float
%17 = 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
%18 = call i64 @calloc(i32 4, i32 16)
%19 = inttoptr i64 %18 to float*
store float* %19, float** %13
%20 = load float, float* %11
%21 = load float, float* %12
%22 = fsub float %20, %21
store float %22, float* %14
%23 = load float, float* %9
%24 = load float, float* %10
%25 = fsub float %23, %24
store float %25, float* %15
%26 = load float, float* %7
%27 = load float, float* %8
%28 = fsub float %26, %27
store float %28, float* %16
%29 = load float, float* %12
%30 = fpext float %29 to double
%31 = fmul double 2.000000e+00, %30
%32 = fptrunc double %31 to float
store float %32, float* %17
%33 = load float, float* %17
%34 = load float, float* %16
%35 = fdiv float %33, %34
%36 = load float*, float** %13
%37 = getelementptr inbounds float, float* %36, i64 0
store float %35, float* %37
%38 = load float*, float** %13
%39 = getelementptr inbounds float, float* %38, i64 1
store float 0.000000e+00, float* %39
%40 = load float*, float** %13
%41 = getelementptr inbounds float, float* %40, i64 2
store float 0.000000e+00, float* %41
%42 = load float*, float** %13
%43 = getelementptr inbounds float, float* %42, i64 3
store float 0.000000e+00, float* %43
%44 = load float*, float** %13
%45 = getelementptr inbounds float, float* %44, i64 4
store float 0.000000e+00, float* %45
%46 = load float, float* %17
%47 = load float, float* %15
%48 = fdiv float %46, %47
%49 = load float*, float** %13
%50 = getelementptr inbounds float, float* %49, i64 5
store float %48, float* %50
%51 = load float*, float** %13
%52 = getelementptr inbounds float, float* %51, i64 6
store float 0.000000e+00, float* %52
%53 = load float*, float** %13
%54 = getelementptr inbounds float, float* %53, i64 7
store float 0.000000e+00, float* %54
%55 = load float, float* %7
%56 = load float, float* %8
%57 = fadd float %55, %56
%58 = load float, float* %16
%59 = fdiv float %57, %58
%60 = load float*, float** %13
%61 = getelementptr inbounds float, float* %60, i64 8
store float %59, float* %61
%62 = load float, float* %9
%63 = load float, float* %10
%64 = fadd float %62, %63
%65 = load float, float* %15
%66 = fdiv float %64, %65
%67 = load float*, float** %13
%68 = getelementptr inbounds float, float* %67, i64 9
store float %66, float* %68
%69 = load float, float* %11
%70 = load float, float* %12
%71 = fadd float %69, %70
%72 = load float, float* %14
%73 = fdiv float %71, %72
%74 = fpext float %73 to double
%75 = fmul double -1.000000e+00, %74
%76 = fptrunc double %75 to float
%77 = load float*, float** %13
%78 = getelementptr inbounds float, float* %77, i64 10
store float %76, float* %78
%79 = load float*, float** %13
%80 = getelementptr inbounds float, float* %79, i64 11
store float -1.000000e+00, float* %80
%81 = load float*, float** %13
%82 = getelementptr inbounds float, float* %81, i64 12
store float 0.000000e+00, float* %82
%83 = load float*, float** %13
%84 = getelementptr inbounds float, float* %83, i64 13
store float 0.000000e+00, float* %84
%85 = load float, float* %11
%86 = fpext float %85 to double
%87 = fmul double -2.000000e+00, %86
%88 = load float, float* %12
%89 = fpext float %88 to double
%90 = fmul double %87, %89
%91 = load float, float* %14
%92 = fpext float %91 to double
%93 = fdiv double %90, %92
%94 = fptrunc double %93 to float
%95 = load float*, float** %13
%96 = getelementptr inbounds float, float* %95, i64 14
store float %94, float* %96
%97 = load float*, float** %13
%98 = getelementptr inbounds float, float* %97, i64 15
store float 0.000000e+00, float* %98
%99 = load float*, float** %13
ret float* %99
}

LLVM IR (-O2):
define float* @PerspectiveMatrix(float %0, float %1, float %2, float %3, float %4, float %5) {
%7 = tail call i64 @calloc(i32 4, i32 16)
%8 = inttoptr i64 %7 to float*
%9 = fsub float %4, %5
%10 = fsub float %2, %3
%11 = fsub float %0, %1
%12 = fpext float %5 to double
%13 = fmul float %5, 2.000000e+00
%14 = fdiv float %13, %11
store float %14, float* %8
%15 = getelementptr inbounds float, float* %8, i64 1
%16 = fdiv float %13, %10
%17 = getelementptr inbounds float, float* %8, i64 5
%18 = bitcast float* %15 to i8*
store float %16, float* %17
%19 = getelementptr inbounds float, float* %8, i64 6
store float 0.000000e+00, float* %19
%20 = getelementptr inbounds float, float* %8, i64 7
store float 0.000000e+00, float* %20
%21 = fadd float %0, %1
%22 = fdiv float %21, %11
%23 = getelementptr inbounds float, float* %8, i64 8
store float %22, float* %23
%24 = fadd float %2, %3
%25 = fdiv float %24, %10
%26 = getelementptr inbounds float, float* %8, i64 9
store float %25, float* %26
%27 = fadd float %4, %5
%28 = fneg float %27
%29 = fdiv float %28, %9
%30 = getelementptr inbounds float, float* %8, i64 10
store float %29, float* %30
%31 = getelementptr inbounds float, float* %8, i64 11
store float -1.000000e+00, float* %31
%32 = getelementptr inbounds float, float* %8, i64 12
store float 0.000000e+00, float* %32
%33 = getelementptr inbounds float, float* %8, i64 13
store float 0.000000e+00, float* %33
%34 = fpext float %4 to double
%35 = fmul double %34, -2.000000e+00
%36 = fmul double %35, %12
%37 = fpext float %9 to double
%38 = fdiv double %36, %37
%39 = fptrunc double %38 to float
%40 = getelementptr inbounds float, float* %8, i64 14
store float %39, float* %40
%41 = getelementptr inbounds float, float* %8, i64 15
store float 0.000000e+00, float* %41
ret float* %8
}