#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 acos(double);
double cos(double);
double pow(double, double);
double sqrt(double);
double Theta(double alpha, double beta, double z) {
  double C = (1.5e8 - z) / cos(alpha);
  double D = sqrt(pow(1.5e8, 2.0) + pow(C, 2.0) - 2.0 * 1.5e8 * C * cos(alpha));
  if (z >= 0.0 && alpha == 0)
    return 0.0;
  if (z < 0.0 && alpha == 0)
    return 3.141592654;
  return acos((pow(1.5e8, 2.0) + pow(D, 2.0) - pow(C, 2.0)) /
              (2.0 * 1.5e8 * D));
}


x86 assembly (clang, -O0):
<Theta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  0xeb1(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe84(%rip),%xmm0
movsd  0xe74(%rip),%xmm1
call   1050 <pow@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe5d(%rip),%xmm1
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe37(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
movsd  -0x40(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     124a <Theta+0x10a>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    124a <Theta+0x10a>
jp     124a <Theta+0x10a>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12f8 <Theta+0x1b8>
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1282 <Theta+0x142>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1282 <Theta+0x142>
jp     1282 <Theta+0x142>
movsd  0xda0(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12f8 <Theta+0x1b8>
movsd  0xd86(%rip),%xmm0
movsd  0xd76(%rip),%xmm1
call   1050 <pow@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xd5f(%rip),%xmm1
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xd3c(%rip),%xmm1
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  0xd1b(%rip),%xmm1
mulsd  -0x30(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1030 <acos@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Theta>:
sub    $0x28,%rsp
movsd  %xmm0,(%rsp)
movsd  0xebf(%rip),%xmm1
movsd  %xmm2,0x10(%rsp)
subsd  %xmm2,%xmm1
movsd  %xmm1,0x8(%rsp)
call   1040 <cos@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe92(%rip),%xmm1
movsd  %xmm0,0x18(%rsp)
addsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rsp)
movsd  (%rsp),%xmm0
call   1040 <cos@plt>
movsd  0x8(%rsp),%xmm1
mulsd  0xe72(%rip),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
addsd  0x20(%rsp),%xmm0
xorpd  %xmm4,%xmm4
ucomisd %xmm4,%xmm0
jb     11bc <Theta+0x8c>
sqrtsd %xmm0,%xmm0
jmp    11c5 <Theta+0x95>
call   1050 <sqrt@plt>
xorpd  %xmm4,%xmm4
movsd  0x10(%rsp),%xmm2
movsd  (%rsp),%xmm3
ucomisd %xmm4,%xmm3
jne    11e2 <Theta+0xb2>
jp     11e2 <Theta+0xb2>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm2
jae    11fc <Theta+0xcc>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm3
jne    1205 <Theta+0xd5>
jp     1205 <Theta+0xd5>
ucomisd %xmm2,%xmm1
jbe    1205 <Theta+0xd5>
movsd  0xe1c(%rip),%xmm4
movapd %xmm4,%xmm0
add    $0x28,%rsp
ret
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
addsd  0xdf3(%rip),%xmm1
subsd  0x18(%rsp),%xmm1
mulsd  0xdfd(%rip),%xmm0
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
jmp    1030 <acos@plt>

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

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