void b_power(const double a[2048], double y[2048]) {
  int k;
  for (k = 0; k < 2048; k++) {
    y[k] = a[k] * a[k];
  }
}


x86 assembly (clang, -O0):
<b_power>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x800,-0x14(%rbp)
jge    1155 <b_power+0x55>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1113 <b_power+0x13>
pop    %rbp
ret

x86 assembly (clang, -O2):
<b_power>:
lea    0x4000(%rdi),%rax
cmp    %rsi,%rax
jbe    116c <b_power+0x6c>
lea    0x4000(%rsi),%rax
cmp    %rdi,%rax
jbe    116c <b_power+0x6c>
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
movsd  (%rdi,%rax,8),%xmm0
mulsd  %xmm0,%xmm0
movsd  %xmm0,(%rsi,%rax,8)
movsd  0x8(%rdi,%rax,8),%xmm0
mulsd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsi,%rax,8)
movsd  0x10(%rdi,%rax,8),%xmm0
mulsd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsi,%rax,8)
movsd  0x18(%rdi,%rax,8),%xmm0
mulsd  %xmm0,%xmm0
movsd  %xmm0,0x18(%rsi,%rax,8)
add    $0x4,%rax
cmp    $0x800,%rax
jne    1120 <b_power+0x20>
jmp    11ba <b_power+0xba>
xor    %eax,%eax
xchg   %ax,%ax
movupd (%rdi,%rax,8),%xmm0
movupd 0x10(%rdi,%rax,8),%xmm1
mulpd  %xmm0,%xmm0
mulpd  %xmm1,%xmm1
movupd %xmm0,(%rsi,%rax,8)
movupd %xmm1,0x10(%rsi,%rax,8)
movupd 0x20(%rdi,%rax,8),%xmm0
movupd 0x30(%rdi,%rax,8),%xmm1
mulpd  %xmm0,%xmm0
mulpd  %xmm1,%xmm1
movupd %xmm0,0x20(%rsi,%rax,8)
movupd %xmm1,0x30(%rsi,%rax,8)
add    $0x8,%rax
cmp    $0x800,%rax
jne    1170 <b_power+0x70>
ret

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

LLVM IR (-O2):
define void @b_power(double* nocapture %0, double* nocapture writeonly %1) {
%3 = getelementptr double, double* %1, i64 2048
%4 = getelementptr double, double* %0, i64 2048
%5 = icmp ugt double* %4, %1
%6 = icmp ugt double* %3, %0
%7 = and i1 %5, %6
br i1 %7, label %37, label %8
8: ; preds = %2, %8
%9 = phi i64 [ %35, %8 ], [ 0, %2 ]
%10 = getelementptr inbounds double, double* %0, i64 %9
%11 = bitcast double* %10 to <2 x double>*
%12 = load <2 x double>, <2 x double>* %11
%13 = getelementptr inbounds double, double* %10, i64 2
%14 = bitcast double* %13 to <2 x double>*
%15 = load <2 x double>, <2 x double>* %14
%16 = fmul <2 x double> %12, %12
%17 = fmul <2 x double> %15, %15
%18 = getelementptr inbounds double, double* %1, i64 %9
%19 = bitcast double* %18 to <2 x double>*
store <2 x double> %16, <2 x double>* %19
%20 = getelementptr inbounds double, double* %18, i64 2
%21 = bitcast double* %20 to <2 x double>*
store <2 x double> %17, <2 x double>* %21
%22 = or i64 %9, 4
%23 = getelementptr inbounds double, double* %0, i64 %22
%24 = bitcast double* %23 to <2 x double>*
%25 = load <2 x double>, <2 x double>* %24
%26 = getelementptr inbounds double, double* %23, i64 2
%27 = bitcast double* %26 to <2 x double>*
%28 = load <2 x double>, <2 x double>* %27
%29 = fmul <2 x double> %25, %25
%30 = fmul <2 x double> %28, %28
%31 = getelementptr inbounds double, double* %1, i64 %22
%32 = bitcast double* %31 to <2 x double>*
store <2 x double> %29, <2 x double>* %32
%33 = getelementptr inbounds double, double* %31, i64 2
%34 = bitcast double* %33 to <2 x double>*
store <2 x double> %30, <2 x double>* %34
%35 = add nuw nsw i64 %9, 8
%36 = icmp eq i64 %35, 2048
br i1 %36, label %60, label %8
37: ; preds = %2, %37
%38 = phi i64 [ %58, %37 ], [ 0, %2 ]
%39 = getelementptr inbounds double, double* %0, i64 %38
%40 = load double, double* %39
%41 = fmul double %40, %40
%42 = getelementptr inbounds double, double* %1, i64 %38
store double %41, double* %42
%43 = or i64 %38, 1
%44 = getelementptr inbounds double, double* %0, i64 %43
%45 = load double, double* %44
%46 = fmul double %45, %45
%47 = getelementptr inbounds double, double* %1, i64 %43
store double %46, double* %47
%48 = or i64 %38, 2
%49 = getelementptr inbounds double, double* %0, i64 %48
%50 = load double, double* %49
%51 = fmul double %50, %50
%52 = getelementptr inbounds double, double* %1, i64 %48
store double %51, double* %52
%53 = or i64 %38, 3
%54 = getelementptr inbounds double, double* %0, i64 %53
%55 = load double, double* %54
%56 = fmul double %55, %55
%57 = getelementptr inbounds double, double* %1, i64 %53
store double %56, double* %57
%58 = add nuw nsw i64 %38, 4
%59 = icmp eq i64 %58, 2048
br i1 %59, label %60, label %37
60: ; preds = %8, %37
ret void
}