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


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  -0x8(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
movss  0xe6c(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe64(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1040 <tan@plt>
movaps %xmm0,%xmm1
movss  -0x18(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
divss  -0x14(%rbp),%xmm0
call   1030 <atan@plt>
movss  %xmm0,-0x10(%rbp)
movss  0xe22(%rip),%xmm0
mulss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe19(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%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    0xebb(%rip),%rsi
mov    $0x1,%edi
movss  %xmm0,0xc(%rsp)
call   1050 <Com_Error@plt>
movss  0xc(%rsp),%xmm0
divss  0xe8d(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xe89(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1040 <tan@plt>
movss  0x10(%rsp),%xmm1
divss  %xmm0,%xmm1
movss  0x14(%rsp),%xmm0
divss  %xmm1,%xmm0
call   1030 <atan@plt>
mulss  0xe57(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
divsd  0xe53(%rip),%xmm0
cvtsd2ss %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
%7 = alloca float
%8 = alloca float
store float %0, float* %4
store float %1, float* %5
store float %2, float* %6
%9 = load float, float* %4
%10 = fcmp olt float %9, 1.000000e+00
br i1 %10, label %14, label %11
11: ; preds = %3
%12 = load float, float* %4
%13 = fcmp ogt float %12, 1.790000e+02
br i1 %13, label %14, label %17
14: ; preds = %11, %3
%15 = load float, float* %4
%16 = call i32 @Com_Error(i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), float %15)
br label %17
17: ; preds = %14, %11
%18 = load float, float* %5
%19 = load float, float* %4
%20 = fdiv float %19, 3.600000e+02
%21 = fpext float %20 to double
%22 = fmul double %21, 0x400921FB54442D18
%23 = fptrunc double %22 to float
%24 = call float @tan(float %23)
%25 = fdiv float %18, %24
store float %25, float* %8
%26 = load float, float* %6
%27 = load float, float* %8
%28 = fdiv float %26, %27
%29 = call float @atan(float %28)
store float %29, float* %7
%30 = load float, float* %7
%31 = fmul float %30, 3.600000e+02
%32 = fpext float %31 to double
%33 = fdiv double %32, 0x400921FB54442D18
%34 = fptrunc double %33 to float
store float %34, float* %7
%35 = load float, float* %7
ret float %35
}

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 = fpext float %10 to double
%12 = fmul double %11, 0x400921FB54442D18
%13 = fptrunc double %12 to float
%14 = tail call float @tan(float %13)
%15 = fdiv float %1, %14
%16 = fdiv float %2, %15
%17 = tail call float @atan(float %16)
%18 = fmul float %17, 3.600000e+02
%19 = fpext float %18 to double
%20 = fdiv double %19, 0x400921FB54442D18
%21 = fptrunc double %20 to float
ret float %21
}