#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 DBL_MAX;
int /*<<< orphan*/ ERI_Associated_Laguerre_Polynomial(double, int, double,
                                                      double *, double *);
int fabs(double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
void ERI_GLQ(double *x, double *w, int n) {
  int i, itr;
  double err, xi, i1, L, dL;
  for (i = 0; i < n; i++) {
    if (i == 0) {
      xi = 3.0 / (1.0 + 2.4 * (double)n);
    } else if (i == 1) {
      xi = x[i - 1] + 15.0 / (1.0 + 2.5 * (double)n);
    } else {
      i1 = (double)(i - 1);
      xi = x[i - 1] + (x[i - 1] - x[i - 2]) * (1.0 + 2.55 * i1) / (1.9 * i1);
    }
    err = DBL_MAX;
    for (itr = 0; (itr < 50) && (fabs(err) > 1e-12); itr++) {
      ERI_Associated_Laguerre_Polynomial(xi, n, 0.0, &L, &dL);
      err = L / dL;
      xi -= err;
    }
    if (fabs(err) > 1e-12) {
      fprintf(stderr, "*** error in ERI_GLQ: no convergence\n");
      fprintf(stderr, "    err = %12.4e\n", err);
    }
    x[i] = xi;
    w[i] = 1.0 / dL / dL / xi;
  }
}


x86 assembly (clang, -O0):
<ERI_GLQ>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    13a0 <ERI_GLQ+0x270>
cmpl   $0x0,-0x18(%rbp)
jne    1193 <ERI_GLQ+0x63>
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  0xec3(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xe97(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xea3(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    126b <ERI_GLQ+0x13b>
cmpl   $0x1,-0x18(%rbp)
jne    11e6 <ERI_GLQ+0xb6>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm2
movsd  0xe64(%rip),%xmm1
mulsd  %xmm1,%xmm2
movsd  0xe48(%rip),%xmm1
addsd  %xmm1,%xmm2
movsd  0xe44(%rip),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1266 <ERI_GLQ+0x136>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm1
movsd  -0x38(%rbp),%xmm2
movsd  0xdd0(%rip),%xmm3
mulsd  %xmm3,%xmm2
movsd  0xdcc(%rip),%xmm3
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
movsd  0xdac(%rip),%xmm2
mulsd  -0x38(%rbp),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    126b <ERI_GLQ+0x13b>
mov    0x2d66(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
xor    %eax,%eax
cmpl   $0x32,-0x1c(%rbp)
mov    %al,-0x49(%rbp)
jge    12b1 <ERI_GLQ+0x181>
movsd  -0x28(%rbp),%xmm0
call   1040 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xd91(%rip),%xmm1
ucomisd %xmm1,%xmm0
seta   %al
mov    %al,-0x49(%rbp)
mov    -0x49(%rbp),%al
test   $0x1,%al
jne    12c1 <ERI_GLQ+0x191>
jmp    1309 <ERI_GLQ+0x1d9>
movsd  -0x30(%rbp),%xmm0
mov    -0x14(%rbp),%edi
xorps  %xmm1,%xmm1
lea    -0x40(%rbp),%rsi
lea    -0x48(%rbp),%rdx
call   1030 <ERI_Associated_Laguerre_Polynomial@plt>
movsd  -0x40(%rbp),%xmm0
divsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1282 <ERI_GLQ+0x152>
movsd  -0x28(%rbp),%xmm0
call   1040 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xd19(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    135c <ERI_GLQ+0x22c>
mov    0x2cb0(%rip),%rax
mov    (%rax),%edi
lea    0xd07(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2c99(%rip),%rax
mov    (%rax),%edi
movsd  -0x28(%rbp),%xmm0
lea    0xd11(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
movsd  -0x30(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  0xc9a(%rip),%xmm0
divsd  -0x48(%rbp),%xmm0
divsd  -0x48(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114a <ERI_GLQ+0x1a>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ERI_GLQ>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,0x38(%rsp)
test   %edx,%edx
jle    132d <ERI_GLQ+0x1fd>
mov    %edx,%ebx
mov    %rdi,%r15
cvtsi2sd %edx,%xmm0
movsd  0xea4(%rip),%xmm1
mulsd  %xmm0,%xmm1
movsd  0xea0(%rip),%xmm2
addsd  %xmm2,%xmm1
movsd  0xe9c(%rip),%xmm3
divsd  %xmm1,%xmm3
movsd  %xmm3,0x20(%rsp)
mulsd  0xe92(%rip),%xmm0
addsd  %xmm2,%xmm0
movsd  0xe8e(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x30(%rsp)
mov    %edx,%eax
mov    %rax,0x28(%rsp)
lea    0x40(%rsp),%r12
lea    0x18(%rsp),%r13
xor    %r14d,%r14d
jmp    1200 <ERI_GLQ+0xd0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  0x8(%rsp),%xmm2
movsd  %xmm2,(%r15,%r14,8)
movsd  0x18(%rsp),%xmm0
movsd  0xe2e(%rip),%xmm1
divsd  %xmm0,%xmm1
divsd  %xmm0,%xmm1
divsd  %xmm2,%xmm1
mov    0x38(%rsp),%rax
movsd  %xmm1,(%rax,%r14,8)
add    $0x1,%r14
cmp    0x28(%rsp),%r14
je     132d <ERI_GLQ+0x1fd>
movsd  0x30(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
test   %r14d,%r14d
je     127b <ERI_GLQ+0x14b>
cmp    $0x1,%r14d
jne    1230 <ERI_GLQ+0x100>
movsd  (%r15),%xmm0
addsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
jmp    127b <ERI_GLQ+0x14b>
nopw   0x0(%rax,%rax,1)
lea    -0x1(%r14),%rax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  -0x8(%r15,%r14,8),%xmm1
movapd %xmm1,%xmm2
subsd  -0x10(%r15,%r14,8),%xmm2
movapd %xmm0,%xmm3
mulsd  0xdcf(%rip),%xmm3
addsd  0xda7(%rip),%xmm3
mulsd  %xmm2,%xmm3
mulsd  0xdc3(%rip),%xmm0
divsd  %xmm0,%xmm3
addsd  %xmm1,%xmm3
movsd  %xmm3,0x8(%rsp)
mov    0x2d56(%rip),%rax
movsd  (%rax),%xmm0
mov    $0x32,%ebp
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x10(%rsp)
call   1040 <fabs@plt>
test   %eax,%eax
jle    12e0 <ERI_GLQ+0x1b0>
xorpd  %xmm1,%xmm1
movsd  0x8(%rsp),%xmm0
mov    %ebx,%edi
mov    %r12,%rsi
mov    %r13,%rdx
call   1030 <ERI_Associated_Laguerre_Polynomial@plt>
movsd  0x40(%rsp),%xmm0
divsd  0x18(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
add    $0xffffffff,%ebp
jne    1290 <ERI_GLQ+0x160>
jmp    12e6 <ERI_GLQ+0x1b6>
nopl   0x0(%rax)
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
call   1040 <fabs@plt>
test   %eax,%eax
jle    11c0 <ERI_GLQ+0x90>
mov    0x2ce0(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xd2e(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xd43(%rip),%rsi
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1050 <fprintf@plt>
jmp    11c0 <ERI_GLQ+0x90>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@DBL_MAX = global double 0.000000e+00
@stderr = global i32 0
@.str = [38 x i8] c"*** error in ERI_GLQ: no convergence\0A\00"
@.str.1 = [18 x i8] c" err = %12.4e\0A\00"
define void @ERI_GLQ(double* %0, double* %1, i32 %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
store double* %0, double** %4
store double* %1, double** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %14
14: ; preds = %124, %3
%15 = load i32, i32* %7
%16 = load i32, i32* %6
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %127
18: ; preds = %14
%19 = load i32, i32* %7
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load i32, i32* %6
%23 = sitofp i32 %22 to double
%24 = call double @llvm.fmuladd.f64(double 2.400000e+00, double %23, double 1.000000e+00)
%25 = fdiv double 3.000000e+00, %24
store double %25, double* %10
br label %72
26: ; preds = %18
%27 = load i32, i32* %7
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %41
29: ; preds = %26
%30 = load double*, double** %4
%31 = load i32, i32* %7
%32 = sub nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %30, i64 %33
%35 = load double, double* %34
%36 = load i32, i32* %6
%37 = sitofp i32 %36 to double
%38 = call double @llvm.fmuladd.f64(double 2.500000e+00, double %37, double 1.000000e+00)
%39 = fdiv double 1.500000e+01, %38
%40 = fadd double %35, %39
store double %40, double* %10
br label %71
41: ; preds = %26
%42 = load i32, i32* %7
%43 = sub nsw i32 %42, 1
%44 = sitofp i32 %43 to double
store double %44, double* %11
%45 = load double*, double** %4
%46 = load i32, i32* %7
%47 = sub nsw i32 %46, 1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds double, double* %45, i64 %48
%50 = load double, double* %49
%51 = load double*, double** %4
%52 = load i32, i32* %7
%53 = sub nsw i32 %52, 1
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double, double* %51, i64 %54
%56 = load double, double* %55
%57 = load double*, double** %4
%58 = load i32, i32* %7
%59 = sub nsw i32 %58, 2
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %57, i64 %60
%62 = load double, double* %61
%63 = fsub double %56, %62
%64 = load double, double* %11
%65 = call double @llvm.fmuladd.f64(double 2.550000e+00, double %64, double 1.000000e+00)
%66 = fmul double %63, %65
%67 = load double, double* %11
%68 = fmul double 1.900000e+00, %67
%69 = fdiv double %66, %68
%70 = fadd double %50, %69
store double %70, double* %10
br label %71
71: ; preds = %41, %29
br label %72
72: ; preds = %71, %21
%73 = load double, double* @DBL_MAX
store double %73, double* %9
store i32 0, i32* %8
br label %74
74: ; preds = %94, %72
%75 = load i32, i32* %8
%76 = icmp slt i32 %75, 50
br i1 %76, label %77, label %82
77: ; preds = %74
%78 = load double, double* %9
%79 = call i32 @fabs(double %78)
%80 = sitofp i32 %79 to double
%81 = fcmp ogt double %80, 0x3D719799812DEA11
br label %82
82: ; preds = %77, %74
%83 = phi i1 [ false, %74 ], [ %81, %77 ]
br i1 %83, label %84, label %97
84: ; preds = %82
%85 = load double, double* %10
%86 = load i32, i32* %6
%87 = call i32 @ERI_Associated_Laguerre_Polynomial(double %85, i32 %86, double 0.000000e+00, double* %12, double* %13)
%88 = load double, double* %12
%89 = load double, double* %13
%90 = fdiv double %88, %89
store double %90, double* %9
%91 = load double, double* %9
%92 = load double, double* %10
%93 = fsub double %92, %91
store double %93, double* %10
br label %94
94: ; preds = %84
%95 = load i32, i32* %8
%96 = add nsw i32 %95, 1
store i32 %96, i32* %8
br label %74
97: ; preds = %82
%98 = load double, double* %9
%99 = call i32 @fabs(double %98)
%100 = sitofp i32 %99 to double
%101 = fcmp ogt double %100, 0x3D719799812DEA11
br i1 %101, label %102, label %108
102: ; preds = %97
%103 = load i32, i32* @stderr
%104 = call i32 (i32, i8*, ...) @fprintf(i32 %103, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%105 = load i32, i32* @stderr
%106 = load double, double* %9
%107 = call i32 (i32, i8*, ...) @fprintf(i32 %105, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), double %106)
br label %108
108: ; preds = %102, %97
%109 = load double, double* %10
%110 = load double*, double** %4
%111 = load i32, i32* %7
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds double, double* %110, i64 %112
store double %109, double* %113
%114 = load double, double* %13
%115 = fdiv double 1.000000e+00, %114
%116 = load double, double* %13
%117 = fdiv double %115, %116
%118 = load double, double* %10
%119 = fdiv double %117, %118
%120 = load double*, double** %5
%121 = load i32, i32* %7
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds double, double* %120, i64 %122
store double %119, double* %123
br label %124
124: ; preds = %108
%125 = load i32, i32* %7
%126 = add nsw i32 %125, 1
store i32 %126, i32* %7
br label %14
127: ; preds = %14
ret void
}

LLVM IR (-O2):
@DBL_MAX = global double 0.000000e+00
@stderr = global i32 0
@.str = [38 x i8] c"*** error in ERI_GLQ: no convergence\0A\00"
@.str.1 = [18 x i8] c" err = %12.4e\0A\00"
define void @ERI_GLQ(double* nocapture %0, double* nocapture writeonly %1, i32 %2) {
%4 = alloca double
%5 = alloca double
%6 = bitcast double* %4 to i8*
%7 = bitcast double* %5 to i8*
%8 = icmp sgt i32 %2, 0
br i1 %8, label %9, label %73
9: ; preds = %3
%10 = sitofp i32 %2 to double
%11 = call double @llvm.fmuladd.f64(double %10, double 2.500000e+00, double 1.000000e+00)
%12 = fdiv double 1.500000e+01, %11
%13 = call double @llvm.fmuladd.f64(double %10, double 2.400000e+00, double 1.000000e+00)
%14 = fdiv double 3.000000e+00, %13
%15 = zext i32 %2 to i64
br label %16
16: ; preds = %9, %64
%17 = phi i64 [ 0, %9 ], [ %71, %64 ]
%18 = trunc i64 %17 to i32
switch i32 %18, label %22 [
i32 0, label %37
i32 1, label %19
]
19: ; preds = %16
%20 = load double, double* %0
%21 = fadd double %12, %20
br label %37
22: ; preds = %16
%23 = add nsw i64 %17, -1
%24 = trunc i64 %23 to i32
%25 = sitofp i32 %24 to double
%26 = getelementptr inbounds double, double* %0, i64 %23
%27 = load double, double* %26
%28 = add nsw i64 %17, -2
%29 = getelementptr inbounds double, double* %0, i64 %28
%30 = load double, double* %29
%31 = fsub double %27, %30
%32 = call double @llvm.fmuladd.f64(double %25, double 2.550000e+00, double 1.000000e+00)
%33 = fmul double %32, %31
%34 = fmul double %25, 1.900000e+00
%35 = fdiv double %33, %34
%36 = fadd double %27, %35
br label %37
37: ; preds = %16, %19, %22
%38 = phi double [ %21, %19 ], [ %36, %22 ], [ %14, %16 ]
%39 = load double, double* @DBL_MAX
br label %40
40: ; preds = %37, %46
%41 = phi double [ %38, %37 ], [ %51, %46 ]
%42 = phi double [ %39, %37 ], [ %50, %46 ]
%43 = phi i32 [ 0, %37 ], [ %52, %46 ]
%44 = call i32 @fabs(double %42)
%45 = icmp sgt i32 %44, 0
br i1 %45, label %46, label %54
46: ; preds = %40
%47 = call i32 @ERI_Associated_Laguerre_Polynomial(double %41, i32 %2, double 0.000000e+00, double* %4, double* %5)
%48 = load double, double* %4
%49 = load double, double* %5
%50 = fdiv double %48, %49
%51 = fsub double %41, %50
%52 = add nuw nsw i32 %43, 1
%53 = icmp eq i32 %52, 50
br i1 %53, label %54, label %40
54: ; preds = %46, %40
%55 = phi double [ %50, %46 ], [ %42, %40 ]
%56 = phi double [ %51, %46 ], [ %41, %40 ]
%57 = call i32 @fabs(double %55)
%58 = icmp sgt i32 %57, 0
br i1 %58, label %59, label %64
59: ; preds = %54
%60 = load i32, i32* @stderr
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%62 = load i32, i32* @stderr
%63 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), double %55)
br label %64
64: ; preds = %59, %54
%65 = getelementptr inbounds double, double* %0, i64 %17
store double %56, double* %65
%66 = load double, double* %5
%67 = fdiv double 1.000000e+00, %66
%68 = fdiv double %67, %66
%69 = fdiv double %68, %56
%70 = getelementptr inbounds double, double* %1, i64 %17
store double %69, double* %70
%71 = add nuw nsw i64 %17, 1
%72 = icmp eq i64 %71, %15
br i1 %72, label %73, label %16
73: ; preds = %64, %3
ret void
}