#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);
scalar_t__ atan2(float, float);
scalar_t__ 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);
  width = width / (float)tan(fov_x / 360 * 3.14159265358979323846f);
  return (float)atan2(height, width) * 360 / 3.14159265358979323846f;
}


x86 assembly (clang, -O0):
<CalcFov>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%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    0xe90(%rip),%rsi
call   1050 <Com_Error@plt>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
movss  0xe70(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xe60(%rip),%xmm1
mulss  %xmm1,%xmm0
call   1040 <tan@plt>
movss  -0x10(%rbp),%xmm0
cvtsi2ss %rax,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
call   1030 <atan2@plt>
cvtsi2ss %rax,%xmm0
movss  0xe2c(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe1c(%rip),%xmm1
divss  %xmm1,%xmm0
add    $0x10,%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    0xeb3(%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>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  0x10(%rsp),%xmm1
divss  %xmm0,%xmm1
movss  0x14(%rsp),%xmm0
call   1030 <atan2@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mulss  0xe53(%rip),%xmm0
divss  0xe4f(%rip),%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* %5
%17 = load float, float* %4
%18 = fdiv float %17, 3.600000e+02
%19 = fmul float %18, 0x400921FB60000000
%20 = call i64 @tan(float %19)
%21 = sitofp i64 %20 to float
%22 = fdiv float %16, %21
store float %22, float* %5
%23 = load float, float* %6
%24 = load float, float* %5
%25 = call i64 @atan2(float %23, float %24)
%26 = sitofp i64 %25 to float
%27 = fmul float %26, 3.600000e+02
%28 = fdiv float %27, 0x400921FB60000000
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 i64 @tan(float %11)
%13 = sitofp i64 %12 to float
%14 = fdiv float %1, %13
%15 = tail call i64 @atan2(float %2, float %14)
%16 = sitofp i64 %15 to float
%17 = fmul float %16, 3.600000e+02
%18 = fdiv float %17, 0x400921FB60000000
ret float %18
}