#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 */
double cos(double);
double pow(double, double);
double sqrt(double);
double tan(double);
double R(double alpha, double beta, double z) {
  double C;
  double C2;
  double D;
  double B;
  double B2;
  if (alpha == 0.0) {
    C = 1.5e8 - z;
    D = z;
  } else {
    C = (1.5e8 - z) / cos(alpha);
    C2 = pow(1.5e8, 2.0) + (pow(C, 2.0) - 2.0 * 1.5e8 * C * cos(alpha));
    D = sqrt(C2);
  }
  B = C * tan(beta);
  B2 = pow(B, 2.0) + pow(D, 2.0);
  return sqrt(B2);
}


x86 assembly (clang, -O0):
<R>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1190 <R+0x50>
jp     1190 <R+0x50>
movsd  0xe99(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1253 <R+0x113>
movsd  0xe78(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe4b(%rip),%xmm0
movsd  0xe3b(%rip),%xmm1
call   1050 <pow@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe24(%rip),%xmm1
call   1050 <pow@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  0xe0a(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <cos@plt>
movsd  -0x58(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x48(%rbp),%xmm0
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <tan@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xd83(%rip),%xmm1
call   1050 <pow@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xd6c(%rip),%xmm1
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1060 <sqrt@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<R>:
sub    $0x28,%rsp
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm0
movsd  0xebc(%rip),%xmm3
subsd  %xmm2,%xmm3
movsd  %xmm3,0x10(%rsp)
jne    115a <R+0x2a>
jp     115a <R+0x2a>
movsd  %xmm2,0x8(%rsp)
jmp    11d9 <R+0xa9>
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x20(%rsp)
call   1040 <cos@plt>
movsd  0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x20(%rsp),%xmm0
call   1040 <cos@plt>
movapd %xmm0,%xmm1
movsd  0xe68(%rip),%xmm0
mulsd  0x10(%rsp),%xmm0
mulsd  %xmm1,%xmm0
addsd  0x8(%rsp),%xmm0
addsd  0xe58(%rip),%xmm0
ucomisd 0xe58(%rip),%xmm0
jb     11c8 <R+0x98>
sqrtsd %xmm0,%xmm0
jmp    11cd <R+0x9d>
call   1050 <sqrt@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm1
movapd %xmm1,%xmm0
call   1030 <tan@plt>
mulsd  0x10(%rsp),%xmm0
mulsd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
ucomisd 0xe16(%rip),%xmm1
movapd %xmm1,%xmm0
jb     1211 <R+0xe1>
sqrtsd %xmm0,%xmm0
add    $0x28,%rsp
ret
add    $0x28,%rsp
jmp    1050 <sqrt@plt>

LLVM IR (-O0):
define double @R(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%12 = load double, double* %4
%13 = fcmp oeq double %12, 0.000000e+00
br i1 %13, label %14, label %18
14: ; preds = %3
%15 = load double, double* %6
%16 = fsub double 1.500000e+08, %15
store double %16, double* %7
%17 = load double, double* %6
store double %17, double* %9
br label %36
18: ; preds = %3
%19 = load double, double* %6
%20 = fsub double 1.500000e+08, %19
%21 = load double, double* %4
%22 = call double @cos(double %21)
%23 = fdiv double %20, %22
store double %23, double* %7
%24 = call double @pow(double 1.500000e+08, double 2.000000e+00)
%25 = load double, double* %7
%26 = call double @pow(double %25, double 2.000000e+00)
%27 = load double, double* %7
%28 = fmul double 3.000000e+08, %27
%29 = load double, double* %4
%30 = call double @cos(double %29)
%31 = fneg double %28
%32 = call double @llvm.fmuladd.f64(double %31, double %30, double %26)
%33 = fadd double %24, %32
store double %33, double* %8
%34 = load double, double* %8
%35 = call double @sqrt(double %34)
store double %35, double* %9
br label %36
36: ; preds = %18, %14
%37 = load double, double* %7
%38 = load double, double* %5
%39 = call double @tan(double %38)
%40 = fmul double %37, %39
store double %40, double* %10
%41 = load double, double* %10
%42 = call double @pow(double %41, double 2.000000e+00)
%43 = load double, double* %9
%44 = call double @pow(double %43, double 2.000000e+00)
%45 = fadd double %42, %44
store double %45, double* %11
%46 = load double, double* %11
%47 = call double @sqrt(double %46)
ret double %47
}

LLVM IR (-O2):
define double @R(double %0, double %1, double %2) {
%4 = fcmp oeq double %0, 0.000000e+00
%5 = fsub double 1.500000e+08, %2
br i1 %4, label %15, label %6
6: ; preds = %3
%7 = tail call double @cos(double %0)
%8 = fdiv double %5, %7
%9 = fmul double %8, %8
%10 = tail call double @cos(double %0)
%11 = fmul double %8, -3.000000e+08
%12 = tail call double @llvm.fmuladd.f64(double %11, double %10, double %9)
%13 = fadd double %12, 2.250000e+16
%14 = tail call double @sqrt(double %13)
br label %15
15: ; preds = %3, %6
%16 = phi double [ %14, %6 ], [ %2, %3 ]
%17 = phi double [ %8, %6 ], [ %5, %3 ]
%18 = tail call double @tan(double %1)
%19 = fmul double %17, %18
%20 = fmul double %19, %19
%21 = fmul double %16, %16
%22 = fadd double %21, %20
%23 = tail call double @sqrt(double %22)
ret double %23
}