#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 horner(double);
double sqrt(double);
double ln(double x) {
  if (x > 1.5) {
    int i = 0;
    for (; x > 1.25; i++)
      x = sqrt(x);
    return (1 << i) * horner(x - 1);
  } else if (x < 0.7 && x > 0) {
    int i = 0;
    for (; x < 0.7; i++)
      x = sqrt(x);
    return (1 << i) * horner(x - 1);
  } else
    return horner(x - 1);
}


x86 assembly (clang, -O0):
<ln>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xec6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11be <ln+0x9e>
movl   $0x0,-0x14(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xec0(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    117f <ln+0x5f>
movsd  -0x10(%rbp),%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114b <ln+0x2b>
mov    -0x14(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe71(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1040 <horner@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1274 <ln+0x154>
movsd  0xe42(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1259 <ln+0x139>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1259 <ln+0x139>
movl   $0x0,-0x18(%rbp)
movsd  0xe16(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    121a <ln+0xfa>
movsd  -0x10(%rbp),%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11ea <ln+0xca>
mov    -0x18(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xdd6(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1040 <horner@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1274 <ln+0x154>
movsd  -0x10(%rbp),%xmm0
movsd  0xdaa(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1040 <horner@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ln>:
push   %rbx
sub    $0x10,%rsp
ucomisd 0xed3(%rip),%xmm0
jbe    1176 <ln+0x56>
xor    %ebx,%ebx
ucomisd 0xedf(%rip),%xmm0
jbe    11c6 <ln+0xa6>
xor    %ebx,%ebx
xorpd  %xmm1,%xmm1
movsd  0xecb(%rip),%xmm2
jmp    116a <ln+0x4a>
nop
call   1030 <sqrt@plt>
movsd  0xebb(%rip),%xmm2
xorpd  %xmm1,%xmm1
add    $0x1,%ebx
ucomisd %xmm2,%xmm0
jbe    11c6 <ln+0xa6>
ucomisd %xmm1,%xmm0
jb     1150 <ln+0x30>
sqrtsd %xmm0,%xmm0
jmp    1161 <ln+0x41>
movsd  0xe8a(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    11e6 <ln+0xc6>
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jbe    11e6 <ln+0xc6>
mov    $0xffffffff,%ebx
jmp    11ba <ln+0x9a>
cs nopw 0x0(%rax,%rax,1)
nop
call   1030 <sqrt@plt>
xorpd  %xmm2,%xmm2
movsd  0xe57(%rip),%xmm1
add    $0x1,%ebx
ucomisd %xmm0,%xmm1
jbe    11f8 <ln+0xd8>
ucomisd %xmm2,%xmm0
jb     11a0 <ln+0x80>
sqrtsd %xmm0,%xmm0
jmp    11b1 <ln+0x91>
mov    $0x1,%eax
mov    %ebx,%ecx
shl    %cl,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  %xmm1,0x8(%rsp)
addsd  0xe2c(%rip),%xmm0
jmp    1216 <ln+0xf6>
addsd  0xe22(%rip),%xmm0
add    $0x10,%rsp
pop    %rbx
jmp    1040 <horner@plt>
mov    $0x2,%eax
mov    %ebx,%ecx
shl    %cl,%eax
addsd  0xe07(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  %xmm1,0x8(%rsp)
call   1040 <horner@plt>
mulsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @ln(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
store double %0, double* %3
%6 = load double, double* %3
%7 = fcmp ogt double %6, 1.500000e+00
br i1 %7, label %8, label %26
8: ; preds = %1
store i32 0, i32* %4
br label %9
9: ; preds = %15, %8
%10 = load double, double* %3
%11 = fcmp ogt double %10, 1.250000e+00
br i1 %11, label %12, label %18
12: ; preds = %9
%13 = load double, double* %3
%14 = call double @sqrt(double %13)
store double %14, double* %3
br label %15
15: ; preds = %12
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 1
store i32 %17, i32* %4
br label %9
18: ; preds = %9
%19 = load i32, i32* %4
%20 = shl i32 1, %19
%21 = sitofp i32 %20 to double
%22 = load double, double* %3
%23 = fsub double %22, 1.000000e+00
%24 = call double @horner(double %23)
%25 = fmul double %21, %24
store double %25, double* %2
br label %54
26: ; preds = %1
%27 = load double, double* %3
%28 = fcmp olt double %27, 0x3FE6666666666666
br i1 %28, label %29, label %50
29: ; preds = %26
%30 = load double, double* %3
%31 = fcmp ogt double %30, 0.000000e+00
br i1 %31, label %32, label %50
32: ; preds = %29
store i32 0, i32* %5
br label %33
33: ; preds = %39, %32
%34 = load double, double* %3
%35 = fcmp olt double %34, 0x3FE6666666666666
br i1 %35, label %36, label %42
36: ; preds = %33
%37 = load double, double* %3
%38 = call double @sqrt(double %37)
store double %38, double* %3
br label %39
39: ; preds = %36
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
br label %33
42: ; preds = %33
%43 = load i32, i32* %5
%44 = shl i32 1, %43
%45 = sitofp i32 %44 to double
%46 = load double, double* %3
%47 = fsub double %46, 1.000000e+00
%48 = call double @horner(double %47)
%49 = fmul double %45, %48
store double %49, double* %2
br label %54
50: ; preds = %29, %26
%51 = load double, double* %3
%52 = fsub double %51, 1.000000e+00
%53 = call double @horner(double %52)
store double %53, double* %2
br label %54
54: ; preds = %50, %42, %18
%55 = load double, double* %2
ret double %55
}

LLVM IR (-O2):
define double @ln(double %0) {
%2 = fcmp ogt double %0, 1.500000e+00
br i1 %2, label %3, label %19
3: ; preds = %1
%4 = fcmp ogt double %0, 1.250000e+00
br i1 %4, label %5, label %11
5: ; preds = %3, %5
%6 = phi i32 [ %9, %5 ], [ 0, %3 ]
%7 = phi double [ %8, %5 ], [ %0, %3 ]
%8 = tail call double @sqrt(double %7)
%9 = add nuw nsw i32 %6, 1
%10 = fcmp ogt double %8, 1.250000e+00
br i1 %10, label %5, label %11
11: ; preds = %5, %3
%12 = phi double [ %0, %3 ], [ %8, %5 ]
%13 = phi i32 [ 0, %3 ], [ %9, %5 ]
%14 = shl nuw i32 1, %13
%15 = sitofp i32 %14 to double
%16 = fadd double %12, -1.000000e+00
%17 = tail call double @horner(double %16)
%18 = fmul double %17, %15
br label %38
19: ; preds = %1
%20 = fcmp olt double %0, 0x3FE6666666666666
%21 = fcmp ogt double %0, 0.000000e+00
%22 = and i1 %20, %21
br i1 %22, label %23, label %35
23: ; preds = %19, %23
%24 = phi i32 [ %27, %23 ], [ 0, %19 ]
%25 = phi double [ %26, %23 ], [ %0, %19 ]
%26 = tail call double @sqrt(double %25)
%27 = add nuw nsw i32 %24, 1
%28 = fcmp olt double %26, 0x3FE6666666666666
br i1 %28, label %23, label %29
29: ; preds = %23
%30 = fadd double %26, -1.000000e+00
%31 = shl i32 2, %24
%32 = sitofp i32 %31 to double
%33 = tail call double @horner(double %30)
%34 = fmul double %33, %32
br label %38
35: ; preds = %19
%36 = fadd double %0, -1.000000e+00
%37 = tail call double @horner(double %36)
br label %38
38: ; preds = %35, %29, %11
%39 = phi double [ %18, %11 ], [ %34, %29 ], [ %37, %35 ]
ret double %39
}