#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*/ ERI_RCSH_Coeff(int, double *, double *);
int /*<<< orphan*/ ERI_Spherical_Harmonics(int, int, double, double, double *,
                                           double *, double *);
void ERI_Real_Spherical_Harmonics(int l, int m, double theta, double phi,
                                  double *Z, double *dZdt, double *dZdp) {
  double Y1[2], dY1dt[2], dY1dp[2];
  double Y2[2], dY2dt[2], dY2dp[2];
  double a[2], b[2];
  ERI_Spherical_Harmonics(l, m, theta, phi, Y1, dY1dt, dY1dp);
  ERI_Spherical_Harmonics(l, -m, theta, phi, Y2, dY2dt, dY2dp);
  ERI_RCSH_Coeff(m, a, b);
  if (Z) {
    *Z = a[0] * Y1[0] - a[1] * Y1[1] + b[0] * Y2[0] - b[1] * Y2[1];
  }
  if (dZdt) {
    *dZdt =
        a[0] * dY1dt[0] - a[1] * dY1dt[1] + b[0] * dY2dt[0] - b[1] * dY2dt[1];
  }
  if (dZdp) {
    *dZdp =
        a[0] * dY1dp[0] - a[1] * dY1dp[1] + b[0] * dY2dp[0] - b[1] * dY2dp[1];
  }
}


x86 assembly (clang, -O0):
<ERI_Real_Spherical_Harmonics>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    -0x40(%rbp),%rdx
lea    -0x50(%rbp),%rcx
lea    -0x60(%rbp),%r8
call   1040 <ERI_Spherical_Harmonics@plt>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
sub    -0x8(%rbp),%esi
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    -0x70(%rbp),%rdx
lea    -0x80(%rbp),%rcx
lea    -0x90(%rbp),%r8
call   1040 <ERI_Spherical_Harmonics@plt>
mov    -0x8(%rbp),%edi
lea    -0xa0(%rbp),%rsi
lea    -0xb0(%rbp),%rdx
call   1030 <ERI_RCSH_Coeff@plt>
cmpq   $0x0,-0x20(%rbp)
je     1231 <ERI_Real_Spherical_Harmonics+0x111>
movsd  -0xa0(%rbp),%xmm0
ff
movsd  -0x40(%rbp),%xmm2
movsd  -0x98(%rbp),%xmm1
ff
mulsd  -0x38(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0xb0(%rbp),%xmm1
ff
movsd  -0x70(%rbp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0xa8(%rbp),%xmm0
ff
movsd  -0x68(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
cmpq   $0x0,-0x28(%rbp)
je     12be <ERI_Real_Spherical_Harmonics+0x19e>
movsd  -0xa0(%rbp),%xmm0
ff
movsd  -0x50(%rbp),%xmm2
movsd  -0x98(%rbp),%xmm1
ff
mulsd  -0x48(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0xb0(%rbp),%xmm1
ff
movsd  -0x80(%rbp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0xa8(%rbp),%xmm0
ff
movsd  -0x78(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
cmpq   $0x0,-0x30(%rbp)
je     1351 <ERI_Real_Spherical_Harmonics+0x231>
movsd  -0xa0(%rbp),%xmm0
ff
movsd  -0x60(%rbp),%xmm2
movsd  -0x98(%rbp),%xmm1
ff
mulsd  -0x58(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0xb0(%rbp),%xmm1
ff
movsd  -0x90(%rbp),%xmm2
ff
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0xa8(%rbp),%xmm0
ff
movsd  -0x88(%rbp),%xmm2
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ERI_Real_Spherical_Harmonics>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x90,%rsp
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
movsd  %xmm1,0x28(%rsp)
movsd  %xmm0,0x20(%rsp)
mov    %esi,%ebp
mov    %edi,%ebx
lea    0x80(%rsp),%rdx
lea    0x70(%rsp),%rcx
lea    0x60(%rsp),%r8
call   1040 <ERI_Spherical_Harmonics@plt>
mov    %ebp,%esi
neg    %esi
lea    0x50(%rsp),%rdx
lea    0x40(%rsp),%rcx
lea    0x30(%rsp),%r8
mov    %ebx,%edi
movsd  0x20(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
call   1040 <ERI_Spherical_Harmonics@plt>
lea    0x10(%rsp),%rsi
mov    %rsp,%rdx
mov    %ebp,%edi
call   1030 <ERI_RCSH_Coeff@plt>
test   %r12,%r12
je     11e0 <ERI_Real_Spherical_Harmonics+0xc0>
movsd  0x10(%rsp),%xmm0
movsd  0x88(%rsp),%xmm1
mulsd  0x18(%rsp),%xmm1
mulsd  0x80(%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  (%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
mulsd  0x50(%rsp),%xmm1
addsd  %xmm0,%xmm1
mulsd  0x58(%rsp),%xmm2
subsd  %xmm2,%xmm1
movsd  %xmm1,(%r12)
test   %r15,%r15
je     1225 <ERI_Real_Spherical_Harmonics+0x105>
movsd  0x10(%rsp),%xmm0
movsd  0x78(%rsp),%xmm1
mulsd  0x18(%rsp),%xmm1
mulsd  0x70(%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  (%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
mulsd  0x40(%rsp),%xmm1
addsd  %xmm0,%xmm1
mulsd  0x48(%rsp),%xmm2
subsd  %xmm2,%xmm1
movsd  %xmm1,(%r15)
test   %r14,%r14
je     126a <ERI_Real_Spherical_Harmonics+0x14a>
movsd  0x10(%rsp),%xmm0
movsd  0x68(%rsp),%xmm1
mulsd  0x18(%rsp),%xmm1
mulsd  0x60(%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  (%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
mulsd  0x30(%rsp),%xmm1
addsd  %xmm0,%xmm1
mulsd  0x38(%rsp),%xmm2
subsd  %xmm2,%xmm1
movsd  %xmm1,(%r14)
add    $0x90,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ERI_Real_Spherical_Harmonics(i32 %0, i32 %1, double %2, double %3, double* %4, double* %5, double* %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca [2 x double]
%16 = alloca [2 x double]
%17 = alloca [2 x double]
%18 = alloca [2 x double]
%19 = alloca [2 x double]
%20 = alloca [2 x double]
%21 = alloca [2 x double]
%22 = alloca [2 x double]
store i32 %0, i32* %8
store i32 %1, i32* %9
store double %2, double* %10
store double %3, double* %11
store double* %4, double** %12
store double* %5, double** %13
store double* %6, double** %14
%23 = load i32, i32* %8
%24 = load i32, i32* %9
%25 = load double, double* %10
%26 = load double, double* %11
%27 = getelementptr inbounds [2 x double], [2 x double]* %15, i64 0, i64 0
%28 = getelementptr inbounds [2 x double], [2 x double]* %16, i64 0, i64 0
%29 = getelementptr inbounds [2 x double], [2 x double]* %17, i64 0, i64 0
%30 = call i32 @ERI_Spherical_Harmonics(i32 %23, i32 %24, double %25, double %26, double* %27, double* %28, double* %29)
%31 = load i32, i32* %8
%32 = load i32, i32* %9
%33 = sub nsw i32 0, %32
%34 = load double, double* %10
%35 = load double, double* %11
%36 = getelementptr inbounds [2 x double], [2 x double]* %18, i64 0, i64 0
%37 = getelementptr inbounds [2 x double], [2 x double]* %19, i64 0, i64 0
%38 = getelementptr inbounds [2 x double], [2 x double]* %20, i64 0, i64 0
%39 = call i32 @ERI_Spherical_Harmonics(i32 %31, i32 %33, double %34, double %35, double* %36, double* %37, double* %38)
%40 = load i32, i32* %9
%41 = getelementptr inbounds [2 x double], [2 x double]* %21, i64 0, i64 0
%42 = getelementptr inbounds [2 x double], [2 x double]* %22, i64 0, i64 0
%43 = call i32 @ERI_RCSH_Coeff(i32 %40, double* %41, double* %42)
%44 = load double*, double** %12
%45 = icmp ne double* %44, null
br i1 %45, label %46, label %70
46: ; preds = %7
%47 = getelementptr inbounds [2 x double], [2 x double]* %21, i64 0, i64 0
%48 = load double, double* %47
%49 = getelementptr inbounds [2 x double], [2 x double]* %15, i64 0, i64 0
%50 = load double, double* %49
%51 = getelementptr inbounds [2 x double], [2 x double]* %21, i64 0, i64 1
%52 = load double, double* %51
%53 = getelementptr inbounds [2 x double], [2 x double]* %15, i64 0, i64 1
%54 = load double, double* %53
%55 = fmul double %52, %54
%56 = fneg double %55
%57 = call double @llvm.fmuladd.f64(double %48, double %50, double %56)
%58 = getelementptr inbounds [2 x double], [2 x double]* %22, i64 0, i64 0
%59 = load double, double* %58
%60 = getelementptr inbounds [2 x double], [2 x double]* %18, i64 0, i64 0
%61 = load double, double* %60
%62 = call double @llvm.fmuladd.f64(double %59, double %61, double %57)
%63 = getelementptr inbounds [2 x double], [2 x double]* %22, i64 0, i64 1
%64 = load double, double* %63
%65 = getelementptr inbounds [2 x double], [2 x double]* %18, i64 0, i64 1
%66 = load double, double* %65
%67 = fneg double %64
%68 = call double @llvm.fmuladd.f64(double %67, double %66, double %62)
%69 = load double*, double** %12
store double %68, double* %69
br label %70
70: ; preds = %46, %7
%71 = load double*, double** %13
%72 = icmp ne double* %71, null
br i1 %72, label %73, label %97
73: ; preds = %70
%74 = getelementptr inbounds [2 x double], [2 x double]* %21, i64 0, i64 0
%75 = load double, double* %74
%76 = getelementptr inbounds [2 x double], [2 x double]* %16, i64 0, i64 0
%77 = load double, double* %76
%78 = getelementptr inbounds [2 x double], [2 x double]* %21, i64 0, i64 1
%79 = load double, double* %78
%80 = getelementptr inbounds [2 x double], [2 x double]* %16, i64 0, i64 1
%81 = load double, double* %80
%82 = fmul double %79, %81
%83 = fneg double %82
%84 = call double @llvm.fmuladd.f64(double %75, double %77, double %83)
%85 = getelementptr inbounds [2 x double], [2 x double]* %22, i64 0, i64 0
%86 = load double, double* %85
%87 = getelementptr inbounds [2 x double], [2 x double]* %19, i64 0, i64 0
%88 = load double, double* %87
%89 = call double @llvm.fmuladd.f64(double %86, double %88, double %84)
%90 = getelementptr inbounds [2 x double], [2 x double]* %22, i64 0, i64 1
%91 = load double, double* %90
%92 = getelementptr inbounds [2 x double], [2 x double]* %19, i64 0, i64 1
%93 = load double, double* %92
%94 = fneg double %91
%95 = call double @llvm.fmuladd.f64(double %94, double %93, double %89)
%96 = load double*, double** %13
store double %95, double* %96
br label %97
97: ; preds = %73, %70
%98 = load double*, double** %14
%99 = icmp ne double* %98, null
br i1 %99, label %100, label %124
100: ; preds = %97
%101 = getelementptr inbounds [2 x double], [2 x double]* %21, i64 0, i64 0
%102 = load double, double* %101
%103 = getelementptr inbounds [2 x double], [2 x double]* %17, i64 0, i64 0
%104 = load double, double* %103
%105 = getelementptr inbounds [2 x double], [2 x double]* %21, i64 0, i64 1
%106 = load double, double* %105
%107 = getelementptr inbounds [2 x double], [2 x double]* %17, i64 0, i64 1
%108 = load double, double* %107
%109 = fmul double %106, %108
%110 = fneg double %109
%111 = call double @llvm.fmuladd.f64(double %102, double %104, double %110)
%112 = getelementptr inbounds [2 x double], [2 x double]* %22, i64 0, i64 0
%113 = load double, double* %112
%114 = getelementptr inbounds [2 x double], [2 x double]* %20, i64 0, i64 0
%115 = load double, double* %114
%116 = call double @llvm.fmuladd.f64(double %113, double %115, double %111)
%117 = getelementptr inbounds [2 x double], [2 x double]* %22, i64 0, i64 1
%118 = load double, double* %117
%119 = getelementptr inbounds [2 x double], [2 x double]* %20, i64 0, i64 1
%120 = load double, double* %119
%121 = fneg double %118
%122 = call double @llvm.fmuladd.f64(double %121, double %120, double %116)
%123 = load double*, double** %14
store double %122, double* %123
br label %124
124: ; preds = %100, %97
ret void
}

LLVM IR (-O2):
define void @ERI_Real_Spherical_Harmonics(i32 %0, i32 %1, double %2, double %3, double* writeonly %4, double* writeonly %5, double* writeonly %6) {
%8 = alloca [2 x double]
%9 = alloca [2 x double]
%10 = alloca [2 x double]
%11 = alloca [2 x double]
%12 = alloca [2 x double]
%13 = alloca [2 x double]
%14 = alloca [2 x double]
%15 = alloca [2 x double]
%16 = bitcast [2 x double]* %8 to i8*
%17 = bitcast [2 x double]* %9 to i8*
%18 = bitcast [2 x double]* %10 to i8*
%19 = bitcast [2 x double]* %11 to i8*
%20 = bitcast [2 x double]* %12 to i8*
%21 = bitcast [2 x double]* %13 to i8*
%22 = bitcast [2 x double]* %14 to i8*
%23 = bitcast [2 x double]* %15 to i8*
%24 = getelementptr inbounds [2 x double], [2 x double]* %8, i64 0, i64 0
%25 = getelementptr inbounds [2 x double], [2 x double]* %9, i64 0, i64 0
%26 = getelementptr inbounds [2 x double], [2 x double]* %10, i64 0, i64 0
%27 = call i32 @ERI_Spherical_Harmonics(i32 %0, i32 %1, double %2, double %3, double* %24, double* %25, double* %26)
%28 = sub nsw i32 0, %1
%29 = getelementptr inbounds [2 x double], [2 x double]* %11, i64 0, i64 0
%30 = getelementptr inbounds [2 x double], [2 x double]* %12, i64 0, i64 0
%31 = getelementptr inbounds [2 x double], [2 x double]* %13, i64 0, i64 0
%32 = call i32 @ERI_Spherical_Harmonics(i32 %0, i32 %28, double %2, double %3, double* %29, double* %30, double* %31)
%33 = getelementptr inbounds [2 x double], [2 x double]* %14, i64 0, i64 0
%34 = getelementptr inbounds [2 x double], [2 x double]* %15, i64 0, i64 0
%35 = call i32 @ERI_RCSH_Coeff(i32 %1, double* %33, double* %34)
%36 = icmp eq double* %4, null
br i1 %36, label %56, label %37
37: ; preds = %7
%38 = load double, double* %33
%39 = load double, double* %24
%40 = getelementptr inbounds [2 x double], [2 x double]* %14, i64 0, i64 1
%41 = load double, double* %40
%42 = getelementptr inbounds [2 x double], [2 x double]* %8, i64 0, i64 1
%43 = load double, double* %42
%44 = fneg double %41
%45 = fmul double %43, %44
%46 = call double @llvm.fmuladd.f64(double %38, double %39, double %45)
%47 = load double, double* %34
%48 = load double, double* %29
%49 = call double @llvm.fmuladd.f64(double %47, double %48, double %46)
%50 = getelementptr inbounds [2 x double], [2 x double]* %15, i64 0, i64 1
%51 = load double, double* %50
%52 = getelementptr inbounds [2 x double], [2 x double]* %11, i64 0, i64 1
%53 = load double, double* %52
%54 = fneg double %51
%55 = call double @llvm.fmuladd.f64(double %54, double %53, double %49)
store double %55, double* %4
br label %56
56: ; preds = %37, %7
%57 = icmp eq double* %5, null
br i1 %57, label %77, label %58
58: ; preds = %56
%59 = load double, double* %33
%60 = load double, double* %25
%61 = getelementptr inbounds [2 x double], [2 x double]* %14, i64 0, i64 1
%62 = load double, double* %61
%63 = getelementptr inbounds [2 x double], [2 x double]* %9, i64 0, i64 1
%64 = load double, double* %63
%65 = fneg double %62
%66 = fmul double %64, %65
%67 = call double @llvm.fmuladd.f64(double %59, double %60, double %66)
%68 = load double, double* %34
%69 = load double, double* %30
%70 = call double @llvm.fmuladd.f64(double %68, double %69, double %67)
%71 = getelementptr inbounds [2 x double], [2 x double]* %15, i64 0, i64 1
%72 = load double, double* %71
%73 = getelementptr inbounds [2 x double], [2 x double]* %12, i64 0, i64 1
%74 = load double, double* %73
%75 = fneg double %72
%76 = call double @llvm.fmuladd.f64(double %75, double %74, double %70)
store double %76, double* %5
br label %77
77: ; preds = %58, %56
%78 = icmp eq double* %6, null
br i1 %78, label %98, label %79
79: ; preds = %77
%80 = load double, double* %33
%81 = load double, double* %26
%82 = getelementptr inbounds [2 x double], [2 x double]* %14, i64 0, i64 1
%83 = load double, double* %82
%84 = getelementptr inbounds [2 x double], [2 x double]* %10, i64 0, i64 1
%85 = load double, double* %84
%86 = fneg double %83
%87 = fmul double %85, %86
%88 = call double @llvm.fmuladd.f64(double %80, double %81, double %87)
%89 = load double, double* %34
%90 = load double, double* %31
%91 = call double @llvm.fmuladd.f64(double %89, double %90, double %88)
%92 = getelementptr inbounds [2 x double], [2 x double]* %15, i64 0, i64 1
%93 = load double, double* %92
%94 = getelementptr inbounds [2 x double], [2 x double]* %13, i64 0, i64 1
%95 = load double, double* %94
%96 = fneg double %93
%97 = call double @llvm.fmuladd.f64(double %96, double %95, double %91)
store double %97, double* %6
br label %98
98: ; preds = %79, %77
ret void
}