#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 _atan(double, int);
double atan(double x) {
  double a;
  a = x < 0.0 ? -x : x;
  if (a > 1.0)
    a = _atan(1.0 / a, 2);
  else
    a = _atan(a, 0);
  return (x < 0.0 ? -a : a);
}


x86 assembly (clang, -O0):
<atan>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1151 <atan+0x41>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    115b <atan+0x4b>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe8e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    119d <atan+0x8d>
movsd  0xe7c(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
mov    $0x2,%edi
call   1030 <_atan@plt>
movsd  %xmm0,-0x10(%rbp)
jmp    11ae <atan+0x9e>
movsd  -0x10(%rbp),%xmm0
xor    %edi,%edi
call   1030 <_atan@plt>
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    11e2 <atan+0xd2>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11ec <atan+0xdc>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<atan>:
sub    $0x18,%rsp
movapd %xmm0,%xmm3
movapd 0xee0(%rip),%xmm1
xorpd  %xmm0,%xmm1
xorpd  %xmm2,%xmm2
cmpltsd %xmm2,%xmm0
andpd  %xmm0,%xmm1
movapd %xmm3,(%rsp)
andnpd %xmm3,%xmm0
orpd   %xmm1,%xmm0
ucomisd 0xeca(%rip),%xmm0
jbe    115f <atan+0x4f>
movsd  0xec0(%rip),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
mov    $0x2,%edi
jmp    1161 <atan+0x51>
xor    %edi,%edi
call   1030 <_atan@plt>
movapd 0xe92(%rip),%xmm1
xorpd  %xmm0,%xmm1
xorpd  %xmm2,%xmm2
movapd (%rsp),%xmm3
cmpltsd %xmm2,%xmm3
andpd  %xmm3,%xmm1
andnpd %xmm0,%xmm3
orpd   %xmm1,%xmm3
movapd %xmm3,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @atan(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %2
%4 = load double, double* %2
%5 = fcmp olt double %4, 0.000000e+00
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load double, double* %2
%8 = fneg double %7
br label %11
9: ; preds = %1
%10 = load double, double* %2
br label %11
11: ; preds = %9, %6
%12 = phi double [ %8, %6 ], [ %10, %9 ]
store double %12, double* %3
%13 = load double, double* %3
%14 = fcmp ogt double %13, 1.000000e+00
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load double, double* %3
%17 = fdiv double 1.000000e+00, %16
%18 = call double @_atan(double %17, i32 2)
store double %18, double* %3
br label %22
19: ; preds = %11
%20 = load double, double* %3
%21 = call double @_atan(double %20, i32 0)
store double %21, double* %3
br label %22
22: ; preds = %19, %15
%23 = load double, double* %2
%24 = fcmp olt double %23, 0.000000e+00
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load double, double* %3
%27 = fneg double %26
br label %30
28: ; preds = %22
%29 = load double, double* %3
br label %30
30: ; preds = %28, %25
%31 = phi double [ %27, %25 ], [ %29, %28 ]
ret double %31
}

LLVM IR (-O2):
define double @atan(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
%3 = fneg double %0
%4 = select i1 %2, double %3, double %0
%5 = fcmp ogt double %4, 1.000000e+00
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = fdiv double 1.000000e+00, %4
%8 = tail call double @_atan(double %7, i32 2)
br label %11
9: ; preds = %1
%10 = tail call double @_atan(double %4, i32 0)
br label %11
11: ; preds = %9, %6
%12 = phi double [ %8, %6 ], [ %10, %9 ]
%13 = fneg double %12
%14 = select i1 %2, double %13, double %12
ret double %14
}