#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 cPhi(double);
double exp(double);
double fabs(double);
double sqrt(int);
double ADf(double z, int j) {
  double t, f, fnew, a, b, c, r;
  int i;
  t = (4 * j + 1) * (4 * j + 1) * 1.23370055013617 / z;
  if (t > 150.)
    return 0.;
  a = 2.22144146907918 * exp(-t) / sqrt(t);
  b = 3.93740248643060 * 2. * cPhi(sqrt(2 * t));
  r = z * .125;
  f = a + b * r;
  for (i = 1; i < 200; i++) {
    c = ((i - .5 - t) * b + t * a) / i;
    a = b;
    b = c;
    r *= z / (8 * i + 8);
    if (fabs(r) < 1e-40 || fabs(c) < 1.e-40)
      return f;
    fnew = f + c * r;
    if (f == fnew)
      return f;
    f = fnew;
  }
  return f;
}


x86 assembly (clang, -O0):
<ADf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x2,%eax
add    $0x1,%eax
mov    -0x14(%rbp),%ecx
shl    $0x2,%ecx
add    $0x1,%ecx
imul   %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  0xea7(%rip),%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe84(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1193 <ADf+0x63>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1379 <ADf+0x249>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  0xe69(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
cvttsd2si -0x20(%rbp),%edi
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe35(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
call   1030 <cPhi@plt>
movaps %xmm0,%xmm1
movsd  0xe0f(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xdf6(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x1,-0x54(%rbp)
cmpl   $0xc8,-0x54(%rbp)
jge    136f <ADf+0x23f>
cvtsi2sdl -0x54(%rbp),%xmm0
movsd  0xdd7(%rip),%xmm1
subsd  %xmm1,%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsi2sdl -0x54(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x54(%rbp),%eax
shl    $0x3,%eax
add    $0x8,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm1
movaps 0xd71(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xd55(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     1307 <ADf+0x1d7>
movsd  -0x48(%rbp),%xmm1
movaps 0xd4f(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xd33(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1316 <ADf+0x1e6>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1379 <ADf+0x249>
movsd  -0x28(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jne    1357 <ADf+0x227>
jp     1357 <ADf+0x227>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1379 <ADf+0x249>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1247 <ADf+0x117>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ADf>:
sub    $0x28,%rsp
lea    0x1(,%rdi,4),%eax
imul   %eax,%eax
cvtsi2sd %eax,%xmm1
movapd %xmm0,%xmm2
mulsd  0xeb2(%rip),%xmm1
divsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd 0xeaa(%rip),%xmm1
ja     12b0 <ADf+0x180>
movapd 0xed4(%rip),%xmm0
xorpd  %xmm1,%xmm0
movapd %xmm1,0x10(%rsp)
movsd  %xmm2,0x20(%rsp)
call   1040 <exp@plt>
mulsd  0xe87(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
cvttsd2si 0x10(%rsp),%edi
call   1050 <sqrt@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd 0x10(%rsp),%xmm0
addsd  %xmm0,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
call   1030 <cPhi@plt>
movsd  0x8(%rsp),%xmm6
movsd  0x20(%rsp),%xmm11
movapd 0x10(%rsp),%xmm12
movapd %xmm0,%xmm1
mulsd  0xe36(%rip),%xmm1
movsd  0xe36(%rip),%xmm2
mulsd  %xmm11,%xmm2
movapd %xmm1,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm6,%xmm0
mov    $0x1,%eax
mov    $0x10,%ecx
movsd  0xe1a(%rip),%xmm8
movapd 0xe39(%rip),%xmm9
movsd  0xe10(%rip),%xmm10
movapd %xmm1,%xmm5
movapd %xmm2,%xmm3
xorps  %xmm7,%xmm7
cvtsi2sd %eax,%xmm7
movapd %xmm7,%xmm1
addsd  %xmm8,%xmm1
xorps  %xmm4,%xmm4
cvtsi2sd %ecx,%xmm4
movapd %xmm11,%xmm2
divsd  %xmm4,%xmm2
mulsd  %xmm3,%xmm2
movapd %xmm2,%xmm3
andpd  %xmm9,%xmm3
ucomisd %xmm3,%xmm10
ja     12b0 <ADf+0x180>
subsd  %xmm12,%xmm1
mulsd  %xmm12,%xmm6
mulsd  %xmm5,%xmm1
addsd  %xmm6,%xmm1
divsd  %xmm7,%xmm1
movapd %xmm1,%xmm3
andpd  %xmm9,%xmm3
ucomisd %xmm3,%xmm10
ja     12b0 <ADf+0x180>
movapd %xmm1,%xmm7
mulsd  %xmm2,%xmm7
addsd  %xmm0,%xmm7
ucomisd %xmm7,%xmm0
jne    1296 <ADf+0x166>
jnp    12b0 <ADf+0x180>
add    $0x1,%eax
add    $0x8,%ecx
movapd %xmm5,%xmm6
movapd %xmm7,%xmm0
cmp    $0x648,%ecx
jne    1220 <ADf+0xf0>
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @ADf(double %0, i32 %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca i32
store double %0, double* %4
store i32 %1, i32* %5
%14 = load i32, i32* %5
%15 = mul nsw i32 4, %14
%16 = add nsw i32 %15, 1
%17 = load i32, i32* %5
%18 = mul nsw i32 4, %17
%19 = add nsw i32 %18, 1
%20 = mul nsw i32 %16, %19
%21 = sitofp i32 %20 to double
%22 = fmul double %21, 0x3FF3BD3CC9BE45DF
%23 = load double, double* %4
%24 = fdiv double %22, %23
store double %24, double* %6
%25 = load double, double* %6
%26 = fcmp ogt double %25, 1.500000e+02
br i1 %26, label %27, label %28
27: ; preds = %2
store double 0.000000e+00, double* %3
br label %102
28: ; preds = %2
%29 = load double, double* %6
%30 = fneg double %29
%31 = call double @exp(double %30)
%32 = fmul double 0x4001C5831ADD62DD, %31
%33 = load double, double* %6
%34 = fptosi double %33 to i32
%35 = call double @sqrt(i32 %34)
%36 = fdiv double %32, %35
store double %36, double* %9
%37 = load double, double* %6
%38 = fmul double 2.000000e+00, %37
%39 = fptosi double %38 to i32
%40 = call double @sqrt(i32 %39)
%41 = call double @cPhi(double %40)
%42 = fmul double 0x401F7FCCDFF344A1, %41
store double %42, double* %10
%43 = load double, double* %4
%44 = fmul double %43, 1.250000e-01
store double %44, double* %12
%45 = load double, double* %9
%46 = load double, double* %10
%47 = load double, double* %12
%48 = call double @llvm.fmuladd.f64(double %46, double %47, double %45)
store double %48, double* %7
store i32 1, i32* %13
br label %49
49: ; preds = %97, %28
%50 = load i32, i32* %13
%51 = icmp slt i32 %50, 200
br i1 %51, label %52, label %100
52: ; preds = %49
%53 = load i32, i32* %13
%54 = sitofp i32 %53 to double
%55 = fsub double %54, 5.000000e-01
%56 = load double, double* %6
%57 = fsub double %55, %56
%58 = load double, double* %10
%59 = load double, double* %6
%60 = load double, double* %9
%61 = fmul double %59, %60
%62 = call double @llvm.fmuladd.f64(double %57, double %58, double %61)
%63 = load i32, i32* %13
%64 = sitofp i32 %63 to double
%65 = fdiv double %62, %64
store double %65, double* %11
%66 = load double, double* %10
store double %66, double* %9
%67 = load double, double* %11
store double %67, double* %10
%68 = load double, double* %4
%69 = load i32, i32* %13
%70 = mul nsw i32 8, %69
%71 = add nsw i32 %70, 8
%72 = sitofp i32 %71 to double
%73 = fdiv double %68, %72
%74 = load double, double* %12
%75 = fmul double %74, %73
store double %75, double* %12
%76 = load double, double* %12
%77 = call double @llvm.fabs.f64(double %76)
%78 = fcmp olt double %77, 0x37A16C262777579C
br i1 %78, label %83, label %79
79: ; preds = %52
%80 = load double, double* %11
%81 = call double @llvm.fabs.f64(double %80)
%82 = fcmp olt double %81, 0x37A16C262777579C
br i1 %82, label %83, label %85
83: ; preds = %79, %52
%84 = load double, double* %7
store double %84, double* %3
br label %102
85: ; preds = %79
%86 = load double, double* %7
%87 = load double, double* %11
%88 = load double, double* %12
%89 = call double @llvm.fmuladd.f64(double %87, double %88, double %86)
store double %89, double* %8
%90 = load double, double* %7
%91 = load double, double* %8
%92 = fcmp oeq double %90, %91
br i1 %92, label %93, label %95
93: ; preds = %85
%94 = load double, double* %7
store double %94, double* %3
br label %102
95: ; preds = %85
%96 = load double, double* %8
store double %96, double* %7
br label %97
97: ; preds = %95
%98 = load i32, i32* %13
%99 = add nsw i32 %98, 1
store i32 %99, i32* %13
br label %49
100: ; preds = %49
%101 = load double, double* %7
store double %101, double* %3
br label %102
102: ; preds = %100, %93, %83, %27
%103 = load double, double* %3
ret double %103
}

LLVM IR (-O2):
define double @ADf(double %0, i32 %1) {
%3 = shl nsw i32 %1, 2
%4 = or i32 %3, 1
%5 = mul nsw i32 %4, %4
%6 = sitofp i32 %5 to double
%7 = fmul double %6, 0x3FF3BD3CC9BE45DF
%8 = fdiv double %7, %0
%9 = fcmp ogt double %8, 1.500000e+02
br i1 %9, label %52, label %10
10: ; preds = %2
%11 = fneg double %8
%12 = tail call double @exp(double %11)
%13 = fmul double %12, 0x4001C5831ADD62DD
%14 = fptosi double %8 to i32
%15 = tail call double @sqrt(i32 %14)
%16 = fdiv double %13, %15
%17 = fmul double %8, 2.000000e+00
%18 = fptosi double %17 to i32
%19 = tail call double @sqrt(i32 %18)
%20 = tail call double @cPhi(double %19)
%21 = fmul double %20, 0x401F7FCCDFF344A1
%22 = fmul double %0, 1.250000e-01
%23 = tail call double @llvm.fmuladd.f64(double %21, double %22, double %16)
br label %27
24: ; preds = %49
%25 = add nuw nsw i32 %28, 1
%26 = icmp eq i32 %25, 200
br i1 %26, label %52, label %27
27: ; preds = %10, %24
%28 = phi i32 [ 1, %10 ], [ %25, %24 ]
%29 = phi double [ %22, %10 ], [ %43, %24 ]
%30 = phi double [ %21, %10 ], [ %38, %24 ]
%31 = phi double [ %16, %10 ], [ %30, %24 ]
%32 = phi double [ %23, %10 ], [ %50, %24 ]
%33 = sitofp i32 %28 to double
%34 = fadd double %33, -5.000000e-01
%35 = fsub double %34, %8
%36 = fmul double %8, %31
%37 = tail call double @llvm.fmuladd.f64(double %35, double %30, double %36)
%38 = fdiv double %37, %33
%39 = shl nuw nsw i32 %28, 3
%40 = add nuw nsw i32 %39, 8
%41 = sitofp i32 %40 to double
%42 = fdiv double %0, %41
%43 = fmul double %29, %42
%44 = tail call double @llvm.fabs.f64(double %43)
%45 = fcmp olt double %44, 0x37A16C262777579C
%46 = tail call double @llvm.fabs.f64(double %38)
%47 = fcmp olt double %46, 0x37A16C262777579C
%48 = select i1 %45, i1 true, i1 %47
br i1 %48, label %52, label %49
49: ; preds = %27
%50 = tail call double @llvm.fmuladd.f64(double %38, double %43, double %32)
%51 = fcmp oeq double %32, %50
br i1 %51, label %52, label %24
52: ; preds = %24, %49, %27, %2
%53 = phi double [ 0.000000e+00, %2 ], [ %32, %27 ], [ %32, %49 ], [ %50, %24 ]
ret double %53
}