#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 M_PI_2;
double atan(int /*<<< orphan*/);
double cos(double);
double sin(double);
int /*<<< orphan*/ tan(double);
double ang_equiv2(double theta) {
  if (cos(theta) == 0.0) {
    if (sin(theta) >= 0.0)
      return M_PI_2;
    else
      return -M_PI_2;
  } else
    return (atan(tan(theta)));
}


x86 assembly (clang, -O0):
<ang_equiv2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1060 <cos@plt>
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11c2 <ang_equiv2+0x82>
jp     11c2 <ang_equiv2+0x82>
movsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1196 <ang_equiv2+0x56>
mov    0x2e60(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11d8 <ang_equiv2+0x98>
mov    0x2e4b(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11d8 <ang_equiv2+0x98>
movsd  -0x10(%rbp),%xmm0
call   1050 <tan@plt>
mov    %eax,%edi
call   1040 <atan@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ang_equiv2>:
push   %rax
movsd  %xmm0,(%rsp)
call   1060 <cos@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    117f <ang_equiv2+0x3f>
jp     117f <ang_equiv2+0x3f>
movsd  (%rsp),%xmm0
call   1030 <sin@plt>
ucomisd 0xea7(%rip),%xmm0
mov    0x2e78(%rip),%rax
movsd  (%rax),%xmm0
jae    117d <ang_equiv2+0x3d>
xorps  0xe83(%rip),%xmm0
pop    %rax
ret
movsd  (%rsp),%xmm0
call   1050 <tan@plt>
mov    %eax,%edi
pop    %rax
jmp    1040 <atan@plt>

LLVM IR (-O0):
@M_PI_2 = global double 0.000000e+00
define double @ang_equiv2(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = call double @cos(double %4)
%6 = fcmp oeq double %5, 0.000000e+00
br i1 %6, label %7, label %16
7: ; preds = %1
%8 = load double, double* %3
%9 = call double @sin(double %8)
%10 = fcmp oge double %9, 0.000000e+00
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = load double, double* @M_PI_2
store double %12, double* %2
br label %20
13: ; preds = %7
%14 = load double, double* @M_PI_2
%15 = fneg double %14
store double %15, double* %2
br label %20
16: ; preds = %1
%17 = load double, double* %3
%18 = call i32 @tan(double %17)
%19 = call double @atan(i32 %18)
store double %19, double* %2
br label %20
20: ; preds = %16, %13, %11
%21 = load double, double* %2
ret double %21
}

LLVM IR (-O2):
@M_PI_2 = global double 0.000000e+00
define double @ang_equiv2(double %0) {
%2 = tail call double @cos(double %0)
%3 = fcmp oeq double %2, 0.000000e+00
br i1 %3, label %4, label %10
4: ; preds = %1
%5 = tail call double @sin(double %0)
%6 = fcmp ult double %5, 0.000000e+00
%7 = load double, double* @M_PI_2
br i1 %6, label %8, label %13
8: ; preds = %4
%9 = fneg double %7
br label %13
10: ; preds = %1
%11 = tail call i32 @tan(double %0)
%12 = tail call double @atan(i32 %11)
br label %13
13: ; preds = %4, %10, %8
%14 = phi double [ %9, %8 ], [ %12, %10 ], [ %7, %4 ]
ret double %14
}