#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);
double log(int);
double sqrt(double);
double at1(double z) {
  if (z < 0) {
    double sqrtz = sqrt(-z);
    return 0.5 * log((1 + sqrtz) / (1 - sqrtz)) / sqrtz;
  } else if (z > 0) {
    double sqrtz = sqrt(z);
    return atan(sqrtz) / sqrt(z);
  } else {
    return 1.0;
  }
}


x86 assembly (clang, -O0):
<at1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11b6 <at1+0x86>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  0xe87(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  0xe7a(%rip),%xmm1
subsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  0xe65(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1213 <at1+0xe3>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1206 <at1+0xd6>
movsd  -0x10(%rbp),%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <atan@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1213 <at1+0xe3>
movsd  0xdf2(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<at1>:
sub    $0x18,%rsp
movapd %xmm0,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm0
jbe    1162 <at1+0x32>
movapd 0xed6(%rip),%xmm0
xorpd  %xmm2,%xmm0
movsd  0xeb2(%rip),%xmm1
ucomisd %xmm2,%xmm1
jb     11c9 <at1+0x99>
sqrtsd %xmm0,%xmm0
jmp    11ce <at1+0x9e>
ucomisd %xmm0,%xmm2
jbe    1207 <at1+0xd7>
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
xorpd  %xmm1,%xmm1
movapd %xmm2,(%rsp)
ucomisd %xmm1,%xmm2
movsd  %xmm0,0x10(%rsp)
jae    1192 <at1+0x62>
movapd (%rsp),%xmm0
call   1050 <sqrt@plt>
call   1030 <atan@plt>
movapd %xmm0,%xmm2
movapd (%rsp),%xmm0
ucomisd 0xe70(%rip),%xmm0
movsd  0x10(%rsp),%xmm1
jae    11c3 <at1+0x93>
movsd  %xmm2,(%rsp)
call   1050 <sqrt@plt>
movsd  (%rsp),%xmm2
movapd %xmm0,%xmm1
divsd  %xmm1,%xmm2
jmp    120f <at1+0xdf>
call   1050 <sqrt@plt>
movsd  0xe2a(%rip),%xmm2
movsd  %xmm0,(%rsp)
movapd %xmm0,%xmm1
addsd  %xmm2,%xmm1
subsd  %xmm0,%xmm2
divsd  %xmm2,%xmm1
cvttsd2si %xmm1,%edi
call   1040 <log@plt>
movapd %xmm0,%xmm2
mulsd  0xe10(%rip),%xmm2
divsd  (%rsp),%xmm2
jmp    120f <at1+0xdf>
movsd  0xdf1(%rip),%xmm2
movapd %xmm2,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @at1(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %3
%6 = load double, double* %3
%7 = fcmp olt double %6, 0.000000e+00
br i1 %7, label %8, label %22
8: ; preds = %1
%9 = load double, double* %3
%10 = fneg double %9
%11 = call double @sqrt(double %10)
store double %11, double* %4
%12 = load double, double* %4
%13 = fadd double 1.000000e+00, %12
%14 = load double, double* %4
%15 = fsub double 1.000000e+00, %14
%16 = fdiv double %13, %15
%17 = fptosi double %16 to i32
%18 = call double @log(i32 %17)
%19 = fmul double 5.000000e-01, %18
%20 = load double, double* %4
%21 = fdiv double %19, %20
store double %21, double* %2
br label %34
22: ; preds = %1
%23 = load double, double* %3
%24 = fcmp ogt double %23, 0.000000e+00
br i1 %24, label %25, label %33
25: ; preds = %22
%26 = load double, double* %3
%27 = call double @sqrt(double %26)
store double %27, double* %5
%28 = load double, double* %5
%29 = call double @atan(double %28)
%30 = load double, double* %3
%31 = call double @sqrt(double %30)
%32 = fdiv double %29, %31
store double %32, double* %2
br label %34
33: ; preds = %22
store double 1.000000e+00, double* %2
br label %34
34: ; preds = %33, %25, %8
%35 = load double, double* %2
ret double %35
}

LLVM IR (-O2):
define double @at1(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
br i1 %2, label %3, label %13
3: ; preds = %1
%4 = fneg double %0
%5 = tail call double @sqrt(double %4)
%6 = fadd double %5, 1.000000e+00
%7 = fsub double 1.000000e+00, %5
%8 = fdiv double %6, %7
%9 = fptosi double %8 to i32
%10 = tail call double @log(i32 %9)
%11 = fmul double %10, 5.000000e-01
%12 = fdiv double %11, %5
br label %20
13: ; preds = %1
%14 = fcmp ogt double %0, 0.000000e+00
br i1 %14, label %15, label %20
15: ; preds = %13
%16 = tail call double @sqrt(double %0)
%17 = tail call double @atan(double %16)
%18 = tail call double @sqrt(double %0)
%19 = fdiv double %17, %18
br label %20
20: ; preds = %13, %15, %3
%21 = phi double [ %12, %3 ], [ %19, %15 ], [ 1.000000e+00, %13 ]
ret double %21
}