#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 /*<<< orphan*/ assert(int);
void ERI_Associated_Laguerre_Polynomial(double x, int n, double alpha,
                                        double *L, double *dL) {
  int i;
  double L0, L1, L2;
  assert(n >= 0);
  if (n == 0) {
    *L = 1.0;
    *dL = 0.0;
    return;
  } else if (n == 1) {
    *L = (1.0 + alpha) - x;
    *dL = -1.0;
    return;
  }
  L1 = 1.0;
  L2 = (1.0 + alpha) - x;
  for (i = 1; i < n; i++) {
    L0 = L1;
    L1 = L2;
    L2 = (((double)(2 * i + 1) + (alpha - x)) * L1 - ((double)i + alpha) * L0) /
         (double)(i + 1);
  }
  *L = L2;
  *dL = ((double)n * L2 - ((double)n + alpha) * L1) / x;
}


x86 assembly (clang, -O0):
<ERI_Associated_Laguerre_Polynomial>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
cmpl   $0x0,-0xc(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0xc(%rbp)
jne    1168 <ERI_Associated_Laguerre_Polynomial+0x58>
mov    -0x20(%rbp),%rax
movsd  0xeac(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    12b2 <ERI_Associated_Laguerre_Polynomial+0x1a2>
cmpl   $0x1,-0xc(%rbp)
jne    11a1 <ERI_Associated_Laguerre_Polynomial+0x91>
movsd  0xe86(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  0xe70(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    12b2 <ERI_Associated_Laguerre_Polynomial+0x1a2>
jmp    11a6 <ERI_Associated_Laguerre_Polynomial+0x96>
movsd  0xe52(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe45(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1260 <ERI_Associated_Laguerre_Polynomial+0x150>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x2c(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  -0x18(%rbp),%xmm1
subsd  -0x8(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x40(%rbp),%xmm2
cvtsi2sdl -0x2c(%rbp),%xmm1
addsd  -0x18(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11d1 <ERI_Associated_Laguerre_Polynomial+0xc1>
movsd  -0x48(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
cvtsi2sdl -0xc(%rbp),%xmm1
addsd  -0x18(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x8(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ERI_Associated_Laguerre_Polynomial>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
movsd  %xmm1,0x8(%rsp)
mov    %edi,%ebp
movsd  %xmm0,(%rsp)
not    %edi
shr    $0x1f,%edi
call   1030 <assert@plt>
cmp    $0x1,%ebp
je     1154 <ERI_Associated_Laguerre_Polynomial+0x44>
test   %ebp,%ebp
jne    1178 <ERI_Associated_Laguerre_Polynomial+0x68>
movabs $0x3ff0000000000000,%rax
mov    %rax,(%rbx)
xorpd  %xmm2,%xmm2
jmp    1237 <ERI_Associated_Laguerre_Polynomial+0x127>
movsd  0x8(%rsp),%xmm0
addsd  0xe9e(%rip),%xmm0
subsd  (%rsp),%xmm0
movsd  %xmm0,(%rbx)
movsd  0xe95(%rip),%xmm2
jmp    1237 <ERI_Associated_Laguerre_Polynomial+0x127>
movsd  0xe80(%rip),%xmm1
movsd  0x8(%rsp),%xmm7
movapd %xmm7,%xmm0
addsd  %xmm1,%xmm0
movsd  (%rsp),%xmm8
subsd  %xmm8,%xmm0
cmp    $0x2,%ebp
jl     1217 <ERI_Associated_Laguerre_Polynomial+0x107>
movapd %xmm7,%xmm2
subsd  %xmm8,%xmm2
mov    %ebp,%eax
neg    %eax
movsd  0xe4d(%rip),%xmm3
mov    $0x2,%edx
mov    $0x3,%ecx
movapd %xmm3,%xmm5
movapd %xmm3,%xmm4
cs nopw 0x0(%rax,%rax,1)
nop
movapd %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
addsd  %xmm2,%xmm0
movapd %xmm4,%xmm6
addsd  %xmm7,%xmm6
mulsd  %xmm5,%xmm6
mulsd  %xmm1,%xmm0
subsd  %xmm6,%xmm0
addsd  %xmm3,%xmm4
xorps  %xmm5,%xmm5
cvtsi2sd %edx,%xmm5
divsd  %xmm5,%xmm0
lea    (%rax,%rdx,1),%esi
add    $0x1,%esi
add    $0x1,%edx
add    $0x2,%ecx
movapd %xmm1,%xmm5
cmp    $0x1,%esi
jne    11d0 <ERI_Associated_Laguerre_Polynomial+0xc0>
movsd  %xmm0,(%rbx)
xorps  %xmm2,%xmm2
cvtsi2sd %ebp,%xmm2
addsd  %xmm2,%xmm7
mulsd  %xmm1,%xmm7
mulsd  %xmm0,%xmm2
subsd  %xmm7,%xmm2
divsd  %xmm8,%xmm2
movsd  %xmm2,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @ERI_Associated_Laguerre_Polynomial(double %0, i32 %1, double %2, double* %3, double* %4) {
%6 = alloca double
%7 = alloca i32
%8 = alloca double
%9 = alloca double*
%10 = alloca double*
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
store double %0, double* %6
store i32 %1, i32* %7
store double %2, double* %8
store double* %3, double** %9
store double* %4, double** %10
%15 = load i32, i32* %7
%16 = icmp sge i32 %15, 0
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i32, i32* %7
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %5
%22 = load double*, double** %9
store double 1.000000e+00, double* %22
%23 = load double*, double** %10
store double 0.000000e+00, double* %23
br label %88
24: ; preds = %5
%25 = load i32, i32* %7
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %34
27: ; preds = %24
%28 = load double, double* %8
%29 = fadd double 1.000000e+00, %28
%30 = load double, double* %6
%31 = fsub double %29, %30
%32 = load double*, double** %9
store double %31, double* %32
%33 = load double*, double** %10
store double -1.000000e+00, double* %33
br label %88
34: ; preds = %24
br label %35
35: ; preds = %34
store double 1.000000e+00, double* %13
%36 = load double, double* %8
%37 = fadd double 1.000000e+00, %36
%38 = load double, double* %6
%39 = fsub double %37, %38
store double %39, double* %14
store i32 1, i32* %11
br label %40
40: ; preds = %68, %35
%41 = load i32, i32* %11
%42 = load i32, i32* %7
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %71
44: ; preds = %40
%45 = load double, double* %13
store double %45, double* %12
%46 = load double, double* %14
store double %46, double* %13
%47 = load i32, i32* %11
%48 = mul nsw i32 2, %47
%49 = add nsw i32 %48, 1
%50 = sitofp i32 %49 to double
%51 = load double, double* %8
%52 = load double, double* %6
%53 = fsub double %51, %52
%54 = fadd double %50, %53
%55 = load double, double* %13
%56 = load i32, i32* %11
%57 = sitofp i32 %56 to double
%58 = load double, double* %8
%59 = fadd double %57, %58
%60 = load double, double* %12
%61 = fmul double %59, %60
%62 = fneg double %61
%63 = call double @llvm.fmuladd.f64(double %54, double %55, double %62)
%64 = load i32, i32* %11
%65 = add nsw i32 %64, 1
%66 = sitofp i32 %65 to double
%67 = fdiv double %63, %66
store double %67, double* %14
br label %68
68: ; preds = %44
%69 = load i32, i32* %11
%70 = add nsw i32 %69, 1
store i32 %70, i32* %11
br label %40
71: ; preds = %40
%72 = load double, double* %14
%73 = load double*, double** %9
store double %72, double* %73
%74 = load i32, i32* %7
%75 = sitofp i32 %74 to double
%76 = load double, double* %14
%77 = load i32, i32* %7
%78 = sitofp i32 %77 to double
%79 = load double, double* %8
%80 = fadd double %78, %79
%81 = load double, double* %13
%82 = fmul double %80, %81
%83 = fneg double %82
%84 = call double @llvm.fmuladd.f64(double %75, double %76, double %83)
%85 = load double, double* %6
%86 = fdiv double %84, %85
%87 = load double*, double** %10
store double %86, double* %87
br label %88
88: ; preds = %71, %27, %21
ret void
}

LLVM IR (-O2):
define void @ERI_Associated_Laguerre_Polynomial(double %0, i32 %1, double %2, double* nocapture writeonly %3, double* nocapture writeonly %4) {
%6 = xor i32 %1, -1
%7 = lshr i32 %6, 31
%8 = tail call i32 @assert(i32 %7)
switch i32 %1, label %13 [
i32 0, label %9
i32 1, label %10
]
9: ; preds = %5
store double 1.000000e+00, double* %3
br label %45
10: ; preds = %5
%11 = fadd double %2, 1.000000e+00
%12 = fsub double %11, %0
store double %12, double* %3
br label %45
13: ; preds = %5
%14 = fadd double %2, 1.000000e+00
%15 = fsub double %14, %0
%16 = icmp sgt i32 %1, 1
br i1 %16, label %17, label %36
17: ; preds = %13
%18 = fsub double %2, %0
br label %19
19: ; preds = %17, %19
%20 = phi double [ %15, %17 ], [ %34, %19 ]
%21 = phi double [ 1.000000e+00, %17 ], [ %20, %19 ]
%22 = phi i32 [ 1, %17 ], [ %32, %19 ]
%23 = shl nuw nsw i32 %22, 1
%24 = or i32 %23, 1
%25 = sitofp i32 %24 to double
%26 = fadd double %18, %25
%27 = sitofp i32 %22 to double
%28 = fadd double %27, %2
%29 = fneg double %28
%30 = fmul double %21, %29
%31 = tail call double @llvm.fmuladd.f64(double %26, double %20, double %30)
%32 = add nuw nsw i32 %22, 1
%33 = sitofp i32 %32 to double
%34 = fdiv double %31, %33
%35 = icmp eq i32 %32, %1
br i1 %35, label %36, label %19
36: ; preds = %19, %13
%37 = phi double [ 1.000000e+00, %13 ], [ %20, %19 ]
%38 = phi double [ %15, %13 ], [ %34, %19 ]
store double %38, double* %3
%39 = sitofp i32 %1 to double
%40 = fadd double %39, %2
%41 = fneg double %40
%42 = fmul double %37, %41
%43 = tail call double @llvm.fmuladd.f64(double %39, double %38, double %42)
%44 = fdiv double %43, %0
br label %45
45: ; preds = %36, %10, %9
%46 = phi double [ %44, %36 ], [ -1.000000e+00, %10 ], [ 0.000000e+00, %9 ]
store double %46, double* %4
ret void
}