#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*/ hpmDegreesToRadians(float);
int /*<<< orphan*/ hpmFrustum(float, float, float, float, float, float,
                              float *);
float tan(int /*<<< orphan*/);
void hpmPerspective(int width, int height, float near, float far, float angle,
                    float *mat) {
  float scale = tan(hpmDegreesToRadians(angle * 0.5)) * near;
  float r = ((float)width / (float)height) * scale;
  float l = -r;
  float t = scale;
  float b = -t;
  hpmFrustum(l, r, b, t, near, far, mat);
}


x86 assembly (clang, -O0):
<hpmPerspective>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  %xmm1,-0x10(%rbp)
movss  %xmm2,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe9e(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <hpmDegreesToRadians@plt>
mov    %eax,%edi
call   1040 <tan@plt>
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
cvtsi2ssl -0x4(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
mulss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x30(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x2c(%rbp),%xmm0
movss  -0x28(%rbp),%xmm1
movss  -0x34(%rbp),%xmm2
movss  -0x30(%rbp),%xmm3
movss  -0xc(%rbp),%xmm4
movss  -0x10(%rbp),%xmm5
mov    -0x20(%rbp),%rdi
call   1050 <hpmFrustum@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hpmPerspective>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
movss  %xmm1,0xc(%rsp)
movss  %xmm0,0x8(%rsp)
mov    %esi,%ebp
mov    %edi,%ebx
mulss  0xead(%rip),%xmm2
movaps %xmm2,%xmm0
call   1030 <hpmDegreesToRadians@plt>
mov    %eax,%edi
call   1040 <tan@plt>
movaps %xmm0,%xmm3
movss  0x8(%rsp),%xmm4
mulss  %xmm4,%xmm3
xorps  %xmm1,%xmm1
cvtsi2ss %ebx,%xmm1
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
divss  %xmm0,%xmm1
mulss  %xmm3,%xmm1
movaps 0xe84(%rip),%xmm2
movaps %xmm1,%xmm0
xorps  %xmm2,%xmm0
xorps  %xmm3,%xmm2
movss  0xc(%rsp),%xmm5
mov    %r14,%rdi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <hpmFrustum@plt>

LLVM IR (-O0):
define void @hpmPerspective(i32 %0, i32 %1, float %2, float %3, float %4, float* %5) {
%7 = alloca i32
%8 = alloca i32
%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 i32 %0, i32* %7
store i32 %1, i32* %8
store float %2, float* %9
store float %3, float* %10
store float %4, float* %11
store float* %5, float** %12
%18 = load float, float* %11
%19 = fpext float %18 to double
%20 = fmul double %19, 5.000000e-01
%21 = fptrunc double %20 to float
%22 = call i32 @hpmDegreesToRadians(float %21)
%23 = call float @tan(i32 %22)
%24 = load float, float* %9
%25 = fmul float %23, %24
store float %25, float* %13
%26 = load i32, i32* %7
%27 = sitofp i32 %26 to float
%28 = load i32, i32* %8
%29 = sitofp i32 %28 to float
%30 = fdiv float %27, %29
%31 = load float, float* %13
%32 = fmul float %30, %31
store float %32, float* %14
%33 = load float, float* %14
%34 = fneg float %33
store float %34, float* %15
%35 = load float, float* %13
store float %35, float* %16
%36 = load float, float* %16
%37 = fneg float %36
store float %37, float* %17
%38 = load float, float* %15
%39 = load float, float* %14
%40 = load float, float* %17
%41 = load float, float* %16
%42 = load float, float* %9
%43 = load float, float* %10
%44 = load float*, float** %12
%45 = call i32 @hpmFrustum(float %38, float %39, float %40, float %41, float %42, float %43, float* %44)
ret void
}

LLVM IR (-O2):
define void @hpmPerspective(i32 %0, i32 %1, float %2, float %3, float %4, float* %5) {
%7 = fmul float %4, 5.000000e-01
%8 = tail call i32 @hpmDegreesToRadians(float %7)
%9 = tail call float @tan(i32 %8)
%10 = fmul float %9, %2
%11 = sitofp i32 %0 to float
%12 = sitofp i32 %1 to float
%13 = fdiv float %11, %12
%14 = fmul float %13, %10
%15 = fneg float %14
%16 = fneg float %10
%17 = tail call i32 @hpmFrustum(float %15, float %14, float %16, float %10, float %2, float %3, float* %5)
ret void
}