#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 dilog_series(int);
double log(double);
double dilog(double x) {
  do {
  } while (0);
  if (x <= -2.0)
    return -dilog_series(1. / x) - 1.644934066848226436 -
           0.5 * log(-1. / x) * log(-1. / x);
  else {
    double log1x = log(1. - x);
    return dilog_series(1. / (1. - x)) - 1.644934066848226436 +
           log1x * (0.5 * log1x - log(-x));
  }
}


x86 assembly (clang, -O0):
<dilog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
jmp    1132 <dilog+0x12>
movsd  0xec6(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     11f1 <dilog+0xd1>
movsd  0xecb(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <dilog_series@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe96(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe95(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  0xe68(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe6f(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
call   1040 <log@plt>
movsd  -0x28(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12b6 <dilog+0x196>
movsd  0xe1f(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
call   1040 <log@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  0xe08(%rip),%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  0xdfb(%rip),%xmm0
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <dilog_series@plt>
movsd  0xdde(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1040 <log@plt>
movsd  -0x40(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
movaps %xmm0,%xmm3
movsd  -0x30(%rbp),%xmm0
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
movsd  0xd67(%rip),%xmm4
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dilog>:
sub    $0x28,%rsp
movapd %xmm0,%xmm1
movsd  0xed0(%rip),%xmm0
ucomisd %xmm1,%xmm0
movapd %xmm1,0x10(%rsp)
movsd  0xec6(%rip),%xmm0
jae    11b6 <dilog+0x96>
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
call   1040 <log@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xea8(%rip),%xmm0
divsd  (%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <dilog_series@plt>
addsd  0xe9a(%rip),%xmm0
movsd  %xmm0,(%rsp)
movapd 0x10(%rsp),%xmm0
xorpd  0xea7(%rip),%xmm0
call   1040 <log@plt>
movsd  0xe92(%rip),%xmm1
movsd  0x8(%rsp),%xmm2
mulsd  %xmm2,%xmm1
subsd  %xmm0,%xmm1
mulsd  %xmm2,%xmm1
addsd  (%rsp),%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
ret
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <dilog_series@plt>
movsd  0xe45(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0xe3b(%rip),%xmm0
divsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%rsp)
call   1040 <log@plt>
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
call   1040 <log@plt>
movsd  0x10(%rsp),%xmm1
mulsd  0xe15(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @dilog(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
store double %0, double* %3
br label %5
5: ; preds = %1
br label %6
6: ; preds = %5
%7 = load double, double* %3
%8 = fcmp ole double %7, -2.000000e+00
br i1 %8, label %9, label %25
9: ; preds = %6
%10 = load double, double* %3
%11 = fdiv double 1.000000e+00, %10
%12 = fptosi double %11 to i32
%13 = call double @dilog_series(i32 %12)
%14 = fneg double %13
%15 = fsub double %14, 0x3FFA51A6625307D3
%16 = load double, double* %3
%17 = fdiv double -1.000000e+00, %16
%18 = call double @log(double %17)
%19 = fmul double 5.000000e-01, %18
%20 = load double, double* %3
%21 = fdiv double -1.000000e+00, %20
%22 = call double @log(double %21)
%23 = fneg double %19
%24 = call double @llvm.fmuladd.f64(double %23, double %22, double %15)
store double %24, double* %2
br label %43
25: ; preds = %6
%26 = load double, double* %3
%27 = fsub double 1.000000e+00, %26
%28 = call double @log(double %27)
store double %28, double* %4
%29 = load double, double* %3
%30 = fsub double 1.000000e+00, %29
%31 = fdiv double 1.000000e+00, %30
%32 = fptosi double %31 to i32
%33 = call double @dilog_series(i32 %32)
%34 = fsub double %33, 0x3FFA51A6625307D3
%35 = load double, double* %4
%36 = load double, double* %4
%37 = load double, double* %3
%38 = fneg double %37
%39 = call double @log(double %38)
%40 = fneg double %39
%41 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %36, double %40)
%42 = call double @llvm.fmuladd.f64(double %35, double %41, double %34)
store double %42, double* %2
br label %43
43: ; preds = %25, %9
%44 = load double, double* %2
ret double %44
}

LLVM IR (-O2):
define double @dilog(double %0) {
%2 = fcmp ugt double %0, -2.000000e+00
br i1 %2, label %13, label %3
3: ; preds = %1
%4 = fdiv double 1.000000e+00, %0
%5 = fptosi double %4 to i32
%6 = tail call double @dilog_series(i32 %5)
%7 = fsub double 0xBFFA51A6625307D3, %6
%8 = fdiv double -1.000000e+00, %0
%9 = tail call double @log(double %8)
%10 = tail call double @log(double %8)
%11 = fmul double %9, -5.000000e-01
%12 = tail call double @llvm.fmuladd.f64(double %11, double %10, double %7)
br label %25
13: ; preds = %1
%14 = fsub double 1.000000e+00, %0
%15 = tail call double @log(double %14)
%16 = fdiv double 1.000000e+00, %14
%17 = fptosi double %16 to i32
%18 = tail call double @dilog_series(i32 %17)
%19 = fadd double %18, 0xBFFA51A6625307D3
%20 = fneg double %0
%21 = tail call double @log(double %20)
%22 = fneg double %21
%23 = tail call double @llvm.fmuladd.f64(double %15, double 5.000000e-01, double %22)
%24 = tail call double @llvm.fmuladd.f64(double %15, double %23, double %19)
br label %25
25: ; preds = %13, %3
%26 = phi double [ %12, %3 ], [ %24, %13 ]
ret double %26
}