void kernel_gesummv(int n, double alpha, double beta,
                    double A[1300 + 0][1300 + 0], double B[1300 + 0][1300 + 0],
                    double tmp[1300 + 0], double x[1300 + 0],
                    double y[1300 + 0]) {
  int i, j;
#pragma scop
  for (i = 0; i < n; i++) {
    tmp[i] = 0.0;
    y[i] = 0.0;
    for (j = 0; j < n; j++) {
      tmp[i] = A[i][j] * x[j] + tmp[i];
      y[i] = B[i][j] * x[j] + y[i];
    }
    y[i] = alpha * tmp[i] + beta * y[i];
  }
#pragma endscop
}


x86 assembly (clang, -O0):
<kernel_gesummv>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
mov    %r9,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1254 <kernel_gesummv+0x154>
mov    -0x30(%rbp),%rax
movslq -0x44(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x40(%rbp),%rax
movslq -0x44(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    120d <kernel_gesummv+0x10d>
mov    -0x20(%rbp),%rax
movslq -0x44(%rbp),%rcx
imul   $0x28a0,%rcx,%rcx
add    %rcx,%rax
movslq -0x48(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x48(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x30(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
movslq -0x44(%rbp),%rcx
imul   $0x28a0,%rcx,%rcx
add    %rcx,%rax
movslq -0x48(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x48(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x40(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x40(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    115f <kernel_gesummv+0x5f>
movsd  -0x10(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x18(%rbp),%xmm1
mov    -0x40(%rbp),%rax
movslq -0x44(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x40(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    112c <kernel_gesummv+0x2c>
pop    %rbp
ret

x86 assembly (clang, -O2):
<kernel_gesummv>:
test   %edi,%edi
jle    1197 <kernel_gesummv+0x97>
mov    %edi,%r10d
xor    %edi,%edi
nopl   (%rax)
movq   $0x0,(%rcx,%rdi,8)
movq   $0x0,(%r9,%rdi,8)
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%rsi,%rax,8),%xmm2
mulsd  (%r8,%rax,8),%xmm2
addsd  (%rcx,%rdi,8),%xmm2
movsd  %xmm2,(%rcx,%rdi,8)
movsd  (%rdx,%rax,8),%xmm2
mulsd  (%r8,%rax,8),%xmm2
addsd  (%r9,%rdi,8),%xmm2
movsd  %xmm2,(%r9,%rdi,8)
add    $0x1,%rax
cmp    %rax,%r10
jne    1130 <kernel_gesummv+0x30>
mulsd  %xmm1,%xmm2
movsd  (%rcx,%rdi,8),%xmm3
mulsd  %xmm0,%xmm3
addsd  %xmm2,%xmm3
movsd  %xmm3,(%r9,%rdi,8)
add    $0x1,%rdi
add    $0x28a0,%rdx
add    $0x28a0,%rsi
cmp    %r10,%rdi
jne    1110 <kernel_gesummv+0x10>
ret

LLVM IR (-O0):
define void @kernel_gesummv(i32 %0, double %1, double %2, [1300 x double]* %3, [1300 x double]* %4, double* %5, double* %6, double* %7) {
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca [1300 x double]*
%13 = alloca [1300 x double]*
%14 = alloca double*
%15 = alloca double*
%16 = alloca double*
%17 = alloca i32
%18 = alloca i32
store i32 %0, i32* %9
store double %1, double* %10
store double %2, double* %11
store [1300 x double]* %3, [1300 x double]** %12
store [1300 x double]* %4, [1300 x double]** %13
store double* %5, double** %14
store double* %6, double** %15
store double* %7, double** %16
store i32 0, i32* %17
br label %19
19: ; preds = %105, %8
%20 = load i32, i32* %17
%21 = load i32, i32* %9
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %108
23: ; preds = %19
%24 = load double*, double** %14
%25 = load i32, i32* %17
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %24, i64 %26
store double 0.000000e+00, double* %27
%28 = load double*, double** %16
%29 = load i32, i32* %17
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %28, i64 %30
store double 0.000000e+00, double* %31
store i32 0, i32* %18
br label %32
32: ; preds = %83, %23
%33 = load i32, i32* %18
%34 = load i32, i32* %9
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %86
36: ; preds = %32
%37 = load [1300 x double]*, [1300 x double]** %12
%38 = load i32, i32* %17
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [1300 x double], [1300 x double]* %37, i64 %39
%41 = load i32, i32* %18
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [1300 x double], [1300 x double]* %40, i64 0, i64 %42
%44 = load double, double* %43
%45 = load double*, double** %15
%46 = load i32, i32* %18
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %45, i64 %47
%49 = load double, double* %48
%50 = load double*, double** %14
%51 = load i32, i32* %17
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds double, double* %50, i64 %52
%54 = load double, double* %53
%55 = call double @llvm.fmuladd.f64(double %44, double %49, double %54)
%56 = load double*, double** %14
%57 = load i32, i32* %17
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %56, i64 %58
store double %55, double* %59
%60 = load [1300 x double]*, [1300 x double]** %13
%61 = load i32, i32* %17
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [1300 x double], [1300 x double]* %60, i64 %62
%64 = load i32, i32* %18
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [1300 x double], [1300 x double]* %63, i64 0, i64 %65
%67 = load double, double* %66
%68 = load double*, double** %15
%69 = load i32, i32* %18
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds double, double* %68, i64 %70
%72 = load double, double* %71
%73 = load double*, double** %16
%74 = load i32, i32* %17
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double, double* %73, i64 %75
%77 = load double, double* %76
%78 = call double @llvm.fmuladd.f64(double %67, double %72, double %77)
%79 = load double*, double** %16
%80 = load i32, i32* %17
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds double, double* %79, i64 %81
store double %78, double* %82
br label %83
83: ; preds = %36
%84 = load i32, i32* %18
%85 = add nsw i32 %84, 1
store i32 %85, i32* %18
br label %32
86: ; preds = %32
%87 = load double, double* %10
%88 = load double*, double** %14
%89 = load i32, i32* %17
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds double, double* %88, i64 %90
%92 = load double, double* %91
%93 = load double, double* %11
%94 = load double*, double** %16
%95 = load i32, i32* %17
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds double, double* %94, i64 %96
%98 = load double, double* %97
%99 = fmul double %93, %98
%100 = call double @llvm.fmuladd.f64(double %87, double %92, double %99)
%101 = load double*, double** %16
%102 = load i32, i32* %17
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds double, double* %101, i64 %103
store double %100, double* %104
br label %105
105: ; preds = %86
%106 = load i32, i32* %17
%107 = add nsw i32 %106, 1
store i32 %107, i32* %17
br label %19
108: ; preds = %19
ret void
}

LLVM IR (-O2):
define void @kernel_gesummv(i32 %0, double %1, double %2, [1300 x double]* nocapture %3, [1300 x double]* nocapture %4, double* nocapture %5, double* nocapture %6, double* nocapture %7) {
%9 = icmp sgt i32 %0, 0
br i1 %9, label %10, label %37
10: ; preds = %8
%11 = zext i32 %0 to i64
br label %12
12: ; preds = %31, %10
%13 = phi i64 [ 0, %10 ], [ %35, %31 ]
%14 = getelementptr inbounds double, double* %5, i64 %13
store double 0.000000e+00, double* %14
%15 = getelementptr inbounds double, double* %7, i64 %13
store double 0.000000e+00, double* %15
br label %16
16: ; preds = %12, %16
%17 = phi i64 [ 0, %12 ], [ %29, %16 ]
%18 = getelementptr inbounds [1300 x double], [1300 x double]* %3, i64 %13, i64 %17
%19 = load double, double* %18
%20 = getelementptr inbounds double, double* %6, i64 %17
%21 = load double, double* %20
%22 = load double, double* %14
%23 = tail call double @llvm.fmuladd.f64(double %19, double %21, double %22)
store double %23, double* %14
%24 = getelementptr inbounds [1300 x double], [1300 x double]* %4, i64 %13, i64 %17
%25 = load double, double* %24
%26 = load double, double* %20
%27 = load double, double* %15
%28 = tail call double @llvm.fmuladd.f64(double %25, double %26, double %27)
store double %28, double* %15
%29 = add nuw nsw i64 %17, 1
%30 = icmp eq i64 %29, %11
br i1 %30, label %31, label %16
31: ; preds = %16
%32 = load double, double* %14
%33 = fmul double %28, %2
%34 = tail call double @llvm.fmuladd.f64(double %1, double %32, double %33)
store double %34, double* %15
%35 = add nuw nsw i64 %13, 1
%36 = icmp eq i64 %35, %11
br i1 %36, label %37, label %12
37: ; preds = %31, %8
ret void
}