void jacobi_precond(double *M, double **Adata, int n) {
  int i = 0;
  for (i = 0; i < n; i++) {
    M[i] += Adata[i][i];
  }
}


x86 assembly (clang, -O0):
<jacobi_precond>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    115e <jacobi_precond+0x5e>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    111d <jacobi_precond+0x1d>
pop    %rbp
ret

x86 assembly (clang, -O2):
<jacobi_precond>:
test   %edx,%edx
jle    116c <jacobi_precond+0x6c>
mov    %edx,%r8d
cmp    $0x1,%edx
jne    1110 <jacobi_precond+0x10>
xor    %ecx,%ecx
jmp    1153 <jacobi_precond+0x53>
mov    %r8d,%edx
and    $0xfffffffe,%edx
xor    %ecx,%ecx
nopl   0x0(%rax,%rax,1)
mov    (%rsi,%rcx,8),%rax
movsd  (%rax,%rcx,8),%xmm0
addsd  (%rdi,%rcx,8),%xmm0
movsd  %xmm0,(%rdi,%rcx,8)
mov    0x8(%rsi,%rcx,8),%rax
movsd  0x8(%rax,%rcx,8),%xmm0
addsd  0x8(%rdi,%rcx,8),%xmm0
movsd  %xmm0,0x8(%rdi,%rcx,8)
add    $0x2,%rcx
cmp    %rcx,%rdx
jne    1120 <jacobi_precond+0x20>
test   $0x1,%r8b
je     116c <jacobi_precond+0x6c>
mov    (%rsi,%rcx,8),%rax
movsd  (%rax,%rcx,8),%xmm0
addsd  (%rdi,%rcx,8),%xmm0
movsd  %xmm0,(%rdi,%rcx,8)
ret

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

LLVM IR (-O2):
define void @jacobi_precond(double* nocapture %0, double** nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %43
5: ; preds = %3
%6 = zext i32 %2 to i64
%7 = and i64 %6, 1
%8 = icmp eq i32 %2, 1
br i1 %8, label %32, label %9
9: ; preds = %5
%10 = and i64 %6, 4294967294
br label %11
11: ; preds = %11, %9
%12 = phi i64 [ 0, %9 ], [ %29, %11 ]
%13 = phi i64 [ 0, %9 ], [ %30, %11 ]
%14 = getelementptr inbounds double*, double** %1, i64 %12
%15 = load double*, double** %14
%16 = getelementptr inbounds double, double* %15, i64 %12
%17 = load double, double* %16
%18 = getelementptr inbounds double, double* %0, i64 %12
%19 = load double, double* %18
%20 = fadd double %17, %19
store double %20, double* %18
%21 = or i64 %12, 1
%22 = getelementptr inbounds double*, double** %1, i64 %21
%23 = load double*, double** %22
%24 = getelementptr inbounds double, double* %23, i64 %21
%25 = load double, double* %24
%26 = getelementptr inbounds double, double* %0, i64 %21
%27 = load double, double* %26
%28 = fadd double %25, %27
store double %28, double* %26
%29 = add nuw nsw i64 %12, 2
%30 = add i64 %13, 2
%31 = icmp eq i64 %30, %10
br i1 %31, label %32, label %11
32: ; preds = %11, %5
%33 = phi i64 [ 0, %5 ], [ %29, %11 ]
%34 = icmp eq i64 %7, 0
br i1 %34, label %43, label %35
35: ; preds = %32
%36 = getelementptr inbounds double*, double** %1, i64 %33
%37 = load double*, double** %36
%38 = getelementptr inbounds double, double* %37, i64 %33
%39 = load double, double* %38
%40 = getelementptr inbounds double, double* %0, i64 %33
%41 = load double, double* %40
%42 = fadd double %39, %41
store double %42, double* %40
br label %43
43: ; preds = %35, %32, %3
ret void
}