#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 ADf(double, int);
double ADinf(double z) {
  int j;
  double ad, adnew, r;
  if (z < .01)
    return 0.;
  r = 1. / z;
  ad = r * ADf(z, 0);
  for (j = 1; j < 100; j++) {
    r *= (.5 - j) / j;
    adnew = ad + (4 * j + 1) * r * ADf(z, j);
    if (ad == adnew) {
      return ad;
    }
    ad = adnew;
  }
  return ad;
}


x86 assembly (clang, -O0):
<ADinf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  0xedb(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    113d <ADinf+0x2d>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    123c <ADinf+0x12c>
movsd  0xec3(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
xor    %edi,%edi
call   1030 <ADf@plt>
movsd  -0x38(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jge    1232 <ADinf+0x122>
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  0xe7b(%rip),%xmm0
subsd  %xmm1,%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x2,%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%edi
call   1030 <ADf@plt>
movsd  -0x48(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
cvtsi2sd %eax,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jne    121a <ADinf+0x10a>
jp     121a <ADinf+0x10a>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    123c <ADinf+0x12c>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117e <ADinf+0x6e>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ADinf>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
xorpd  %xmm2,%xmm2
movsd  0xede(%rip),%xmm1
movsd  %xmm0,0x10(%rsp)
ucomisd %xmm0,%xmm1
ja     11ec <ADinf+0xdc>
movsd  0xece(%rip),%xmm1
movsd  0x10(%rsp),%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
xor    %edi,%edi
call   1030 <ADf@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
mov    $0x1,%ebx
mov    $0x5,%ebp
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
movsd  0xe85(%rip),%xmm2
subsd  %xmm1,%xmm2
divsd  %xmm1,%xmm2
mulsd  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
movsd  %xmm2,0x8(%rsp)
mulsd  %xmm2,%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x10(%rsp),%xmm0
mov    %ebx,%edi
call   1030 <ADf@plt>
movsd  0x20(%rsp),%xmm2
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x18(%rsp),%xmm0
addsd  %xmm2,%xmm0
ucomisd %xmm0,%xmm2
jne    11da <ADinf+0xca>
jnp    11ec <ADinf+0xdc>
add    $0x1,%ebx
add    $0x4,%ebp
movapd %xmm0,%xmm2
cmp    $0x191,%ebp
jne    1170 <ADinf+0x60>
movapd %xmm2,%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define double @ADinf(double %0) {
%2 = fcmp olt double %0, 1.000000e-02
br i1 %2, label %27, label %3
3: ; preds = %1
%4 = fdiv double 1.000000e+00, %0
%5 = tail call i32 @ADf(double %0, i32 0)
%6 = sitofp i32 %5 to double
%7 = fmul double %4, %6
br label %11
8: ; preds = %11
%9 = add nuw nsw i32 %14, 1
%10 = icmp eq i32 %9, 100
br i1 %10, label %27, label %11
11: ; preds = %3, %8
%12 = phi double [ %4, %3 ], [ %18, %8 ]
%13 = phi double [ %7, %3 ], [ %25, %8 ]
%14 = phi i32 [ 1, %3 ], [ %9, %8 ]
%15 = sitofp i32 %14 to double
%16 = fsub double 5.000000e-01, %15
%17 = fdiv double %16, %15
%18 = fmul double %12, %17
%19 = shl nuw nsw i32 %14, 2
%20 = or i32 %19, 1
%21 = sitofp i32 %20 to double
%22 = fmul double %18, %21
%23 = tail call i32 @ADf(double %0, i32 %14)
%24 = sitofp i32 %23 to double
%25 = tail call double @llvm.fmuladd.f64(double %22, double %24, double %13)
%26 = fcmp oeq double %13, %25
br i1 %26, label %27, label %8
27: ; preds = %8, %11, %1
%28 = phi double [ 0.000000e+00, %1 ], [ %13, %11 ], [ %25, %8 ]
ret double %28
}