void axpy(double *z, double alpha, double *x, double beta, double *y, int n) {
  int nn;
  for (nn = 0; nn < n; nn++) {
    z[nn] = alpha * x[nn] + beta * y[nn];
  }
}


x86 assembly (clang, -O0):
<axpy>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %ecx,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1177 <axpy+0x77>
movsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x20(%rbp),%xmm1
mov    -0x28(%rbp),%rax
movslq -0x30(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1124 <axpy+0x24>
pop    %rbp
ret

x86 assembly (clang, -O2):
<axpy>:
test   %ecx,%ecx
jle    12d7 <axpy+0x1d7>
mov    %ecx,%r8d
cmp    $0x4,%ecx
jae    1197 <axpy+0x97>
xor    %ecx,%ecx
mov    %rcx,%rax
not    %rax
test   $0x1,%r8b
je     1141 <axpy+0x41>
movsd  (%rdx,%rcx,8),%xmm2
mulsd  %xmm1,%xmm2
movsd  (%rsi,%rcx,8),%xmm3
mulsd  %xmm0,%xmm3
addsd  %xmm2,%xmm3
movsd  %xmm3,(%rdi,%rcx,8)
or     $0x1,%rcx
add    %r8,%rax
je     12d7 <axpy+0x1d7>
nopw   0x0(%rax,%rax,1)
movsd  (%rdx,%rcx,8),%xmm2
mulsd  %xmm1,%xmm2
movsd  (%rsi,%rcx,8),%xmm3
mulsd  %xmm0,%xmm3
addsd  %xmm2,%xmm3
movsd  %xmm3,(%rdi,%rcx,8)
movsd  0x8(%rdx,%rcx,8),%xmm2
mulsd  %xmm1,%xmm2
movsd  0x8(%rsi,%rcx,8),%xmm3
mulsd  %xmm0,%xmm3
addsd  %xmm2,%xmm3
movsd  %xmm3,0x8(%rdi,%rcx,8)
add    $0x2,%rcx
cmp    %rcx,%r8
jne    1150 <axpy+0x50>
jmp    12d7 <axpy+0x1d7>
lea    (%rdi,%r8,8),%rcx
lea    (%rsi,%r8,8),%rax
cmp    %rdi,%rax
seta   %r10b
lea    (%rdx,%r8,8),%rax
cmp    %rsi,%rcx
seta   %r11b
cmp    %rdi,%rax
seta   %al
cmp    %rdx,%rcx
seta   %r9b
xor    %ecx,%ecx
test   %r11b,%r10b
jne    1116 <axpy+0x16>
and    %r9b,%al
jne    1116 <axpy+0x16>
mov    %r8d,%ecx
and    $0xfffffffc,%ecx
movapd %xmm1,%xmm3
unpcklpd %xmm1,%xmm3
movapd %xmm0,%xmm2
unpcklpd %xmm0,%xmm2
lea    -0x4(%rcx),%rax
mov    %rax,%r9
shr    $0x2,%r9
add    $0x1,%r9
test   %rax,%rax
je     12d8 <axpy+0x1d8>
mov    %r9,%r10
and    $0xfffffffffffffffe,%r10
xor    %eax,%eax
nopl   0x0(%rax)
movupd (%rsi,%rax,8),%xmm4
movupd 0x10(%rsi,%rax,8),%xmm5
movupd (%rdx,%rax,8),%xmm6
movupd 0x10(%rdx,%rax,8),%xmm7
mulpd  %xmm3,%xmm6
mulpd  %xmm3,%xmm7
mulpd  %xmm2,%xmm4
addpd  %xmm6,%xmm4
mulpd  %xmm2,%xmm5
addpd  %xmm7,%xmm5
movupd %xmm4,(%rdi,%rax,8)
movupd %xmm5,0x10(%rdi,%rax,8)
movupd 0x20(%rsi,%rax,8),%xmm4
movupd 0x30(%rsi,%rax,8),%xmm5
movupd 0x20(%rdx,%rax,8),%xmm6
movupd 0x30(%rdx,%rax,8),%xmm7
mulpd  %xmm3,%xmm6
mulpd  %xmm3,%xmm7
mulpd  %xmm2,%xmm4
addpd  %xmm6,%xmm4
mulpd  %xmm2,%xmm5
addpd  %xmm7,%xmm5
movupd %xmm4,0x20(%rdi,%rax,8)
movupd %xmm5,0x30(%rdi,%rax,8)
add    $0x8,%rax
add    $0xfffffffffffffffe,%r10
jne    1210 <axpy+0x110>
test   $0x1,%r9b
je     12ce <axpy+0x1ce>
movupd (%rsi,%rax,8),%xmm4
movupd 0x10(%rsi,%rax,8),%xmm5
movupd (%rdx,%rax,8),%xmm6
movupd 0x10(%rdx,%rax,8),%xmm7
mulpd  %xmm3,%xmm6
mulpd  %xmm3,%xmm7
mulpd  %xmm2,%xmm4
addpd  %xmm6,%xmm4
mulpd  %xmm2,%xmm5
addpd  %xmm7,%xmm5
movupd %xmm4,(%rdi,%rax,8)
movupd %xmm5,0x10(%rdi,%rax,8)
cmp    %r8,%rcx
jne    1116 <axpy+0x16>
ret
xor    %eax,%eax
test   $0x1,%r9b
jne    1295 <axpy+0x195>
jmp    12ce <axpy+0x1ce>

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

LLVM IR (-O2):
define void @axpy(double* nocapture writeonly %0, double %1, double* nocapture %2, double %3, double* nocapture %4, i32 %5) {
%7 = icmp sgt i32 %5, 0
br i1 %7, label %8, label %149
8: ; preds = %6
%9 = zext i32 %5 to i64
%10 = icmp ult i32 %5, 4
br i1 %10, label %112, label %11
11: ; preds = %8
%12 = getelementptr double, double* %0, i64 %9
%13 = getelementptr double, double* %2, i64 %9
%14 = getelementptr double, double* %4, i64 %9
%15 = icmp ugt double* %13, %0
%16 = icmp ugt double* %12, %2
%17 = and i1 %15, %16
%18 = icmp ugt double* %14, %0
%19 = icmp ugt double* %12, %4
%20 = and i1 %18, %19
%21 = or i1 %17, %20
br i1 %21, label %112, label %22
22: ; preds = %11
%23 = and i64 %9, 4294967292
%24 = insertelement <2 x double> poison, double %3, i64 0
%25 = shufflevector <2 x double> %24, <2 x double> poison, <2 x i32> zeroinitializer
%26 = insertelement <2 x double> poison, double %3, i64 0
%27 = shufflevector <2 x double> %26, <2 x double> poison, <2 x i32> zeroinitializer
%28 = insertelement <2 x double> poison, double %1, i64 0
%29 = shufflevector <2 x double> %28, <2 x double> poison, <2 x i32> zeroinitializer
%30 = insertelement <2 x double> poison, double %1, i64 0
%31 = shufflevector <2 x double> %30, <2 x double> poison, <2 x i32> zeroinitializer
%32 = add nsw i64 %23, -4
%33 = lshr exact i64 %32, 2
%34 = add nuw nsw i64 %33, 1
%35 = and i64 %34, 1
%36 = icmp eq i64 %32, 0
br i1 %36, label %86, label %37
37: ; preds = %22
%38 = and i64 %34, 9223372036854775806
br label %39
39: ; preds = %39, %37
%40 = phi i64 [ 0, %37 ], [ %83, %39 ]
%41 = phi i64 [ 0, %37 ], [ %84, %39 ]
%42 = getelementptr inbounds double, double* %2, i64 %40
%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 = getelementptr inbounds double, double* %4, i64 %40
%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 = fmul <2 x double> %50, %25
%55 = fmul <2 x double> %53, %27
%56 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %29, <2 x double> %44, <2 x double> %54)
%57 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %31, <2 x double> %47, <2 x double> %55)
%58 = getelementptr inbounds double, double* %0, i64 %40
%59 = bitcast double* %58 to <2 x double>*
store <2 x double> %56, <2 x double>* %59
%60 = getelementptr inbounds double, double* %58, i64 2
%61 = bitcast double* %60 to <2 x double>*
store <2 x double> %57, <2 x double>* %61
%62 = or i64 %40, 4
%63 = getelementptr inbounds double, double* %2, i64 %62
%64 = bitcast double* %63 to <2 x double>*
%65 = load <2 x double>, <2 x double>* %64
%66 = getelementptr inbounds double, double* %63, i64 2
%67 = bitcast double* %66 to <2 x double>*
%68 = load <2 x double>, <2 x double>* %67
%69 = getelementptr inbounds double, double* %4, i64 %62
%70 = bitcast double* %69 to <2 x double>*
%71 = load <2 x double>, <2 x double>* %70
%72 = getelementptr inbounds double, double* %69, i64 2
%73 = bitcast double* %72 to <2 x double>*
%74 = load <2 x double>, <2 x double>* %73
%75 = fmul <2 x double> %71, %25
%76 = fmul <2 x double> %74, %27
%77 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %29, <2 x double> %65, <2 x double> %75)
%78 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %31, <2 x double> %68, <2 x double> %76)
%79 = getelementptr inbounds double, double* %0, i64 %62
%80 = bitcast double* %79 to <2 x double>*
store <2 x double> %77, <2 x double>* %80
%81 = getelementptr inbounds double, double* %79, i64 2
%82 = bitcast double* %81 to <2 x double>*
store <2 x double> %78, <2 x double>* %82
%83 = add nuw i64 %40, 8
%84 = add i64 %41, 2
%85 = icmp eq i64 %84, %38
br i1 %85, label %86, label %39
86: ; preds = %39, %22
%87 = phi i64 [ 0, %22 ], [ %83, %39 ]
%88 = icmp eq i64 %35, 0
br i1 %88, label %110, label %89
89: ; preds = %86
%90 = getelementptr inbounds double, double* %2, i64 %87
%91 = bitcast double* %90 to <2 x double>*
%92 = load <2 x double>, <2 x double>* %91
%93 = getelementptr inbounds double, double* %90, i64 2
%94 = bitcast double* %93 to <2 x double>*
%95 = load <2 x double>, <2 x double>* %94
%96 = getelementptr inbounds double, double* %4, i64 %87
%97 = bitcast double* %96 to <2 x double>*
%98 = load <2 x double>, <2 x double>* %97
%99 = getelementptr inbounds double, double* %96, i64 2
%100 = bitcast double* %99 to <2 x double>*
%101 = load <2 x double>, <2 x double>* %100
%102 = fmul <2 x double> %98, %25
%103 = fmul <2 x double> %101, %27
%104 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %29, <2 x double> %92, <2 x double> %102)
%105 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %31, <2 x double> %95, <2 x double> %103)
%106 = getelementptr inbounds double, double* %0, i64 %87
%107 = bitcast double* %106 to <2 x double>*
store <2 x double> %104, <2 x double>* %107
%108 = getelementptr inbounds double, double* %106, i64 2
%109 = bitcast double* %108 to <2 x double>*
store <2 x double> %105, <2 x double>* %109
br label %110
110: ; preds = %86, %89
%111 = icmp eq i64 %23, %9
br i1 %111, label %149, label %112
112: ; preds = %11, %8, %110
%113 = phi i64 [ 0, %11 ], [ 0, %8 ], [ %23, %110 ]
%114 = xor i64 %113, -1
%115 = and i64 %9, 1
%116 = icmp eq i64 %115, 0
br i1 %116, label %126, label %117
117: ; preds = %112
%118 = getelementptr inbounds double, double* %2, i64 %113
%119 = load double, double* %118
%120 = getelementptr inbounds double, double* %4, i64 %113
%121 = load double, double* %120
%122 = fmul double %121, %3
%123 = tail call double @llvm.fmuladd.f64(double %1, double %119, double %122)
%124 = getelementptr inbounds double, double* %0, i64 %113
store double %123, double* %124
%125 = or i64 %113, 1
br label %126
126: ; preds = %117, %112
%127 = phi i64 [ %113, %112 ], [ %125, %117 ]
%128 = sub nsw i64 0, %9
%129 = icmp eq i64 %114, %128
br i1 %129, label %149, label %130
130: ; preds = %126, %130
%131 = phi i64 [ %147, %130 ], [ %127, %126 ]
%132 = getelementptr inbounds double, double* %2, i64 %131
%133 = load double, double* %132
%134 = getelementptr inbounds double, double* %4, i64 %131
%135 = load double, double* %134
%136 = fmul double %135, %3
%137 = tail call double @llvm.fmuladd.f64(double %1, double %133, double %136)
%138 = getelementptr inbounds double, double* %0, i64 %131
store double %137, double* %138
%139 = add nuw nsw i64 %131, 1
%140 = getelementptr inbounds double, double* %2, i64 %139
%141 = load double, double* %140
%142 = getelementptr inbounds double, double* %4, i64 %139
%143 = load double, double* %142
%144 = fmul double %143, %3
%145 = tail call double @llvm.fmuladd.f64(double %1, double %141, double %144)
%146 = getelementptr inbounds double, double* %0, i64 %139
store double %145, double* %146
%147 = add nuw nsw i64 %131, 2
%148 = icmp eq i64 %147, %9
br i1 %148, label %149, label %130
149: ; preds = %126, %130, %110, %6
ret void
}