void vec_mult_ref(double *p, double *v1, double *v2) {
  int i;
  for (i = 0; i < 100000; i++)
    p[i] = v1[i] * v2[i];
}


x86 assembly (clang, -O0):
<vec_mult_ref>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x186a0,-0x1c(%rbp)
jge    1159 <vec_mult_ref+0x59>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1117 <vec_mult_ref+0x17>
pop    %rbp
ret

x86 assembly (clang, -O2):
<vec_mult_ref>:
lea    0xc3500(%rsi),%rax
cmp    %rdi,%rax
seta   %r9b
lea    0xc3500(%rdi),%rcx
cmp    %rsi,%rcx
seta   %r10b
lea    0xc3500(%rdx),%rax
cmp    %rdi,%rax
seta   %al
cmp    %rdx,%rcx
seta   %r8b
test   %r10b,%r9b
jne    11a3 <vec_mult_ref+0xa3>
and    %r8b,%al
jne    11a3 <vec_mult_ref+0xa3>
mov    $0x6,%eax
nop
movupd -0x30(%rsi,%rax,8),%xmm0
movupd -0x20(%rsi,%rax,8),%xmm1
movupd -0x30(%rdx,%rax,8),%xmm2
mulpd  %xmm0,%xmm2
movupd -0x20(%rdx,%rax,8),%xmm0
mulpd  %xmm1,%xmm0
movupd %xmm2,-0x30(%rdi,%rax,8)
movupd %xmm0,-0x20(%rdi,%rax,8)
movupd -0x10(%rsi,%rax,8),%xmm0
movupd (%rsi,%rax,8),%xmm1
movupd -0x10(%rdx,%rax,8),%xmm2
mulpd  %xmm0,%xmm2
movupd (%rdx,%rax,8),%xmm0
mulpd  %xmm1,%xmm0
movupd %xmm2,-0x10(%rdi,%rax,8)
movupd %xmm0,(%rdi,%rax,8)
add    $0x8,%rax
cmp    $0x186a6,%rax
jne    1140 <vec_mult_ref+0x40>
jmp    1201 <vec_mult_ref+0x101>
mov    $0x3,%eax
nopl   0x0(%rax,%rax,1)
movsd  -0x18(%rsi,%rax,8),%xmm0
mulsd  -0x18(%rdx,%rax,8),%xmm0
movsd  %xmm0,-0x18(%rdi,%rax,8)
movsd  -0x10(%rsi,%rax,8),%xmm0
mulsd  -0x10(%rdx,%rax,8),%xmm0
movsd  %xmm0,-0x10(%rdi,%rax,8)
movsd  -0x8(%rsi,%rax,8),%xmm0
mulsd  -0x8(%rdx,%rax,8),%xmm0
movsd  %xmm0,-0x8(%rdi,%rax,8)
movsd  (%rsi,%rax,8),%xmm0
mulsd  (%rdx,%rax,8),%xmm0
movsd  %xmm0,(%rdi,%rax,8)
add    $0x4,%rax
cmp    $0x186a3,%rax
jne    11b0 <vec_mult_ref+0xb0>
ret

LLVM IR (-O0):
define void @vec_mult_ref(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
store i32 0, i32* %7
br label %8
8: ; preds = %27, %3
%9 = load i32, i32* %7
%10 = icmp slt i32 %9, 100000
br i1 %10, label %11, label %30
11: ; preds = %8
%12 = load double*, double** %5
%13 = load i32, i32* %7
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds double, double* %12, i64 %14
%16 = load double, double* %15
%17 = load double*, double** %6
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %17, i64 %19
%21 = load double, double* %20
%22 = fmul double %16, %21
%23 = load double*, double** %4
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
store double %22, double* %26
br label %27
27: ; preds = %11
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %8
30: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @vec_mult_ref(double* nocapture writeonly %0, double* nocapture %1, double* nocapture %2) {
%4 = getelementptr double, double* %0, i64 100000
%5 = getelementptr double, double* %1, i64 100000
%6 = getelementptr double, double* %2, i64 100000
%7 = icmp ugt double* %5, %0
%8 = icmp ugt double* %4, %1
%9 = and i1 %7, %8
%10 = icmp ugt double* %6, %0
%11 = icmp ugt double* %4, %2
%12 = and i1 %10, %11
%13 = or i1 %9, %12
br i1 %13, label %55, label %14
14: ; preds = %3, %14
%15 = phi i64 [ %53, %14 ], [ 0, %3 ]
%16 = getelementptr inbounds double, double* %1, i64 %15
%17 = bitcast double* %16 to <2 x double>*
%18 = load <2 x double>, <2 x double>* %17
%19 = getelementptr inbounds double, double* %16, i64 2
%20 = bitcast double* %19 to <2 x double>*
%21 = load <2 x double>, <2 x double>* %20
%22 = getelementptr inbounds double, double* %2, i64 %15
%23 = bitcast double* %22 to <2 x double>*
%24 = load <2 x double>, <2 x double>* %23
%25 = getelementptr inbounds double, double* %22, i64 2
%26 = bitcast double* %25 to <2 x double>*
%27 = load <2 x double>, <2 x double>* %26
%28 = fmul <2 x double> %18, %24
%29 = fmul <2 x double> %21, %27
%30 = getelementptr inbounds double, double* %0, i64 %15
%31 = bitcast double* %30 to <2 x double>*
store <2 x double> %28, <2 x double>* %31
%32 = getelementptr inbounds double, double* %30, i64 2
%33 = bitcast double* %32 to <2 x double>*
store <2 x double> %29, <2 x double>* %33
%34 = or i64 %15, 4
%35 = getelementptr inbounds double, double* %1, i64 %34
%36 = bitcast double* %35 to <2 x double>*
%37 = load <2 x double>, <2 x double>* %36
%38 = getelementptr inbounds double, double* %35, i64 2
%39 = bitcast double* %38 to <2 x double>*
%40 = load <2 x double>, <2 x double>* %39
%41 = getelementptr inbounds double, double* %2, i64 %34
%42 = bitcast double* %41 to <2 x double>*
%43 = load <2 x double>, <2 x double>* %42
%44 = getelementptr inbounds double, double* %41, i64 2
%45 = bitcast double* %44 to <2 x double>*
%46 = load <2 x double>, <2 x double>* %45
%47 = fmul <2 x double> %37, %43
%48 = fmul <2 x double> %40, %46
%49 = getelementptr inbounds double, double* %0, i64 %34
%50 = bitcast double* %49 to <2 x double>*
store <2 x double> %47, <2 x double>* %50
%51 = getelementptr inbounds double, double* %49, i64 2
%52 = bitcast double* %51 to <2 x double>*
store <2 x double> %48, <2 x double>* %52
%53 = add nuw nsw i64 %15, 8
%54 = icmp eq i64 %53, 100000
br i1 %54, label %86, label %14
55: ; preds = %3, %55
%56 = phi i64 [ %84, %55 ], [ 0, %3 ]
%57 = getelementptr inbounds double, double* %1, i64 %56
%58 = load double, double* %57
%59 = getelementptr inbounds double, double* %2, i64 %56
%60 = load double, double* %59
%61 = fmul double %58, %60
%62 = getelementptr inbounds double, double* %0, i64 %56
store double %61, double* %62
%63 = or i64 %56, 1
%64 = getelementptr inbounds double, double* %1, i64 %63
%65 = load double, double* %64
%66 = getelementptr inbounds double, double* %2, i64 %63
%67 = load double, double* %66
%68 = fmul double %65, %67
%69 = getelementptr inbounds double, double* %0, i64 %63
store double %68, double* %69
%70 = or i64 %56, 2
%71 = getelementptr inbounds double, double* %1, i64 %70
%72 = load double, double* %71
%73 = getelementptr inbounds double, double* %2, i64 %70
%74 = load double, double* %73
%75 = fmul double %72, %74
%76 = getelementptr inbounds double, double* %0, i64 %70
store double %75, double* %76
%77 = or i64 %56, 3
%78 = getelementptr inbounds double, double* %1, i64 %77
%79 = load double, double* %78
%80 = getelementptr inbounds double, double* %2, i64 %77
%81 = load double, double* %80
%82 = fmul double %79, %81
%83 = getelementptr inbounds double, double* %0, i64 %77
store double %82, double* %83
%84 = add nuw nsw i64 %56, 4
%85 = icmp eq i64 %84, 100000
br i1 %85, label %86, label %55
86: ; preds = %14, %55
ret void
}