#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 */
struct mat44 {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ mat44_set_frustum(struct mat44 *, float, float, float, float,
                                     float, float);
float tanf(float);
void mat44_set_perspective(struct mat44 *m, float fovy, float aspect,
                           float znear, float zfar) {
  float dy = znear * tanf(((fovy) / 180.0f * (3.141592653589793)) / 2);
  float dx = dy * aspect;
  mat44_set_frustum(m, -dx, dx, -dy, dy, znear, zfar);
}


x86 assembly (clang, -O0):
<mat44_set_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  -0x14(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0xc(%rbp),%xmm0
movss  0xeb9(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xea1(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe8d(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1040 <tanf@plt>
movaps %xmm0,%xmm1
movss  -0x24(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
movss  -0x20(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  -0x20(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm2
movd   %xmm2,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm2
movss  -0x1c(%rbp),%xmm3
movss  -0x14(%rbp),%xmm4
movss  -0x18(%rbp),%xmm5
call   1030 <mat44_set_frustum@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mat44_set_perspective>:
push   %rbx
sub    $0x20,%rsp
divss  0xed3(%rip),%xmm0
movss  %xmm3,0xc(%rsp)
movss  %xmm2,0x8(%rsp)
movaps %xmm1,0x10(%rsp)
mov    %rdi,%rbx
cvtss2sd %xmm0,%xmm0
mulsd  0xebb(%rip),%xmm0
mulsd  0xebb(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1040 <tanf@plt>
movaps %xmm0,%xmm3
movss  0x8(%rsp),%xmm4
mulss  %xmm4,%xmm3
movaps 0x10(%rsp),%xmm1
mulss  %xmm3,%xmm1
movaps 0xea5(%rip),%xmm2
movaps %xmm1,%xmm0
xorps  %xmm2,%xmm0
xorps  %xmm3,%xmm2
mov    %rbx,%rdi
movss  0xc(%rsp),%xmm5
add    $0x20,%rsp
pop    %rbx
jmp    1030 <mat44_set_frustum@plt>

LLVM IR (-O0):
%struct.mat44 = type { i32 }
define void @mat44_set_perspective(%struct.mat44* %0, float %1, float %2, float %3, float %4) {
%6 = alloca %struct.mat44*
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
store %struct.mat44* %0, %struct.mat44** %6
store float %1, float* %7
store float %2, float* %8
store float %3, float* %9
store float %4, float* %10
%13 = load float, float* %9
%14 = load float, float* %7
%15 = fdiv float %14, 1.800000e+02
%16 = fpext float %15 to double
%17 = fmul double %16, 0x400921FB54442D18
%18 = fdiv double %17, 2.000000e+00
%19 = fptrunc double %18 to float
%20 = call float @tanf(float %19)
%21 = fmul float %13, %20
store float %21, float* %11
%22 = load float, float* %11
%23 = load float, float* %8
%24 = fmul float %22, %23
store float %24, float* %12
%25 = load %struct.mat44*, %struct.mat44** %6
%26 = load float, float* %12
%27 = fneg float %26
%28 = load float, float* %12
%29 = load float, float* %11
%30 = fneg float %29
%31 = load float, float* %11
%32 = load float, float* %9
%33 = load float, float* %10
%34 = call i32 @mat44_set_frustum(%struct.mat44* %25, float %27, float %28, float %30, float %31, float %32, float %33)
ret void
}

LLVM IR (-O2):
%struct.mat44 = type { i32 }
define void @mat44_set_perspective(%struct.mat44* %0, float %1, float %2, float %3, float %4) {
%6 = fdiv float %1, 1.800000e+02
%7 = fpext float %6 to double
%8 = fmul double %7, 0x400921FB54442D18
%9 = fmul double %8, 5.000000e-01
%10 = fptrunc double %9 to float
%11 = tail call float @tanf(float %10)
%12 = fmul float %11, %3
%13 = fmul float %12, %2
%14 = fneg float %13
%15 = fneg float %12
%16 = tail call i32 @mat44_set_frustum(%struct.mat44* %0, float %14, float %13, float %15, float %12, float %3, float %4)
ret void
}