#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 DBL_EPSILON;
int fabs(double);
double log(int);
double _pypy_math_log1p(double x) {
  double y;
  if (fabs(x) < DBL_EPSILON / 2.) {
    return x;
  } else if (-0.5 <= x && x <= 1.) {
    y = 1. + x;
    return log(y) - ((y - 1.) - x) / y;
  } else {
    return log(1. + x);
  }
}


x86 assembly (clang, -O0):
<_pypy_math_log1p>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm1
mov    0x2ea6(%rip),%rax
cvtsi2sdl (%rax),%xmm0
movsd  0xeb2(%rip),%xmm2
divsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    116b <_pypy_math_log1p+0x4b>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11f5 <_pypy_math_log1p+0xd5>
movsd  -0x10(%rbp),%xmm0
movsd  0xe90(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11da <_pypy_math_log1p+0xba>
movsd  0xe86(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     11da <_pypy_math_log1p+0xba>
movsd  0xe73(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
cvttsd2si -0x18(%rbp),%edi
call   1040 <log@plt>
movsd  -0x18(%rbp),%xmm1
movsd  0xe52(%rip),%xmm2
subsd  %xmm2,%xmm1
subsd  -0x10(%rbp),%xmm1
divsd  -0x18(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11f5 <_pypy_math_log1p+0xd5>
movsd  0xe2e(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <log@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_pypy_math_log1p>:
sub    $0x18,%rsp
movsd  %xmm0,0x8(%rsp)
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    0x2eab(%rip),%rax
cvtsi2sdl (%rax),%xmm1
mulsd  0xeb7(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    115a <_pypy_math_log1p+0x3a>
movsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
ret
movsd  0xea6(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
cvttsd2si %xmm0,%edi
call   1040 <log@plt>
movsd  0x8(%rsp),%xmm1
ucomisd 0xe8b(%rip),%xmm1
jb     11b7 <_pypy_math_log1p+0x97>
movsd  0xe79(%rip),%xmm1
ucomisd 0x8(%rsp),%xmm1
jb     11b7 <_pypy_math_log1p+0x97>
movsd  0xe79(%rip),%xmm1
movsd  0x10(%rsp),%xmm2
addsd  %xmm2,%xmm1
subsd  0x8(%rsp),%xmm1
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
add    $0x18,%rsp
ret

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

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