void dampVector(double *vector, double damp, unsigned size) {
  unsigned i;
  const double addFactor = damp / size;
  const double multiplyFactor = 1 - damp;
  for (i = 0; i < size; i++) {
    vector[i] = multiplyFactor * vector[i] + addFactor;
  }
}


x86 assembly (clang, -O0):
<dampVector>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%eax
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xed2(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1183 <dampVector+0x83>
movsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113f <dampVector+0x3f>
pop    %rbp
ret

x86 assembly (clang, -O2):
<dampVector>:
test   %esi,%esi
je     121b <dampVector+0x11b>
mov    %esi,%eax
cvtsi2sd %rax,%xmm2
movsd  0xee9(%rip),%xmm1
subsd  %xmm0,%xmm1
divsd  %xmm2,%xmm0
cmp    $0x4,%esi
jae    112b <dampVector+0x2b>
xor    %ecx,%ecx
jmp    1200 <dampVector+0x100>
mov    %eax,%ecx
and    $0xfffffffc,%ecx
movapd %xmm1,%xmm2
unpcklpd %xmm1,%xmm2
movapd %xmm0,%xmm3
unpcklpd %xmm0,%xmm3
lea    -0x4(%rcx),%rdx
mov    %rdx,%r8
shr    $0x2,%r8
add    $0x1,%r8
test   %rdx,%rdx
je     121c <dampVector+0x11c>
mov    %r8,%rsi
and    $0xfffffffffffffffe,%rsi
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movupd (%rdi,%rdx,8),%xmm4
movupd 0x10(%rdi,%rdx,8),%xmm5
movupd 0x20(%rdi,%rdx,8),%xmm6
movupd 0x30(%rdi,%rdx,8),%xmm7
mulpd  %xmm2,%xmm4
addpd  %xmm3,%xmm4
mulpd  %xmm2,%xmm5
addpd  %xmm3,%xmm5
movupd %xmm4,(%rdi,%rdx,8)
movupd %xmm5,0x10(%rdi,%rdx,8)
mulpd  %xmm2,%xmm6
addpd  %xmm3,%xmm6
mulpd  %xmm2,%xmm7
addpd  %xmm3,%xmm7
movupd %xmm6,0x20(%rdi,%rdx,8)
movupd %xmm7,0x30(%rdi,%rdx,8)
add    $0x8,%rdx
add    $0xfffffffffffffffe,%rsi
jne    1170 <dampVector+0x70>
test   $0x1,%r8b
je     11f4 <dampVector+0xf4>
movupd (%rdi,%rdx,8),%xmm4
movupd 0x10(%rdi,%rdx,8),%xmm5
mulpd  %xmm2,%xmm4
addpd  %xmm3,%xmm4
mulpd  %xmm2,%xmm5
addpd  %xmm3,%xmm5
movupd %xmm4,(%rdi,%rdx,8)
movupd %xmm5,0x10(%rdi,%rdx,8)
cmp    %rax,%rcx
je     121b <dampVector+0x11b>
nopl   0x0(%rax)
movsd  (%rdi,%rcx,8),%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm0,%xmm2
movsd  %xmm2,(%rdi,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1200 <dampVector+0x100>
ret
xor    %edx,%edx
test   $0x1,%r8b
jne    11ce <dampVector+0xce>
jmp    11f4 <dampVector+0xf4>

LLVM IR (-O0):
define void @dampVector(double* %0, double %1, i32 %2) {
%4 = alloca double*
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca double
store double* %0, double** %4
store double %1, double* %5
store i32 %2, i32* %6
%10 = load double, double* %5
%11 = load i32, i32* %6
%12 = uitofp i32 %11 to double
%13 = fdiv double %10, %12
store double %13, double* %8
%14 = load double, double* %5
%15 = fsub double 1.000000e+00, %14
store double %15, double* %9
store i32 0, i32* %7
br label %16
16: ; preds = %33, %3
%17 = load i32, i32* %7
%18 = load i32, i32* %6
%19 = icmp ult i32 %17, %18
br i1 %19, label %20, label %36
20: ; preds = %16
%21 = load double, double* %9
%22 = load double*, double** %4
%23 = load i32, i32* %7
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds double, double* %22, i64 %24
%26 = load double, double* %25
%27 = load double, double* %8
%28 = call double @llvm.fmuladd.f64(double %21, double %26, double %27)
%29 = load double*, double** %4
%30 = load i32, i32* %7
%31 = zext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
store double %28, double* %32
br label %33
33: ; preds = %20
%34 = load i32, i32* %7
%35 = add i32 %34, 1
store i32 %35, i32* %7
br label %16
36: ; preds = %16
ret void
}

LLVM IR (-O2):
define void @dampVector(double* nocapture %0, double %1, i32 %2) {
%4 = uitofp i32 %2 to double
%5 = fdiv double %1, %4
%6 = fsub double 1.000000e+00, %1
%7 = icmp eq i32 %2, 0
br i1 %7, label %80, label %8
8: ; preds = %3
%9 = zext i32 %2 to i64
%10 = icmp ult i32 %2, 4
br i1 %10, label %71, label %11
11: ; preds = %8
%12 = and i64 %9, 4294967292
%13 = insertelement <2 x double> poison, double %6, i64 0
%14 = shufflevector <2 x double> %13, <2 x double> poison, <2 x i32> zeroinitializer
%15 = insertelement <2 x double> poison, double %5, i64 0
%16 = shufflevector <2 x double> %15, <2 x double> poison, <2 x i32> zeroinitializer
%17 = insertelement <2 x double> poison, double %6, i64 0
%18 = shufflevector <2 x double> %17, <2 x double> poison, <2 x i32> zeroinitializer
%19 = insertelement <2 x double> poison, double %5, i64 0
%20 = shufflevector <2 x double> %19, <2 x double> poison, <2 x i32> zeroinitializer
%21 = add nsw i64 %12, -4
%22 = lshr exact i64 %21, 2
%23 = add nuw nsw i64 %22, 1
%24 = and i64 %23, 1
%25 = icmp eq i64 %21, 0
br i1 %25, label %55, label %26
26: ; preds = %11
%27 = and i64 %23, 9223372036854775806
br label %28
28: ; preds = %28, %26
%29 = phi i64 [ 0, %26 ], [ %52, %28 ]
%30 = phi i64 [ 0, %26 ], [ %53, %28 ]
%31 = getelementptr inbounds double, double* %0, i64 %29
%32 = bitcast double* %31 to <2 x double>*
%33 = load <2 x double>, <2 x double>* %32
%34 = getelementptr inbounds double, double* %31, i64 2
%35 = bitcast double* %34 to <2 x double>*
%36 = load <2 x double>, <2 x double>* %35
%37 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %14, <2 x double> %33, <2 x double> %16)
%38 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %18, <2 x double> %36, <2 x double> %20)
%39 = bitcast double* %31 to <2 x double>*
store <2 x double> %37, <2 x double>* %39
%40 = bitcast double* %34 to <2 x double>*
store <2 x double> %38, <2 x double>* %40
%41 = or i64 %29, 4
%42 = getelementptr inbounds double, double* %0, i64 %41
%43 = bitcast double* %42 to <2 x double>*
%44 = load <2 x double>, <2 x double>* %43
%45 = getelementptr inbounds double, double* %42, i64 2
%46 = bitcast double* %45 to <2 x double>*
%47 = load <2 x double>, <2 x double>* %46
%48 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %14, <2 x double> %44, <2 x double> %16)
%49 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %18, <2 x double> %47, <2 x double> %20)
%50 = bitcast double* %42 to <2 x double>*
store <2 x double> %48, <2 x double>* %50
%51 = bitcast double* %45 to <2 x double>*
store <2 x double> %49, <2 x double>* %51
%52 = add nuw i64 %29, 8
%53 = add i64 %30, 2
%54 = icmp eq i64 %53, %27
br i1 %54, label %55, label %28
55: ; preds = %28, %11
%56 = phi i64 [ 0, %11 ], [ %52, %28 ]
%57 = icmp eq i64 %24, 0
br i1 %57, label %69, label %58
58: ; preds = %55
%59 = getelementptr inbounds double, double* %0, i64 %56
%60 = bitcast double* %59 to <2 x double>*
%61 = load <2 x double>, <2 x double>* %60
%62 = getelementptr inbounds double, double* %59, i64 2
%63 = bitcast double* %62 to <2 x double>*
%64 = load <2 x double>, <2 x double>* %63
%65 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %14, <2 x double> %61, <2 x double> %16)
%66 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %18, <2 x double> %64, <2 x double> %20)
%67 = bitcast double* %59 to <2 x double>*
store <2 x double> %65, <2 x double>* %67
%68 = bitcast double* %62 to <2 x double>*
store <2 x double> %66, <2 x double>* %68
br label %69
69: ; preds = %55, %58
%70 = icmp eq i64 %12, %9
br i1 %70, label %80, label %71
71: ; preds = %8, %69
%72 = phi i64 [ 0, %8 ], [ %12, %69 ]
br label %73
73: ; preds = %71, %73
%74 = phi i64 [ %78, %73 ], [ %72, %71 ]
%75 = getelementptr inbounds double, double* %0, i64 %74
%76 = load double, double* %75
%77 = tail call double @llvm.fmuladd.f64(double %6, double %76, double %5)
store double %77, double* %75
%78 = add nuw nsw i64 %74, 1
%79 = icmp eq i64 %78, %9
br i1 %79, label %80, label %73
80: ; preds = %73, %69, %3
ret void
}