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


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    1180 <CalcFov+0x50>
movss  -0x4(%rbp),%xmm0
lea    0xe9d(%rip),%rdi
call   1030 <Sys_Error@plt>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x4(%rbp),%xmm0
movss  0xe71(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe69(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1050 <tan@plt>
movaps %xmm0,%xmm1
movss  -0x14(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
divss  -0x10(%rbp),%xmm0
call   1040 <atan@plt>
imul   $0x168,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe2a(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%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    116e <CalcFov+0x3e>
lea    0xebb(%rip),%rdi
movss  %xmm0,0xc(%rsp)
call   1030 <Sys_Error@plt>
movss  0xc(%rsp),%xmm0
divss  0xe92(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xe8e(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1050 <tan@plt>
movss  0x10(%rsp),%xmm1
divss  %xmm0,%xmm1
movss  0x14(%rsp),%xmm0
divss  %xmm1,%xmm0
call   1040 <atan@plt>
imul   $0x168,%eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xe57(%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
store float %0, float* %4
store float %1, float* %5
store float %2, float* %6
%8 = load float, float* %4
%9 = fcmp olt float %8, 1.000000e+00
br i1 %9, label %13, label %10
10: ; preds = %3
%11 = load float, float* %4
%12 = fcmp ogt float %11, 1.790000e+02
br i1 %12, label %13, label %16
13: ; preds = %10, %3
%14 = load float, float* %4
%15 = call i32 @Sys_Error(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), float %14)
br label %16
16: ; preds = %13, %10
%17 = load float, float* %5
%18 = load float, float* %4
%19 = fdiv float %18, 3.600000e+02
%20 = fpext float %19 to double
%21 = fmul double %20, 0x400921FB54442D18
%22 = fptrunc double %21 to float
%23 = call float @tan(float %22)
%24 = fdiv float %17, %23
store float %24, float* %7
%25 = load float, float* %6
%26 = load float, float* %7
%27 = fdiv float %25, %26
%28 = call i32 @atan(float %27)
%29 = mul nsw i32 %28, 360
%30 = sitofp i32 %29 to double
%31 = fdiv double %30, 0x400921FB54442D18
%32 = fptrunc double %31 to float
ret float %32
}

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 @Sys_Error(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 i32 @atan(float %16)
%18 = mul nsw i32 %17, 360
%19 = sitofp i32 %18 to double
%20 = fdiv double %19, 0x400921FB54442D18
%21 = fptrunc double %20 to float
ret float %21
}