void gll_lag_03(double *restrict p, double *restrict w, unsigned n, int d,
                double xh) {
  const double x = xh * 2;
  const double d00 = x + 2, d01 = x, d02 = x - 2;
  const double u0_01 = 1 * d00, u0_02 = u0_01 * d01;
  const double v0_01 = d02 * 1, v0_00 = d01 * v0_01;
  p[0] = w[0] * 1 * v0_00;
  p[1] = w[1] * u0_01 * v0_01;
  p[2] = w[2] * u0_02 * 1;
  if (d > 0) {
    const double u1_02 = 1 * d01 + u0_01;
    const double v1_00 = d01 * 1 + v0_01;
    p[3 + 0] = 2 * w[0] * (v1_00);
    p[3 + 1] = 2 * w[1] * (1 * v0_01 + u0_01 * 1);
    p[3 + 2] = 2 * w[2] * (u1_02);
    if (d > 1) {
      p[2 * 3 + 0] = 4 * w[0] * (+1 * 2);
      p[2 * 3 + 1] = 4 * w[1] * (+2 * 1 * 1);
      p[2 * 3 + 2] = 4 * w[2] * (2 * 1);
    }
  }
}


x86 assembly (clang, -O0):
<gll_lag_03>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  0xee9(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xed7(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xeb6(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe9d(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe7c(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x10(%rbp),%rax
movsd  0xe57(%rip),%xmm0
mulsd  (%rax),%xmm0
mulsd  -0x60(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mulsd  -0x48(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  0xe14(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
cmpl   $0x0,-0x18(%rbp)
jle    131a <gll_lag_03+0x21a>
movsd  -0x38(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x10(%rbp),%rax
movsd  0xdd3(%rip),%xmm0
mulsd  (%rax),%xmm0
mulsd  -0x70(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x18(%rax)
mov    -0x10(%rbp),%rax
movsd  0xdb5(%rip),%xmm0
mulsd  0x8(%rax),%xmm0
movsd  -0x58(%rbp),%xmm1
movsd  0xd9b(%rip),%xmm2
mulsd  -0x48(%rbp),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x10(%rbp),%rax
movsd  0xd81(%rip),%xmm0
mulsd  0x10(%rax),%xmm0
mulsd  -0x68(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x28(%rax)
cmpl   $0x1,-0x18(%rbp)
jle    1315 <gll_lag_03+0x215>
mov    -0x10(%rbp),%rax
movsd  0xd60(%rip),%xmm0
mulsd  (%rax),%xmm0
movsd  0xd4c(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x30(%rax)
mov    -0x10(%rbp),%rax
movsd  0xd3b(%rip),%xmm0
mulsd  0x8(%rax),%xmm0
movsd  0xd26(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x38(%rax)
mov    -0x10(%rbp),%rax
movsd  0xd15(%rip),%xmm0
mulsd  0x10(%rax),%xmm0
movsd  0xd00(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x40(%rax)
jmp    131a <gll_lag_03+0x21a>
pop    %rbp
ret

x86 assembly (clang, -O2):
<gll_lag_03>:
addsd  %xmm0,%xmm0
movsd  0xef4(%rip),%xmm4
addsd  %xmm0,%xmm4
movsd  0xef0(%rip),%xmm3
addsd  %xmm0,%xmm3
movapd %xmm0,%xmm6
mulsd  %xmm4,%xmm6
movupd (%rsi),%xmm1
movapd %xmm0,%xmm5
unpcklpd %xmm4,%xmm5
movapd %xmm1,%xmm2
movsd  %xmm3,%xmm2
mulpd  %xmm5,%xmm2
movapd %xmm1,%xmm7
unpcklpd %xmm3,%xmm7
mulpd  %xmm2,%xmm7
movupd %xmm7,(%rdi)
movsd  0x10(%rsi),%xmm2
mulsd  %xmm2,%xmm6
movsd  %xmm6,0x10(%rdi)
test   %ecx,%ecx
jle    11b3 <gll_lag_03+0xb3>
addsd  %xmm4,%xmm0
movapd %xmm1,%xmm4
addpd  %xmm1,%xmm4
unpcklpd %xmm3,%xmm3
addpd  %xmm3,%xmm5
mulpd  %xmm4,%xmm5
movupd %xmm5,0x18(%rdi)
movapd %xmm2,%xmm3
addsd  %xmm2,%xmm3
mulsd  %xmm0,%xmm3
movsd  %xmm3,0x28(%rdi)
cmp    $0x1,%ecx
je     11b3 <gll_lag_03+0xb3>
mulpd  0xe87(%rip),%xmm1
addpd  %xmm1,%xmm1
movupd %xmm1,0x30(%rdi)
mulsd  0xe66(%rip),%xmm2
addsd  %xmm2,%xmm2
movsd  %xmm2,0x40(%rdi)
ret

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

LLVM IR (-O2):
define void @gll_lag_03(double* noalias nocapture writeonly %0, double* noalias nocapture %1, i32 %2, i32 %3, double %4) {
%6 = fmul double %4, 2.000000e+00
%7 = fadd double %6, 2.000000e+00
%8 = fadd double %6, -2.000000e+00
%9 = fmul double %6, %7
%10 = bitcast double* %1 to <2 x double>*
%11 = load <2 x double>, <2 x double>* %10
%12 = insertelement <2 x double> poison, double %6, i64 0
%13 = insertelement <2 x double> %12, double %7, i64 1
%14 = insertelement <2 x double> %11, double %8, i64 0
%15 = fmul <2 x double> %13, %14
%16 = insertelement <2 x double> %11, double %8, i64 1
%17 = fmul <2 x double> %15, %16
%18 = bitcast double* %0 to <2 x double>*
store <2 x double> %17, <2 x double>* %18
%19 = getelementptr inbounds double, double* %1, i64 2
%20 = load double, double* %19
%21 = fmul double %9, %20
%22 = getelementptr inbounds double, double* %0, i64 2
store double %21, double* %22
%23 = icmp sgt i32 %3, 0
br i1 %23, label %24, label %45
24: ; preds = %5
%25 = insertelement <2 x double> poison, double %8, i64 0
%26 = fadd double %6, %7
%27 = getelementptr inbounds double, double* %0, i64 3
%28 = fmul <2 x double> %11, <double 2.000000e+00, double 2.000000e+00>
%29 = shufflevector <2 x double> %25, <2 x double> poison, <2 x i32> zeroinitializer
%30 = fadd <2 x double> %13, %29
%31 = fmul <2 x double> %30, %28
%32 = bitcast double* %27 to <2 x double>*
store <2 x double> %31, <2 x double>* %32
%33 = fmul double %20, 2.000000e+00
%34 = fmul double %26, %33
%35 = getelementptr inbounds double, double* %0, i64 5
store double %34, double* %35
%36 = icmp eq i32 %3, 1
br i1 %36, label %45, label %37
37: ; preds = %24
%38 = getelementptr inbounds double, double* %0, i64 6
%39 = fmul <2 x double> %11, <double 4.000000e+00, double 4.000000e+00>
%40 = fmul <2 x double> %39, <double 2.000000e+00, double 2.000000e+00>
%41 = bitcast double* %38 to <2 x double>*
store <2 x double> %40, <2 x double>* %41
%42 = fmul double %20, 4.000000e+00
%43 = fmul double %42, 2.000000e+00
%44 = getelementptr inbounds double, double* %0, i64 8
store double %43, double* %44
br label %45
45: ; preds = %24, %37, %5
ret void
}