#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 */
int log(double);
double pow(double, double);
double eps(double x) {
  double y, t, epsv;
  int t2;
  epsv = pow(2.0, -52.0);
  if (x < 0.) {
    x = -x;
  }
  if (x > 0. && x < 1.0) {
    x /= 2.;
  }
  t2 = (int)(log(x) / log((double)2.0));
  t = pow(2.0, (double)t2);
  y = epsv * t;
  return y;
}


x86 assembly (clang, -O0):
<eps>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xecb(%rip),%xmm0
movsd  0xecb(%rip),%xmm1
call   1040 <pow@plt>
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1176 <eps+0x56>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11b1 <eps+0x91>
movsd  0xe80(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    11b1 <eps+0x91>
movsd  -0x8(%rbp),%xmm0
movsd  0xe58(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <log@plt>
mov    %eax,-0x28(%rbp)
movsd  0xe3a(%rip),%xmm0
call   1030 <log@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm1
movsd  0xe1d(%rip),%xmm0
call   1040 <pow@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eps>:
push   %rbx
movapd %xmm0,%xmm1
movapd 0xed3(%rip),%xmm2
xorpd  %xmm0,%xmm2
xorpd  %xmm0,%xmm0
movapd %xmm1,%xmm3
cmpltsd %xmm0,%xmm3
andpd  %xmm3,%xmm2
andnpd %xmm1,%xmm3
orpd   %xmm2,%xmm3
movsd  0xebe(%rip),%xmm1
mulsd  %xmm3,%xmm1
cmpltsd %xmm3,%xmm0
movapd %xmm3,%xmm2
cmpltsd 0xeb0(%rip),%xmm2
andpd  %xmm2,%xmm1
andnpd %xmm3,%xmm2
orpd   %xmm1,%xmm2
andpd  %xmm0,%xmm2
andnpd %xmm3,%xmm0
orpd   %xmm2,%xmm0
call   1040 <log@plt>
mov    %eax,%ebx
movsd  0xe91(%rip),%xmm0
call   1040 <log@plt>
mov    %eax,%ecx
mov    %ebx,%eax
cltd
idiv   %ecx
movsd  0xe75(%rip),%xmm0
mov    %eax,%edi
call   1030 <ldexp@plt>
mulsd  0xe76(%rip),%xmm0
pop    %rbx
ret

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

LLVM IR (-O2):
define double @eps(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, 0.000000e+00
%6 = fcmp olt double %4, 1.000000e+00
%7 = and i1 %5, %6
%8 = fmul double %4, 5.000000e-01
%9 = select i1 %7, double %8, double %4
%10 = tail call i32 @log(double %9)
%11 = tail call i32 @log(double 2.000000e+00)
%12 = sdiv i32 %10, %11
%13 = tail call double @ldexp(double 1.000000e+00, i32 %12)
%14 = fmul double %13, 0x3CB0000000000000
ret double %14
}