void scalars_nonewald_poly(int version, double r, double aa, double ab,
                           double *scalar) {
  int i;
  for (i = 0; i < 11; i++)
    scalar[i] = 0.0;
  double r2 = r * r;
  double aa2 = aa * aa;
  double ab2 = ab * ab;
  scalar[0] = (1.5 - (aa2 + ab2) * 0.5 / r2) / r;
  scalar[1] = (0.75 + (aa2 + ab2) * 0.25 / r2) / r;
  if (version == 0)
    return;
  scalar[2] = -0.75 / r2;
  scalar[3] = 0.75 / r2 / r;
  scalar[4] = -3.0 / 8.0 / r2 / r;
  if (version == 1)
    return;
  scalar[5] = (2.25 - 13.5 * (aa2 / 10.0 + ab2 / 6.0) / r2) / r2;
  scalar[6] = 4.5 * (aa2 / 10.0 + ab2 / 6.0) / r2 / r2;
  scalar[7] = -9.0 / 8.0 / r2 / r;
  scalar[8] = (-4.5 + 5.4 * (aa2 + ab2) / r2) / r2 / r;
  scalar[9] = (2.25 - 3.6 * (aa2 + ab2) / r2) / r2 / r;
  scalar[10] = 0.9 * (aa2 + ab2) / r2 / r2 / r;
}


x86 assembly (clang, -O0):
<scalars_nonewald_poly>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0xb,-0x2c(%rbp)
jge    1149 <scalars_nonewald_poly+0x49>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1121 <scalars_nonewald_poly+0x21>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm1
addsd  -0x48(%rbp),%xmm1
movsd  0xe90(%rip),%xmm0
mulsd  %xmm0,%xmm1
divsd  -0x38(%rbp),%xmm1
movsd  0xe77(%rip),%xmm0
subsd  %xmm1,%xmm0
divsd  -0x10(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm1
addsd  -0x48(%rbp),%xmm1
movsd  0xe4c(%rip),%xmm0
mulsd  %xmm0,%xmm1
divsd  -0x38(%rbp),%xmm1
movsd  0xe33(%rip),%xmm0
addsd  %xmm1,%xmm0
divsd  -0x10(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x8(%rax)
cmpl   $0x0,-0x4(%rbp)
jne    11ee <scalars_nonewald_poly+0xee>
jmp    139c <scalars_nonewald_poly+0x29c>
movsd  0xe32(%rip),%xmm0
divsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x10(%rax)
movsd  0xdf4(%rip),%xmm0
divsd  -0x38(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x18(%rax)
movsd  0xdf9(%rip),%xmm0
divsd  -0x38(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x20(%rax)
cmpl   $0x1,-0x4(%rbp)
jne    1249 <scalars_nonewald_poly+0x149>
jmp    139c <scalars_nonewald_poly+0x29c>
movsd  -0x40(%rbp),%xmm0
movsd  0xe1a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  0xe01(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  0xe01(%rip),%xmm1
mulsd  %xmm0,%xmm1
divsd  -0x38(%rbp),%xmm1
movsd  0xdb0(%rip),%xmm0
subsd  %xmm1,%xmm0
divsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x28(%rax)
movsd  -0x40(%rbp),%xmm1
movsd  0xdc9(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  0xdb0(%rip),%xmm2
divsd  %xmm2,%xmm0
addsd  %xmm0,%xmm1
movsd  0xd98(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x38(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x30(%rax)
movsd  0xd71(%rip),%xmm0
divsd  -0x38(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x38(%rax)
movsd  -0x40(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  0xd44(%rip),%xmm1
mulsd  %xmm0,%xmm1
divsd  -0x38(%rbp),%xmm1
movsd  0xd2b(%rip),%xmm0
addsd  %xmm1,%xmm0
divsd  -0x38(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x40(%rax)
movsd  -0x40(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  0xcfa(%rip),%xmm1
mulsd  %xmm0,%xmm1
divsd  -0x38(%rbp),%xmm1
movsd  0xce1(%rip),%xmm0
subsd  %xmm1,%xmm0
divsd  -0x38(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x48(%rax)
movsd  -0x40(%rbp),%xmm1
addsd  -0x48(%rbp),%xmm1
movsd  0xcb0(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x38(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x50(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<scalars_nonewald_poly>:
xorps  %xmm3,%xmm3
movups %xmm3,0x40(%rsi)
movups %xmm3,0x30(%rsi)
movups %xmm3,0x20(%rsi)
movups %xmm3,0x10(%rsi)
movq   $0x0,0x50(%rsi)
movapd %xmm0,%xmm3
mulsd  %xmm0,%xmm3
mulsd  %xmm1,%xmm1
mulsd  %xmm2,%xmm2
movapd %xmm1,%xmm4
addsd  %xmm2,%xmm4
movapd %xmm4,%xmm5
unpcklpd %xmm4,%xmm5
movapd 0xebd(%rip),%xmm7
mulpd  %xmm5,%xmm7
movapd %xmm3,%xmm9
unpcklpd %xmm3,%xmm9
divpd  %xmm9,%xmm7
movsd  0xf02(%rip),%xmm6
subpd  %xmm7,%xmm6
addpd  0xea6(%rip),%xmm7
movsd  %xmm6,%xmm7
movapd %xmm0,%xmm8
unpcklpd %xmm0,%xmm8
divpd  %xmm8,%xmm7
movupd %xmm7,(%rsi)
test   %edi,%edi
je     1275 <scalars_nonewald_poly+0x175>
movsd  0xed7(%rip),%xmm6
divsd  %xmm3,%xmm6
movapd 0xe83(%rip),%xmm7
unpcklpd %xmm6,%xmm7
movapd %xmm3,%xmm6
unpcklpd %xmm0,%xmm6
divpd  %xmm6,%xmm7
movupd %xmm7,0x10(%rsi)
movsd  0xeb6(%rip),%xmm7
divsd  %xmm3,%xmm7
divsd  %xmm0,%xmm7
movsd  %xmm7,0x20(%rsi)
cmp    $0x1,%edi
je     1275 <scalars_nonewald_poly+0x175>
divsd  0xea0(%rip),%xmm1
divsd  0xea0(%rip),%xmm2
addsd  %xmm1,%xmm2
movsd  0xe9c(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm3,%xmm1
addsd  0xe94(%rip),%xmm1
divsd  %xmm3,%xmm1
movsd  %xmm1,0x28(%rsi)
mulsd  0xe8b(%rip),%xmm2
shufpd $0x2,0xe1a(%rip),%xmm2
divpd  %xmm9,%xmm2
divpd  %xmm6,%xmm2
mulpd  0xe19(%rip),%xmm5
movupd %xmm2,0x30(%rsi)
divpd  %xmm9,%xmm5
movsd  0xe67(%rip),%xmm1
addpd  %xmm5,%xmm1
movapd 0xe0b(%rip),%xmm2
subpd  %xmm5,%xmm2
movsd  %xmm1,%xmm2
divpd  %xmm9,%xmm2
divpd  %xmm8,%xmm2
movupd %xmm2,0x40(%rsi)
mulsd  0xe44(%rip),%xmm4
divsd  %xmm3,%xmm4
divsd  %xmm3,%xmm4
divsd  %xmm0,%xmm4
movsd  %xmm4,0x50(%rsi)
ret

LLVM IR (-O0):
define void @scalars_nonewald_poly(i32 %0, double %1, double %2, double %3, double* %4) {
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double*
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
store i32 %0, i32* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store double* %4, double** %10
store i32 0, i32* %11
br label %15
15: ; preds = %23, %5
%16 = load i32, i32* %11
%17 = icmp slt i32 %16, 11
br i1 %17, label %18, label %26
18: ; preds = %15
%19 = load double*, double** %10
%20 = load i32, i32* %11
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %19, i64 %21
store double 0.000000e+00, double* %22
br label %23
23: ; preds = %18
%24 = load i32, i32* %11
%25 = add nsw i32 %24, 1
store i32 %25, i32* %11
br label %15
26: ; preds = %15
%27 = load double, double* %7
%28 = load double, double* %7
%29 = fmul double %27, %28
store double %29, double* %12
%30 = load double, double* %8
%31 = load double, double* %8
%32 = fmul double %30, %31
store double %32, double* %13
%33 = load double, double* %9
%34 = load double, double* %9
%35 = fmul double %33, %34
store double %35, double* %14
%36 = load double, double* %13
%37 = load double, double* %14
%38 = fadd double %36, %37
%39 = fmul double %38, 5.000000e-01
%40 = load double, double* %12
%41 = fdiv double %39, %40
%42 = fsub double 1.500000e+00, %41
%43 = load double, double* %7
%44 = fdiv double %42, %43
%45 = load double*, double** %10
%46 = getelementptr inbounds double, double* %45, i64 0
store double %44, double* %46
%47 = load double, double* %13
%48 = load double, double* %14
%49 = fadd double %47, %48
%50 = fmul double %49, 2.500000e-01
%51 = load double, double* %12
%52 = fdiv double %50, %51
%53 = fadd double 7.500000e-01, %52
%54 = load double, double* %7
%55 = fdiv double %53, %54
%56 = load double*, double** %10
%57 = getelementptr inbounds double, double* %56, i64 1
store double %55, double* %57
%58 = load i32, i32* %6
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %61
60: ; preds = %26
br label %151
61: ; preds = %26
%62 = load double, double* %12
%63 = fdiv double -7.500000e-01, %62
%64 = load double*, double** %10
%65 = getelementptr inbounds double, double* %64, i64 2
store double %63, double* %65
%66 = load double, double* %12
%67 = fdiv double 7.500000e-01, %66
%68 = load double, double* %7
%69 = fdiv double %67, %68
%70 = load double*, double** %10
%71 = getelementptr inbounds double, double* %70, i64 3
store double %69, double* %71
%72 = load double, double* %12
%73 = fdiv double -3.750000e-01, %72
%74 = load double, double* %7
%75 = fdiv double %73, %74
%76 = load double*, double** %10
%77 = getelementptr inbounds double, double* %76, i64 4
store double %75, double* %77
%78 = load i32, i32* %6
%79 = icmp eq i32 %78, 1
br i1 %79, label %80, label %81
80: ; preds = %61
br label %151
81: ; preds = %61
%82 = load double, double* %13
%83 = fdiv double %82, 1.000000e+01
%84 = load double, double* %14
%85 = fdiv double %84, 6.000000e+00
%86 = fadd double %83, %85
%87 = fmul double 1.350000e+01, %86
%88 = load double, double* %12
%89 = fdiv double %87, %88
%90 = fsub double 2.250000e+00, %89
%91 = load double, double* %12
%92 = fdiv double %90, %91
%93 = load double*, double** %10
%94 = getelementptr inbounds double, double* %93, i64 5
store double %92, double* %94
%95 = load double, double* %13
%96 = fdiv double %95, 1.000000e+01
%97 = load double, double* %14
%98 = fdiv double %97, 6.000000e+00
%99 = fadd double %96, %98
%100 = fmul double 4.500000e+00, %99
%101 = load double, double* %12
%102 = fdiv double %100, %101
%103 = load double, double* %12
%104 = fdiv double %102, %103
%105 = load double*, double** %10
%106 = getelementptr inbounds double, double* %105, i64 6
store double %104, double* %106
%107 = load double, double* %12
%108 = fdiv double -1.125000e+00, %107
%109 = load double, double* %7
%110 = fdiv double %108, %109
%111 = load double*, double** %10
%112 = getelementptr inbounds double, double* %111, i64 7
store double %110, double* %112
%113 = load double, double* %13
%114 = load double, double* %14
%115 = fadd double %113, %114
%116 = fmul double 5.400000e+00, %115
%117 = load double, double* %12
%118 = fdiv double %116, %117
%119 = fadd double -4.500000e+00, %118
%120 = load double, double* %12
%121 = fdiv double %119, %120
%122 = load double, double* %7
%123 = fdiv double %121, %122
%124 = load double*, double** %10
%125 = getelementptr inbounds double, double* %124, i64 8
store double %123, double* %125
%126 = load double, double* %13
%127 = load double, double* %14
%128 = fadd double %126, %127
%129 = fmul double 3.600000e+00, %128
%130 = load double, double* %12
%131 = fdiv double %129, %130
%132 = fsub double 2.250000e+00, %131
%133 = load double, double* %12
%134 = fdiv double %132, %133
%135 = load double, double* %7
%136 = fdiv double %134, %135
%137 = load double*, double** %10
%138 = getelementptr inbounds double, double* %137, i64 9
store double %136, double* %138
%139 = load double, double* %13
%140 = load double, double* %14
%141 = fadd double %139, %140
%142 = fmul double 9.000000e-01, %141
%143 = load double, double* %12
%144 = fdiv double %142, %143
%145 = load double, double* %12
%146 = fdiv double %144, %145
%147 = load double, double* %7
%148 = fdiv double %146, %147
%149 = load double*, double** %10
%150 = getelementptr inbounds double, double* %149, i64 10
store double %148, double* %150
br label %151
151: ; preds = %81, %80, %60
ret void
}

LLVM IR (-O2):
define void @scalars_nonewald_poly(i32 %0, double %1, double %2, double %3, double* nocapture writeonly %4) {
%6 = getelementptr inbounds double, double* %4, i64 2
%7 = bitcast double* %6 to i8*
%8 = fmul double %1, %1
%9 = fmul double %2, %2
%10 = fmul double %3, %3
%11 = fadd double %9, %10
%12 = insertelement <2 x double> poison, double %11, i64 0
%13 = shufflevector <2 x double> %12, <2 x double> poison, <2 x i32> zeroinitializer
%14 = fmul <2 x double> %13, <double 5.000000e-01, double 2.500000e-01>
%15 = insertelement <2 x double> poison, double %8, i64 0
%16 = shufflevector <2 x double> %15, <2 x double> poison, <2 x i32> zeroinitializer
%17 = fdiv <2 x double> %14, %16
%18 = fsub <2 x double> <double 1.500000e+00, double poison>, %17
%19 = fadd <2 x double> %17, <double poison, double 7.500000e-01>
%20 = shufflevector <2 x double> %18, <2 x double> %19, <2 x i32> <i32 0, i32 3>
%21 = insertelement <2 x double> poison, double %1, i64 0
%22 = shufflevector <2 x double> %21, <2 x double> poison, <2 x i32> zeroinitializer
%23 = fdiv <2 x double> %20, %22
%24 = bitcast double* %4 to <2 x double>*
store <2 x double> %23, <2 x double>* %24
%25 = icmp eq i32 %0, 0
br i1 %25, label %67, label %26
26: ; preds = %5
%27 = getelementptr inbounds double, double* %4, i64 2
%28 = fdiv double 7.500000e-01, %8
%29 = insertelement <2 x double> <double -7.500000e-01, double poison>, double %28, i64 1
%30 = insertelement <2 x double> poison, double %1, i64 1
%31 = insertelement <2 x double> %30, double %8, i64 0
%32 = fdiv <2 x double> %29, %31
%33 = bitcast double* %27 to <2 x double>*
store <2 x double> %32, <2 x double>* %33
%34 = fdiv double -3.750000e-01, %8
%35 = fdiv double %34, %1
%36 = getelementptr inbounds double, double* %4, i64 4
store double %35, double* %36
%37 = icmp eq i32 %0, 1
br i1 %37, label %67, label %38
38: ; preds = %26
%39 = fdiv double %9, 1.000000e+01
%40 = fdiv double %10, 6.000000e+00
%41 = fadd double %39, %40
%42 = fmul double %41, 1.350000e+01
%43 = fdiv double %42, %8
%44 = fsub double 2.250000e+00, %43
%45 = fdiv double %44, %8
%46 = getelementptr inbounds double, double* %4, i64 5
store double %45, double* %46
%47 = fmul double %41, 4.500000e+00
%48 = getelementptr inbounds double, double* %4, i64 6
%49 = insertelement <2 x double> <double poison, double -1.125000e+00>, double %47, i64 0
%50 = fdiv <2 x double> %49, %16
%51 = fdiv <2 x double> %50, %31
%52 = bitcast double* %48 to <2 x double>*
store <2 x double> %51, <2 x double>* %52
%53 = getelementptr inbounds double, double* %4, i64 8
%54 = fmul <2 x double> %13, <double 5.400000e+00, double 3.600000e+00>
%55 = fdiv <2 x double> %54, %16
%56 = fadd <2 x double> %55, <double -4.500000e+00, double poison>
%57 = fsub <2 x double> <double poison, double 2.250000e+00>, %55
%58 = shufflevector <2 x double> %56, <2 x double> %57, <2 x i32> <i32 0, i32 3>
%59 = fdiv <2 x double> %58, %16
%60 = fdiv <2 x double> %59, %22
%61 = bitcast double* %53 to <2 x double>*
store <2 x double> %60, <2 x double>* %61
%62 = fmul double %11, 9.000000e-01
%63 = fdiv double %62, %8
%64 = fdiv double %63, %8
%65 = fdiv double %64, %1
%66 = getelementptr inbounds double, double* %4, i64 10
store double %65, double* %66
br label %67
67: ; preds = %26, %5, %38
ret void
}