#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);
extern void warp_mat4_fill_perspective(float *matrix, float fov,
                                       float aspectRatio, float near,
                                       float far) {
  const float h = 1.0f / tanf(fov);
  const float neg_depth = near - far;
  const float m11 = h * aspectRatio;
  const float m22 = (far + near) / neg_depth;
  const float m23 = 2.0f * (near * far) / neg_depth;
  matrix[0] = m11;
  matrix[1] = 0;
  matrix[2] = 0;
  matrix[3] = 0;
  matrix[4] = 0;
  matrix[5] = h;
  matrix[6] = 0;
  matrix[7] = 0;
  matrix[8] = 0;
  matrix[9] = 0;
  matrix[10] = m22;
  matrix[11] = -1;
  matrix[12] = 0;
  matrix[13] = 0;
  matrix[14] = m23;
  matrix[15] = 0;
}


x86 assembly (clang, -O0):
<warp_mat4_fill_perspective>:
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  -0xc(%rbp),%xmm0
call   1030 <tanf@plt>
movaps %xmm0,%xmm1
movss  0xec3(%rip),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
subss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x1c(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x18(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
divss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x14(%rbp),%xmm1
mulss  -0x18(%rbp),%xmm1
movss  0xe72(%rip),%xmm0
mulss  %xmm1,%xmm0
divss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x2c(%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  -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  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x28(%rax)
mov    -0x8(%rbp),%rax
movss  0xdcb(%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  -0x2c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x38(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x3c(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<warp_mat4_fill_perspective>:
push   %rbx
sub    $0x10,%rsp
movss  %xmm3,0x8(%rsp)
movss  %xmm2,0x4(%rsp)
movss  %xmm1,0xc(%rsp)
mov    %rdi,%rbx
call   1030 <tanf@plt>
movss  0xec9(%rip),%xmm1
divss  %xmm0,%xmm1
movss  0x4(%rsp),%xmm3
movaps %xmm3,%xmm0
movss  0x8(%rsp),%xmm5
subss  %xmm5,%xmm0
movss  0xc(%rsp),%xmm4
mulss  %xmm1,%xmm4
movaps %xmm3,%xmm2
addss  %xmm5,%xmm2
divss  %xmm0,%xmm2
mulss  %xmm5,%xmm3
addss  %xmm3,%xmm3
divss  %xmm0,%xmm3
movss  %xmm4,(%rbx)
xorps  %xmm0,%xmm0
movups %xmm0,0x4(%rbx)
movss  %xmm1,0x14(%rbx)
movups %xmm0,0x18(%rbx)
movss  %xmm2,0x28(%rbx)
mov    $0xbf800000,%eax
mov    %rax,0x2c(%rbx)
movl   $0x0,0x34(%rbx)
movss  %xmm3,0x38(%rbx)
movl   $0x0,0x3c(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define void @warp_mat4_fill_perspective(float* nocapture writeonly %0, float %1, float %2, float %3, float %4) {
%6 = tail call float @tanf(float %1)
%7 = fdiv float 1.000000e+00, %6
%8 = fsub float %3, %4
%9 = fmul float %7, %2
%10 = fadd float %3, %4
%11 = fdiv float %10, %8
%12 = fmul float %3, %4
%13 = fmul float %12, 2.000000e+00
%14 = fdiv float %13, %8
store float %9, float* %0
%15 = getelementptr inbounds float, float* %0, i64 1
%16 = getelementptr inbounds float, float* %0, i64 5
%17 = bitcast float* %15 to i8*
store float %7, float* %16
%18 = getelementptr inbounds float, float* %0, i64 6
%19 = getelementptr inbounds float, float* %0, i64 10
%20 = bitcast float* %18 to i8*
store float %11, 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 = getelementptr inbounds float, float* %0, i64 14
store float %14, float* %24
%25 = getelementptr inbounds float, float* %0, i64 15
store float 0.000000e+00, float* %25
ret void
}