double dot_real(double *vect_1, double *vect_2, int n) {
  double *fstop;
  double sum;
  sum = 0.0;
  fstop = vect_1 + n;
  for (; vect_1 < fstop; vect_1++, vect_2++)
    sum += (*vect_1 * *vect_2);
  return (sum);
}


x86 assembly (clang, -O0):
<dot_real>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1177 <dot_real+0x77>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    112a <dot_real+0x2a>
movsd  -0x28(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<dot_real>:
test   %edx,%edx
jle    112a <dot_real+0x2a>
movslq %edx,%rax
lea    (%rdi,%rax,8),%rax
xorpd  %xmm0,%xmm0
nop
movsd  (%rdi),%xmm1
mulsd  (%rsi),%xmm1
addsd  %xmm1,%xmm0
add    $0x8,%rdi
add    $0x8,%rsi
cmp    %rax,%rdi
jb     1110 <dot_real+0x10>
ret
xorps  %xmm0,%xmm0
ret

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

LLVM IR (-O2):
define double @dot_real(double* %0, double* nocapture %1, i32 %2) {
%4 = sext i32 %2 to i64
%5 = getelementptr inbounds double, double* %0, i64 %4
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %17
7: ; preds = %3, %7
%8 = phi double [ %13, %7 ], [ 0.000000e+00, %3 ]
%9 = phi double* [ %14, %7 ], [ %0, %3 ]
%10 = phi double* [ %15, %7 ], [ %1, %3 ]
%11 = load double, double* %9
%12 = load double, double* %10
%13 = tail call double @llvm.fmuladd.f64(double %11, double %12, double %8)
%14 = getelementptr inbounds double, double* %9, i64 1
%15 = getelementptr inbounds double, double* %10, i64 1
%16 = icmp ult double* %14, %5
br i1 %16, label %7, label %17
17: ; preds = %7, %3
%18 = phi double [ 0.000000e+00, %3 ], [ %13, %7 ]
ret double %18
}