#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*/ Com_Error(int, char *, float);
float atan(float);
float tan(float);
float CalcFov(float fov_x, float width, float height) {
  if (fov_x < 1 || fov_x > 179) {
    Com_Error(1, "Bad fov: %f", fov_x);
  }
  return (float)((int)((atan(height / (width / tan(fov_x / 360 *
                                                   3.14159265358979323846f)))) *
                       57.2957795130823209071f)) *
         2;
}


x86 assembly (clang, -O0):
<CalcFov>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  0xeb1(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
ja     116f <CalcFov+0x3f>
movss  -0x4(%rbp),%xmm0
movss  0xe9e(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    1185 <CalcFov+0x55>
movss  -0x4(%rbp),%xmm0
mov    $0x1,%edi
lea    0xe98(%rip),%rsi
call   1050 <Com_Error@plt>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x4(%rbp),%xmm0
movss  0xe6e(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xe5e(%rip),%xmm1
mulss  %xmm1,%xmm0
call   1040 <tan@plt>
movss  -0x14(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  -0x10(%rbp),%xmm0
divss  %xmm2,%xmm1
divss  %xmm1,%xmm0
call   1030 <atan@plt>
movss  0xe2f(%rip),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
cvtsi2ss %eax,%xmm0
movss  0xe17(%rip),%xmm1
mulss  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CalcFov>:
sub    $0x18,%rsp
movss  %xmm2,0x14(%rsp)
movss  %xmm1,0x10(%rsp)
movss  0xeb8(%rip),%xmm1
ucomiss %xmm0,%xmm1
ja     1156 <CalcFov+0x26>
ucomiss 0xeb0(%rip),%xmm0
jbe    1173 <CalcFov+0x43>
lea    0xeb7(%rip),%rsi
mov    $0x1,%edi
movss  %xmm0,0xc(%rsp)
call   1050 <Com_Error@plt>
movss  0xc(%rsp),%xmm0
divss  0xe8d(%rip),%xmm0
mulss  0xe89(%rip),%xmm0
call   1040 <tan@plt>
movss  0x10(%rsp),%xmm1
divss  %xmm0,%xmm1
movss  0x14(%rsp),%xmm0
divss  %xmm1,%xmm0
call   1030 <atan@plt>
mulss  0xe67(%rip),%xmm0
cvttps2dq %xmm0,%xmm0
cvtdq2ps %xmm0,%xmm0
addss  %xmm0,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Bad fov: %f\00"
define float @CalcFov(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
store float %0, float* %4
store float %1, float* %5
store float %2, float* %6
%7 = load float, float* %4
%8 = fcmp olt float %7, 1.000000e+00
br i1 %8, label %12, label %9
9: ; preds = %3
%10 = load float, float* %4
%11 = fcmp ogt float %10, 1.790000e+02
br i1 %11, label %12, label %15
12: ; preds = %9, %3
%13 = load float, float* %4
%14 = call i32 @Com_Error(i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), float %13)
br label %15
15: ; preds = %12, %9
%16 = load float, float* %6
%17 = load float, float* %5
%18 = load float, float* %4
%19 = fdiv float %18, 3.600000e+02
%20 = fmul float %19, 0x400921FB60000000
%21 = call float @tan(float %20)
%22 = fdiv float %17, %21
%23 = fdiv float %16, %22
%24 = call float @atan(float %23)
%25 = fmul float %24, 0x404CA5DC20000000
%26 = fptosi float %25 to i32
%27 = sitofp i32 %26 to float
%28 = fmul float %27, 2.000000e+00
ret float %28
}

LLVM IR (-O2):
@.str = [12 x i8] c"Bad fov: %f\00"
define float @CalcFov(float %0, float %1, float %2) {
%4 = fcmp olt float %0, 1.000000e+00
%5 = fcmp ogt float %0, 1.790000e+02
%6 = or i1 %4, %5
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @Com_Error(i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), float %0)
br label %9
9: ; preds = %3, %7
%10 = fdiv float %0, 3.600000e+02
%11 = fmul float %10, 0x400921FB60000000
%12 = tail call float @tan(float %11)
%13 = fdiv float %1, %12
%14 = fdiv float %2, %13
%15 = tail call float @atan(float %14)
%16 = fmul float %15, 0x404CA5DC20000000
%17 = fptosi float %16 to i32
%18 = sitofp i32 %17 to float
%19 = fmul float %18, 2.000000e+00
ret float %19
}