void daxpy_3l(int n, double da, double *dx, double *dy) {
  int i;
  for (i = 0; i < n; i++) {
    dy[i] += da * dx[i];
  }
}


x86 assembly (clang, -O0):
<daxpy_3l>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1161 <daxpy_3l+0x61>
movsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    111b <daxpy_3l+0x1b>
pop    %rbp
ret

x86 assembly (clang, -O2):
<daxpy_3l>:
test   %edi,%edi
jle    126f <daxpy_3l+0x16f>
mov    %edi,%r9d
cmp    $0x4,%edi
jb     1122 <daxpy_3l+0x22>
lea    (%rsi,%r9,8),%rax
cmp    %rdx,%rax
jbe    1187 <daxpy_3l+0x87>
lea    (%rdx,%r9,8),%rax
cmp    %rsi,%rax
jbe    1187 <daxpy_3l+0x87>
xor    %ecx,%ecx
mov    %rcx,%rax
not    %rax
test   $0x1,%r9b
je     1147 <daxpy_3l+0x47>
movsd  (%rsi,%rcx,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  (%rdx,%rcx,8),%xmm1
movsd  %xmm1,(%rdx,%rcx,8)
or     $0x1,%rcx
add    %r9,%rax
je     126f <daxpy_3l+0x16f>
movsd  (%rsi,%rcx,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  (%rdx,%rcx,8),%xmm1
movsd  %xmm1,(%rdx,%rcx,8)
movsd  0x8(%rsi,%rcx,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  0x8(%rdx,%rcx,8),%xmm1
movsd  %xmm1,0x8(%rdx,%rcx,8)
add    $0x2,%rcx
cmp    %rcx,%r9
jne    1150 <daxpy_3l+0x50>
jmp    126f <daxpy_3l+0x16f>
mov    %r9d,%ecx
and    $0xfffffffc,%ecx
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    -0x4(%rcx),%rax
mov    %rax,%r8
shr    $0x2,%r8
add    $0x1,%r8
test   %rax,%rax
je     1270 <daxpy_3l+0x170>
mov    %r8,%rax
and    $0xfffffffffffffffe,%rax
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
movupd (%rsi,%rdi,8),%xmm2
movupd 0x10(%rsi,%rdi,8),%xmm3
mulpd  %xmm1,%xmm2
movupd (%rdx,%rdi,8),%xmm4
addpd  %xmm2,%xmm4
movupd 0x10(%rdx,%rdi,8),%xmm2
movupd 0x20(%rdx,%rdi,8),%xmm5
movupd 0x30(%rdx,%rdi,8),%xmm6
mulpd  %xmm1,%xmm3
addpd  %xmm2,%xmm3
movupd %xmm4,(%rdx,%rdi,8)
movupd %xmm3,0x10(%rdx,%rdi,8)
movupd 0x20(%rsi,%rdi,8),%xmm2
movupd 0x30(%rsi,%rdi,8),%xmm3
mulpd  %xmm1,%xmm2
addpd  %xmm5,%xmm2
mulpd  %xmm1,%xmm3
addpd  %xmm6,%xmm3
movupd %xmm2,0x20(%rdx,%rdi,8)
movupd %xmm3,0x30(%rdx,%rdi,8)
add    $0x8,%rdi
add    $0xfffffffffffffffe,%rax
jne    11c0 <daxpy_3l+0xc0>
test   $0x1,%r8b
je     1266 <daxpy_3l+0x166>
movupd (%rsi,%rdi,8),%xmm2
movupd 0x10(%rsi,%rdi,8),%xmm3
movupd (%rdx,%rdi,8),%xmm4
movupd 0x10(%rdx,%rdi,8),%xmm5
mulpd  %xmm1,%xmm2
addpd  %xmm4,%xmm2
mulpd  %xmm1,%xmm3
addpd  %xmm5,%xmm3
movupd %xmm2,(%rdx,%rdi,8)
movupd %xmm3,0x10(%rdx,%rdi,8)
cmp    %r9,%rcx
jne    1124 <daxpy_3l+0x24>
ret
xor    %edi,%edi
test   $0x1,%r8b
jne    1235 <daxpy_3l+0x135>
jmp    1266 <daxpy_3l+0x166>

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

LLVM IR (-O2):
define void @daxpy_3l(i32 %0, double %1, double* nocapture %2, double* nocapture %3) {
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %120
6: ; preds = %4
%7 = zext i32 %0 to i64
%8 = icmp ult i32 %0, 4
br i1 %8, label %89, label %9
9: ; preds = %6
%10 = getelementptr double, double* %3, i64 %7
%11 = getelementptr double, double* %2, i64 %7
%12 = icmp ugt double* %11, %3
%13 = icmp ugt double* %10, %2
%14 = and i1 %12, %13
br i1 %14, label %89, label %15
15: ; preds = %9
%16 = and i64 %7, 4294967292
%17 = insertelement <2 x double> poison, double %1, i64 0
%18 = shufflevector <2 x double> %17, <2 x double> poison, <2 x i32> zeroinitializer
%19 = insertelement <2 x double> poison, double %1, i64 0
%20 = shufflevector <2 x double> %19, <2 x double> poison, <2 x i32> zeroinitializer
%21 = add nsw i64 %16, -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 %67, label %26
26: ; preds = %15
%27 = and i64 %23, 9223372036854775806
br label %28
28: ; preds = %28, %26
%29 = phi i64 [ 0, %26 ], [ %64, %28 ]
%30 = phi i64 [ 0, %26 ], [ %65, %28 ]
%31 = getelementptr inbounds double, double* %2, 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 = getelementptr inbounds double, double* %3, i64 %29
%38 = bitcast double* %37 to <2 x double>*
%39 = load <2 x double>, <2 x double>* %38
%40 = getelementptr inbounds double, double* %37, i64 2
%41 = bitcast double* %40 to <2 x double>*
%42 = load <2 x double>, <2 x double>* %41
%43 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %18, <2 x double> %33, <2 x double> %39)
%44 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %20, <2 x double> %36, <2 x double> %42)
%45 = bitcast double* %37 to <2 x double>*
store <2 x double> %43, <2 x double>* %45
%46 = bitcast double* %40 to <2 x double>*
store <2 x double> %44, <2 x double>* %46
%47 = or i64 %29, 4
%48 = getelementptr inbounds double, double* %2, i64 %47
%49 = bitcast double* %48 to <2 x double>*
%50 = load <2 x double>, <2 x double>* %49
%51 = getelementptr inbounds double, double* %48, i64 2
%52 = bitcast double* %51 to <2 x double>*
%53 = load <2 x double>, <2 x double>* %52
%54 = getelementptr inbounds double, double* %3, i64 %47
%55 = bitcast double* %54 to <2 x double>*
%56 = load <2 x double>, <2 x double>* %55
%57 = getelementptr inbounds double, double* %54, i64 2
%58 = bitcast double* %57 to <2 x double>*
%59 = load <2 x double>, <2 x double>* %58
%60 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %18, <2 x double> %50, <2 x double> %56)
%61 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %20, <2 x double> %53, <2 x double> %59)
%62 = bitcast double* %54 to <2 x double>*
store <2 x double> %60, <2 x double>* %62
%63 = bitcast double* %57 to <2 x double>*
store <2 x double> %61, <2 x double>* %63
%64 = add nuw i64 %29, 8
%65 = add i64 %30, 2
%66 = icmp eq i64 %65, %27
br i1 %66, label %67, label %28
67: ; preds = %28, %15
%68 = phi i64 [ 0, %15 ], [ %64, %28 ]
%69 = icmp eq i64 %24, 0
br i1 %69, label %87, label %70
70: ; preds = %67
%71 = getelementptr inbounds double, double* %2, i64 %68
%72 = bitcast double* %71 to <2 x double>*
%73 = load <2 x double>, <2 x double>* %72
%74 = getelementptr inbounds double, double* %71, i64 2
%75 = bitcast double* %74 to <2 x double>*
%76 = load <2 x double>, <2 x double>* %75
%77 = getelementptr inbounds double, double* %3, i64 %68
%78 = bitcast double* %77 to <2 x double>*
%79 = load <2 x double>, <2 x double>* %78
%80 = getelementptr inbounds double, double* %77, i64 2
%81 = bitcast double* %80 to <2 x double>*
%82 = load <2 x double>, <2 x double>* %81
%83 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %18, <2 x double> %73, <2 x double> %79)
%84 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %20, <2 x double> %76, <2 x double> %82)
%85 = bitcast double* %77 to <2 x double>*
store <2 x double> %83, <2 x double>* %85
%86 = bitcast double* %80 to <2 x double>*
store <2 x double> %84, <2 x double>* %86
br label %87
87: ; preds = %67, %70
%88 = icmp eq i64 %16, %7
br i1 %88, label %120, label %89
89: ; preds = %9, %6, %87
%90 = phi i64 [ 0, %9 ], [ 0, %6 ], [ %16, %87 ]
%91 = xor i64 %90, -1
%92 = and i64 %7, 1
%93 = icmp eq i64 %92, 0
br i1 %93, label %101, label %94
94: ; preds = %89
%95 = getelementptr inbounds double, double* %2, i64 %90
%96 = load double, double* %95
%97 = getelementptr inbounds double, double* %3, i64 %90
%98 = load double, double* %97
%99 = tail call double @llvm.fmuladd.f64(double %1, double %96, double %98)
store double %99, double* %97
%100 = or i64 %90, 1
br label %101
101: ; preds = %94, %89
%102 = phi i64 [ %90, %89 ], [ %100, %94 ]
%103 = sub nsw i64 0, %7
%104 = icmp eq i64 %91, %103
br i1 %104, label %120, label %105
105: ; preds = %101, %105
%106 = phi i64 [ %118, %105 ], [ %102, %101 ]
%107 = getelementptr inbounds double, double* %2, i64 %106
%108 = load double, double* %107
%109 = getelementptr inbounds double, double* %3, i64 %106
%110 = load double, double* %109
%111 = tail call double @llvm.fmuladd.f64(double %1, double %108, double %110)
store double %111, double* %109
%112 = add nuw nsw i64 %106, 1
%113 = getelementptr inbounds double, double* %2, i64 %112
%114 = load double, double* %113
%115 = getelementptr inbounds double, double* %3, i64 %112
%116 = load double, double* %115
%117 = tail call double @llvm.fmuladd.f64(double %1, double %114, double %116)
store double %117, double* %115
%118 = add nuw nsw i64 %106, 2
%119 = icmp eq i64 %118, %7
br i1 %119, label %120, label %105
120: ; preds = %101, %105, %87, %4
ret void
}