#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 acos(double);
double log(int);
double li2(double x) {
  double pi, sum = 0.0, term, top, z;
  int k;
  pi = acos(0.0) * 2.0;
  if (x <= 0.0)
    return pi * pi / 6.0;
  if (x >= 1.0)
    return 0;
  if (x < 0.5) {
    return (-log(x) * log(1 - x) + (pi * pi / 6.0) - li2(1.0 - x));
  }
  z = 1 - x;
  top = 1.0;
  for (k = 1; k <= 100; k++) {
    top *= z;
    term = top / (double)(k * k);
    sum += term;
    if (term <= 1.0e-20)
      break;
  }
  return sum;
}


x86 assembly (clang, -O0):
<li2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
call   1030 <acos@plt>
movsd  0xeab(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     118c <li2+0x5c>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xea2(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12ee <li2+0x1be>
movsd  -0x10(%rbp),%xmm0
movsd  0xe6f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11b0 <li2+0x80>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12ee <li2+0x1be>
movsd  0xe58(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1252 <li2+0x122>
cvttsd2si -0x10(%rbp),%edi
call   1050 <log@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe17(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <log@plt>
movaps %xmm0,%xmm2
movsd  -0x50(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
movsd  0xe07(%rip),%xmm3
divsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xdd6(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
call   1040 <li2@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12ee <li2+0x1be>
movsd  0xdae(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xd9c(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x1,-0x3c(%rbp)
cmpl   $0x64,-0x3c(%rbp)
jg     12e4 <li2+0x1b4>
movsd  -0x38(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x3c(%rbp),%eax
imul   -0x3c(%rbp),%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xd57(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jb     12d1 <li2+0x1a1>
jmp    12e4 <li2+0x1b4>
jmp    12d6 <li2+0x1a6>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1278 <li2+0x148>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<li2>:
sub    $0x18,%rsp
xorpd  %xmm5,%xmm5
ucomisd %xmm0,%xmm5
jae    11a7 <li2+0x87>
ucomisd 0xed2(%rip),%xmm0
jae    11af <li2+0x8f>
movsd  0xed0(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    11b8 <li2+0x98>
cvttsd2si %xmm0,%edi
movsd  %xmm0,0x10(%rsp)
call   1040 <log@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xea5(%rip),%xmm0
subsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
cvttsd2si %xmm0,%edi
call   1040 <log@plt>
mulsd  0x8(%rsp),%xmm0
movsd  0xe7a(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <li2@plt>
movsd  0x8(%rsp),%xmm5
subsd  %xmm0,%xmm5
jmp    11af <li2+0x8f>
movsd  0xe51(%rip),%xmm5
movapd %xmm5,%xmm0
add    $0x18,%rsp
ret
movsd  0xe48(%rip),%xmm6
movapd %xmm6,%xmm1
subsd  %xmm0,%xmm1
xorpd  %xmm5,%xmm5
mov    $0x1,%eax
movsd  0xe3f(%rip),%xmm2
nopl   0x0(%rax)
mulsd  %xmm1,%xmm6
mov    %eax,%ecx
imul   %eax,%ecx
xorps  %xmm3,%xmm3
cvtsi2sd %ecx,%xmm3
movapd %xmm6,%xmm4
divsd  %xmm3,%xmm4
addsd  %xmm4,%xmm5
ucomisd %xmm4,%xmm2
jae    11af <li2+0x8f>
lea    0x1(%rax),%ecx
cmp    $0x64,%eax
mov    %ecx,%eax
jne    11e0 <li2+0xc0>
jmp    11af <li2+0x8f>

LLVM IR (-O0):
define double @li2(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32
store double %0, double* %3
store double 0.000000e+00, double* %5
%10 = call double @acos(double 0.000000e+00)
%11 = fmul double %10, 2.000000e+00
store double %11, double* %4
%12 = load double, double* %3
%13 = fcmp ole double %12, 0.000000e+00
br i1 %13, label %14, label %19
14: ; preds = %1
%15 = load double, double* %4
%16 = load double, double* %4
%17 = fmul double %15, %16
%18 = fdiv double %17, 6.000000e+00
store double %18, double* %2
br label %72
19: ; preds = %1
%20 = load double, double* %3
%21 = fcmp oge double %20, 1.000000e+00
br i1 %21, label %22, label %23
22: ; preds = %19
store double 0.000000e+00, double* %2
br label %72
23: ; preds = %19
%24 = load double, double* %3
%25 = fcmp olt double %24, 5.000000e-01
br i1 %25, label %26, label %44
26: ; preds = %23
%27 = load double, double* %3
%28 = fptosi double %27 to i32
%29 = call double @log(i32 %28)
%30 = fneg double %29
%31 = load double, double* %3
%32 = fsub double 1.000000e+00, %31
%33 = fptosi double %32 to i32
%34 = call double @log(i32 %33)
%35 = load double, double* %4
%36 = load double, double* %4
%37 = fmul double %35, %36
%38 = fdiv double %37, 6.000000e+00
%39 = call double @llvm.fmuladd.f64(double %30, double %34, double %38)
%40 = load double, double* %3
%41 = fsub double 1.000000e+00, %40
%42 = call double @li2(double %41)
%43 = fsub double %39, %42
store double %43, double* %2
br label %72
44: ; preds = %23
%45 = load double, double* %3
%46 = fsub double 1.000000e+00, %45
store double %46, double* %8
store double 1.000000e+00, double* %7
store i32 1, i32* %9
br label %47
47: ; preds = %67, %44
%48 = load i32, i32* %9
%49 = icmp sle i32 %48, 100
br i1 %49, label %50, label %70
50: ; preds = %47
%51 = load double, double* %8
%52 = load double, double* %7
%53 = fmul double %52, %51
store double %53, double* %7
%54 = load double, double* %7
%55 = load i32, i32* %9
%56 = load i32, i32* %9
%57 = mul nsw i32 %55, %56
%58 = sitofp i32 %57 to double
%59 = fdiv double %54, %58
store double %59, double* %6
%60 = load double, double* %6
%61 = load double, double* %5
%62 = fadd double %61, %60
store double %62, double* %5
%63 = load double, double* %6
%64 = fcmp ole double %63, 0x3BC79CA10C924223
br i1 %64, label %65, label %66
65: ; preds = %50
br label %70
66: ; preds = %50
br label %67
67: ; preds = %66
%68 = load i32, i32* %9
%69 = add nsw i32 %68, 1
store i32 %69, i32* %9
br label %47
70: ; preds = %65, %47
%71 = load double, double* %5
store double %71, double* %2
br label %72
72: ; preds = %70, %26, %22, %14
%73 = load double, double* %2
ret double %73
}

LLVM IR (-O2):
define double @li2(double %0) {
%2 = fcmp ugt double %0, 0.000000e+00
br i1 %2, label %3, label %7
3: ; preds = %1
%4 = fcmp ult double %0, 1.000000e+00
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = fcmp olt double %0, 5.000000e-01
br i1 %6, label %9, label %19
7: ; preds = %21, %1, %3, %9
%8 = phi double [ %18, %9 ], [ 0x3FFA51A6625307D3, %1 ], [ 0.000000e+00, %3 ], [ %29, %21 ]
ret double %8
9: ; preds = %5
%10 = fptosi double %0 to i32
%11 = tail call double @log(i32 %10)
%12 = fneg double %11
%13 = fsub double 1.000000e+00, %0
%14 = fptosi double %13 to i32
%15 = tail call double @log(i32 %14)
%16 = tail call double @llvm.fmuladd.f64(double %12, double %15, double 0x3FFA51A6625307D3)
%17 = tail call double @li2(double %13)
%18 = fsub double %16, %17
br label %7
19: ; preds = %5
%20 = fsub double 1.000000e+00, %0
br label %21
21: ; preds = %21, %19
%22 = phi i32 [ 1, %19 ], [ %31, %21 ]
%23 = phi double [ 1.000000e+00, %19 ], [ %25, %21 ]
%24 = phi double [ 0.000000e+00, %19 ], [ %29, %21 ]
%25 = fmul double %20, %23
%26 = mul nuw nsw i32 %22, %22
%27 = sitofp i32 %26 to double
%28 = fdiv double %25, %27
%29 = fadd double %24, %28
%30 = fcmp ole double %28, 0x3BC79CA10C924223
%31 = add nuw nsw i32 %22, 1
%32 = icmp eq i32 %31, 101
%33 = select i1 %30, i1 true, i1 %32
br i1 %33, label %7, label %21
}