void gll_lag_02(double *restrict p, double *restrict w, unsigned n, int d,
                double xh) {
  const double x = xh * 2;
  const double d00 = x + 2, d01 = x - 2;
  const double u0_01 = 1 * d00;
  const double v0_00 = d01 * 1;
  p[0] = w[0] * 1 * v0_00;
  p[1] = w[1] * u0_01 * 1;
  if (d > 0) {
    p[2 + 0] = 2 * w[0] * (1);
    p[2 + 1] = 2 * w[1] * (1);
    if (d > 1) {
      p[2 * 2 + 0] = 0;
      p[2 * 2 + 1] = 0;
    }
  }
}


x86 assembly (clang, -O0):
<gll_lag_02>:
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  0xec0(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xea7(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe95(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movsd  0xe7f(%rip),%xmm0
mulsd  (%rax),%xmm0
mulsd  -0x48(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  0xe58(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
cmpl   $0x0,-0x18(%rbp)
jle    1231 <gll_lag_02+0x131>
mov    -0x10(%rbp),%rax
movsd  0xe3d(%rip),%xmm0
mulsd  (%rax),%xmm0
movsd  0xe29(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x10(%rbp),%rax
movsd  0xe18(%rip),%xmm0
mulsd  0x8(%rax),%xmm0
movsd  0xe03(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x18(%rax)
cmpl   $0x1,-0x18(%rbp)
jle    122c <gll_lag_02+0x12c>
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x20(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x28(%rax)
jmp    1231 <gll_lag_02+0x131>
pop    %rbp
ret

x86 assembly (clang, -O2):
<gll_lag_02>:
addsd  %xmm0,%xmm0
unpcklpd %xmm0,%xmm0
addpd  0xef0(%rip),%xmm0
movupd (%rsi),%xmm1
mulpd  %xmm1,%xmm0
movupd %xmm0,(%rdi)
test   %ecx,%ecx
jle    1137 <gll_lag_02+0x37>
addpd  %xmm1,%xmm1
movupd %xmm1,0x10(%rdi)
cmp    $0x1,%ecx
je     1137 <gll_lag_02+0x37>
xorpd  %xmm0,%xmm0
movupd %xmm0,0x20(%rdi)
ret

LLVM IR (-O0):
define void @gll_lag_02(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
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
%16 = load double, double* %10
%17 = fmul double %16, 2.000000e+00
store double %17, double* %11
%18 = load double, double* %11
%19 = fadd double %18, 2.000000e+00
store double %19, double* %12
%20 = load double, double* %11
%21 = fsub double %20, 2.000000e+00
store double %21, double* %13
%22 = load double, double* %12
%23 = fmul double 1.000000e+00, %22
store double %23, double* %14
%24 = load double, double* %13
%25 = fmul double %24, 1.000000e+00
store double %25, double* %15
%26 = load double*, double** %7
%27 = getelementptr inbounds double, double* %26, i64 0
%28 = load double, double* %27
%29 = fmul double %28, 1.000000e+00
%30 = load double, double* %15
%31 = fmul double %29, %30
%32 = load double*, double** %6
%33 = getelementptr inbounds double, double* %32, i64 0
store double %31, double* %33
%34 = load double*, double** %7
%35 = getelementptr inbounds double, double* %34, i64 1
%36 = load double, double* %35
%37 = load double, double* %14
%38 = fmul double %36, %37
%39 = fmul double %38, 1.000000e+00
%40 = load double*, double** %6
%41 = getelementptr inbounds double, double* %40, i64 1
store double %39, double* %41
%42 = load i32, i32* %9
%43 = icmp sgt i32 %42, 0
br i1 %43, label %44, label %67
44: ; preds = %5
%45 = load double*, double** %7
%46 = getelementptr inbounds double, double* %45, i64 0
%47 = load double, double* %46
%48 = fmul double 2.000000e+00, %47
%49 = fmul double %48, 1.000000e+00
%50 = load double*, double** %6
%51 = getelementptr inbounds double, double* %50, i64 2
store double %49, double* %51
%52 = load double*, double** %7
%53 = getelementptr inbounds double, double* %52, i64 1
%54 = load double, double* %53
%55 = fmul double 2.000000e+00, %54
%56 = fmul double %55, 1.000000e+00
%57 = load double*, double** %6
%58 = getelementptr inbounds double, double* %57, i64 3
store double %56, double* %58
%59 = load i32, i32* %9
%60 = icmp sgt i32 %59, 1
br i1 %60, label %61, label %66
61: ; preds = %44
%62 = load double*, double** %6
%63 = getelementptr inbounds double, double* %62, i64 4
store double 0.000000e+00, double* %63
%64 = load double*, double** %6
%65 = getelementptr inbounds double, double* %64, i64 5
store double 0.000000e+00, double* %65
br label %66
66: ; preds = %61, %44
br label %67
67: ; preds = %66, %5
ret void
}

LLVM IR (-O2):
define void @gll_lag_02(double* noalias nocapture writeonly %0, double* noalias nocapture %1, i32 %2, i32 %3, double %4) {
%6 = fmul double %4, 2.000000e+00
%7 = insertelement <2 x double> poison, double %6, i64 0
%8 = shufflevector <2 x double> %7, <2 x double> poison, <2 x i32> zeroinitializer
%9 = fadd <2 x double> %8, <double -2.000000e+00, double 2.000000e+00>
%10 = bitcast double* %1 to <2 x double>*
%11 = load <2 x double>, <2 x double>* %10
%12 = fmul <2 x double> %9, %11
%13 = bitcast double* %0 to <2 x double>*
store <2 x double> %12, <2 x double>* %13
%14 = icmp sgt i32 %3, 0
br i1 %14, label %15, label %23
15: ; preds = %5
%16 = getelementptr inbounds double, double* %0, i64 2
%17 = fmul <2 x double> %11, <double 2.000000e+00, double 2.000000e+00>
%18 = bitcast double* %16 to <2 x double>*
store <2 x double> %17, <2 x double>* %18
%19 = icmp eq i32 %3, 1
br i1 %19, label %23, label %20
20: ; preds = %15
%21 = getelementptr inbounds double, double* %0, i64 4
%22 = bitcast double* %21 to i8*
br label %23
23: ; preds = %15, %20, %5
ret void
}