#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
void jacobi(double *T, double *aP, double *aN, double *aS, double *aE,
            double *aW, double *b, int NROWS, int NCOLS, int MAXITER,
            double TOL) {
  int i, j, k;
  int row, col;
  int SIZE;
  int iN, iS, iE, iW;
  double e;
  double *T_new;
  printf("Begin Jacobi solver\n");
  SIZE = NROWS * NCOLS;
  T_new = (double *)malloc(SIZE * sizeof(double));
  printf("ITERATIONS \t ERROR\n");
  k = 0;
  do {
    e = 0;
    for (i = 0; i < SIZE; i++) {
      if (i >= NCOLS && i <= SIZE - NCOLS && i % NCOLS > 0 &&
          i % NCOLS < NCOLS - 1) {
        iN = i - NCOLS;
        iS = i + NCOLS;
        iE = i + 1;
        iW = i - 1;
        T_new[i] =
            (aN[i] * T[iN] + aS[i] * T[iS] + aE[i] * T[iE] + aW[i] * T[iW]) /
            aP[i];
        if (T_new[i] - T[i] > e)
          e = T_new[i] - T[i];
      }
    }
    for (i = 0; i < SIZE; i++) {
      T[i] = T_new[i];
    }
    k++;
    if (k % 1 == 0) {
      printf("%d \t %f\n", k, e);
    }
  } while (e > TOL && k < MAXITER);
  printf("Converged in %d iterations\n", k);
  printf("End Jacobi solver\n\n\n");
  free(T_new);
}


x86 assembly (clang, -O0):
<jacobi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movsd  %xmm0,-0x38(%rbp)
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x18(%rbp),%eax
imul   0x20(%rbp),%eax
mov    %eax,-0x50(%rbp)
movslq -0x50(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x70(%rbp)
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x44(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x50(%rbp),%eax
jge    131c <jacobi+0x1ec>
mov    -0x3c(%rbp),%eax
cmp    0x20(%rbp),%eax
jl     1309 <jacobi+0x1d9>
mov    -0x3c(%rbp),%eax
mov    -0x50(%rbp),%ecx
sub    0x20(%rbp),%ecx
cmp    %ecx,%eax
jg     1309 <jacobi+0x1d9>
mov    -0x3c(%rbp),%eax
cltd
idivl  0x20(%rbp)
cmp    $0x0,%edx
jle    1309 <jacobi+0x1d9>
mov    -0x3c(%rbp),%eax
cltd
idivl  0x20(%rbp)
mov    0x20(%rbp),%eax
sub    $0x1,%eax
cmp    %eax,%edx
jge    1309 <jacobi+0x1d9>
mov    -0x3c(%rbp),%eax
sub    0x20(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x3c(%rbp),%eax
add    0x20(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
mov    -0x3c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x60(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x58(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm0
mov    -0x70(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x70(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
ucomisd -0x68(%rbp),%xmm0
jbe    1304 <jacobi+0x1d4>
mov    -0x70(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    1309 <jacobi+0x1d9>
jmp    130e <jacobi+0x1de>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11b4 <jacobi+0x84>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x50(%rbp),%eax
jge    1357 <jacobi+0x227>
mov    -0x70(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1323 <jacobi+0x1f3>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    $0x1,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    138a <jacobi+0x25a>
mov    -0x44(%rbp),%esi
movsd  -0x68(%rbp),%xmm0
lea    0xca6(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    138f <jacobi+0x25f>
movsd  -0x68(%rbp),%xmm0
xor    %eax,%eax
ucomisd -0x38(%rbp),%xmm0
mov    %al,-0x71(%rbp)
jbe    13b0 <jacobi+0x280>
mov    -0x44(%rbp),%eax
cmp    0x28(%rbp),%eax
setl   %al
mov    %al,-0x71(%rbp)
mov    -0x71(%rbp),%al
test   $0x1,%al
jne    11a5 <jacobi+0x75>
mov    -0x44(%rbp),%esi
lea    0xc6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x70(%rbp),%rdi
call   1030 <free@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jacobi>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
movsd  %xmm0,0x80(%rsp)
mov    %r9,0x78(%rsp)
mov    %r8,0x70(%rsp)
mov    %rcx,0x68(%rsp)
mov    %rdx,0x60(%rsp)
mov    %rsi,0x58(%rsp)
mov    %rdi,%rbp
mov    0xf8(%rsp),%eax
mov    %eax,0x14(%rsp)
mov    0xf0(%rsp),%ebx
lea    0xe96(%rip),%rdi
call   1040 <puts@plt>
mov    0xe8(%rsp),%r13d
imul   %ebx,%r13d
lea    0x0(,%r13,8),%edi
call   1060 <malloc@plt>
mov    %rax,%r14
lea    0xe82(%rip),%rdi
call   1040 <puts@plt>
mov    %r13d,%eax
sub    %ebx,%eax
lea    -0x1(%rbx),%esi
movslq %eax,%r12
movslq %ebx,%r15
lea    0x0(,%r13,8),%rax
add    %rbp,%rax
lea    (%r14,%r13,8),%rcx
mov    %r13d,%edx
and    $0xfffffffc,%edx
mov    %rdx,0x50(%rsp)
add    $0xfffffffffffffffc,%rdx
mov    %rdx,0x48(%rsp)
shr    $0x2,%rdx
add    $0x1,%rdx
cmp    %rbp,%rcx
seta   %cl
cmp    %rax,%r14
setb   %al
and    %cl,%al
mov    %al,0x7(%rsp)
mov    %edx,%ecx
and    $0x3,%ecx
and    $0xfffffffffffffffc,%rdx
mov    %rdx,0x20(%rsp)
mov    %r13d,%eax
and    $0x3,%eax
mov    %rax,0x18(%rsp)
lea    0x0(,%r15,8),%rax
add    %rbp,%rax
mov    %rax,0xa0(%rsp)
lea    0x0(,%r15,8),%rax
mov    %rbp,%rdx
sub    %rax,%rdx
mov    %rdx,0x98(%rsp)
lea    0x10(%rbp),%rax
mov    %rax,0x30(%rsp)
mov    %r14,%rax
add    $0x10,%rax
mov    %rax,0x28(%rsp)
mov    %rcx,0x40(%rsp)
shl    $0x5,%rcx
mov    %rcx,0x38(%rsp)
xor    %eax,%eax
mov    %rax,0x8(%rsp)
mov    %rbx,0x88(%rsp)
mov    %esi,0x10(%rsp)
nop
xorpd  %xmm2,%xmm2
test   %r13d,%r13d
jle    14c0 <jacobi+0x380>
xor    %ecx,%ecx
mov    0x78(%rsp),%r8
mov    0x70(%rsp),%r9
mov    0x68(%rsp),%r10
mov    0x60(%rsp),%r11
mov    0x58(%rsp),%rdi
jmp    12bd <jacobi+0x17d>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rcx
cmp    %rcx,%r13
je     1350 <jacobi+0x210>
cmp    %r15,%rcx
jl     12b0 <jacobi+0x170>
cmp    %r12,%rcx
jg     12b0 <jacobi+0x170>
mov    %ecx,%eax
cltd
idiv   %ebx
test   %edx,%edx
je     12b0 <jacobi+0x170>
cmp    %esi,%edx
jge    12b0 <jacobi+0x170>
movsd  (%r11,%rcx,8),%xmm0
movsd  (%r10,%rcx,8),%xmm1
mov    0xa0(%rsp),%rax
mulsd  (%rax,%rcx,8),%xmm1
mov    0x98(%rsp),%rax
mulsd  (%rax,%rcx,8),%xmm0
addsd  %xmm1,%xmm0
movsd  (%r9,%rcx,8),%xmm1
mulsd  0x8(%rbp,%rcx,8),%xmm1
addsd  %xmm0,%xmm1
movsd  (%r8,%rcx,8),%xmm0
mulsd  -0x8(%rbp,%rcx,8),%xmm0
addsd  %xmm1,%xmm0
divsd  (%rdi,%rcx,8),%xmm0
movsd  %xmm0,(%r14,%rcx,8)
subsd  0x0(%rbp,%rcx,8),%xmm0
ucomisd %xmm2,%xmm0
jbe    12b0 <jacobi+0x170>
movapd %xmm0,%xmm2
jmp    12b0 <jacobi+0x170>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   %r13d,%r13d
jle    14c0 <jacobi+0x380>
cmp    $0x4,%r13d
setb   %al
or     0x7(%rsp),%al
je     1372 <jacobi+0x232>
xor    %eax,%eax
mov    0x18(%rsp),%rsi
jmp    144c <jacobi+0x30c>
cmpq   $0xc,0x48(%rsp)
mov    0x18(%rsp),%rsi
mov    0x38(%rsp),%rdi
jae    1388 <jacobi+0x248>
xor    %eax,%eax
jmp    13f5 <jacobi+0x2b5>
mov    0x20(%rsp),%rcx
xor    %eax,%eax
nop
movups (%r14,%rax,8),%xmm0
movups 0x10(%r14,%rax,8),%xmm1
movups %xmm0,0x0(%rbp,%rax,8)
movups %xmm1,0x10(%rbp,%rax,8)
movups 0x20(%r14,%rax,8),%xmm0
movups 0x30(%r14,%rax,8),%xmm1
movups %xmm0,0x20(%rbp,%rax,8)
movups %xmm1,0x30(%rbp,%rax,8)
movups 0x40(%r14,%rax,8),%xmm0
movups 0x50(%r14,%rax,8),%xmm1
movups %xmm0,0x40(%rbp,%rax,8)
movups %xmm1,0x50(%rbp,%rax,8)
movupd 0x60(%r14,%rax,8),%xmm0
movupd 0x70(%r14,%rax,8),%xmm1
movupd %xmm0,0x60(%rbp,%rax,8)
movupd %xmm1,0x70(%rbp,%rax,8)
add    $0x10,%rax
add    $0xfffffffffffffffc,%rcx
jne    1390 <jacobi+0x250>
cmpq   $0x0,0x40(%rsp)
je     143f <jacobi+0x2ff>
mov    0x30(%rsp),%rcx
lea    (%rcx,%rax,8),%rcx
mov    0x28(%rsp),%rdx
lea    (%rdx,%rax,8),%rax
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movupd -0x10(%rax,%rdx,1),%xmm0
movupd (%rax,%rdx,1),%xmm1
movupd %xmm0,-0x10(%rcx,%rdx,1)
movupd %xmm1,(%rcx,%rdx,1)
add    $0x20,%rdx
cmp    %rdx,%rdi
jne    1420 <jacobi+0x2e0>
mov    0x50(%rsp),%rcx
mov    %rcx,%rax
cmp    %r13,%rcx
je     14c0 <jacobi+0x380>
mov    %rax,%rcx
not    %rcx
add    %r13,%rcx
test   %rsi,%rsi
je     1476 <jacobi+0x336>
mov    %rsi,%rdx
nopl   (%rax)
movsd  (%r14,%rax,8),%xmm0
movsd  %xmm0,0x0(%rbp,%rax,8)
add    $0x1,%rax
add    $0xffffffffffffffff,%rdx
jne    1460 <jacobi+0x320>
cmp    $0x3,%rcx
jb     14c0 <jacobi+0x380>
nopl   0x0(%rax)
movsd  (%r14,%rax,8),%xmm0
movsd  %xmm0,0x0(%rbp,%rax,8)
movsd  0x8(%r14,%rax,8),%xmm0
movsd  %xmm0,0x8(%rbp,%rax,8)
movsd  0x10(%r14,%rax,8),%xmm0
movsd  %xmm0,0x10(%rbp,%rax,8)
movsd  0x18(%r14,%rax,8),%xmm0
movsd  %xmm0,0x18(%rbp,%rax,8)
add    $0x4,%rax
cmp    %rax,%r13
jne    1480 <jacobi+0x340>
nopl   0x0(%rax)
movsd  %xmm2,0x90(%rsp)
mov    0x8(%rsp),%rbx
add    $0x1,%ebx
lea    0xb28(%rip),%rdi
mov    %ebx,%esi
movapd %xmm2,%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
mov    %rbx,0x8(%rsp)
cmp    0x14(%rsp),%ebx
mov    0x88(%rsp),%rbx
mov    0x10(%rsp),%esi
jge    1514 <jacobi+0x3d4>
movsd  0x90(%rsp),%xmm0
ucomisd 0x80(%rsp),%xmm0
ja     1280 <jacobi+0x140>
lea    0xaee(%rip),%rdi
mov    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xb1e(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"Begin Jacobi solver\0A\00"
@.str.1 = [20 x i8] c"ITERATIONS \09 ERROR\0A\00"
@.str.2 = [9 x i8] c"%d \09 %f\0A\00"
@.str.3 = [28 x i8] c"Converged in %d iterations\0A\00"
@.str.4 = [21 x i8] c"End Jacobi solver\0A\0A\0A\00"
define void @jacobi(double* %0, double* %1, double* %2, double* %3, double* %4, double* %5, double* %6, i32 %7, i32 %8, i32 %9, double %10) {
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca double*
%16 = alloca double*
%17 = alloca double*
%18 = alloca double*
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca double
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
%30 = alloca i32
%31 = alloca i32
%32 = alloca i32
%33 = alloca double
%34 = alloca double*
store double* %0, double** %12
store double* %1, double** %13
store double* %2, double** %14
store double* %3, double** %15
store double* %4, double** %16
store double* %5, double** %17
store double* %6, double** %18
store i32 %7, i32* %19
store i32 %8, i32* %20
store i32 %9, i32* %21
store double %10, double* %22
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%36 = load i32, i32* %19
%37 = load i32, i32* %20
%38 = mul nsw i32 %36, %37
store i32 %38, i32* %28
%39 = load i32, i32* %28
%40 = sext i32 %39 to i64
%41 = mul i64 %40, 8
%42 = trunc i64 %41 to i32
%43 = call i64 @malloc(i32 %42)
%44 = inttoptr i64 %43 to double*
store double* %44, double** %34
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %25
br label %46
46: ; preds = %205, %11
store double 0.000000e+00, double* %33
store i32 0, i32* %23
br label %47
47: ; preds = %165, %46
%48 = load i32, i32* %23
%49 = load i32, i32* %28
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %168
51: ; preds = %47
%52 = load i32, i32* %23
%53 = load i32, i32* %20
%54 = icmp sge i32 %52, %53
br i1 %54, label %55, label %164
55: ; preds = %51
%56 = load i32, i32* %23
%57 = load i32, i32* %28
%58 = load i32, i32* %20
%59 = sub nsw i32 %57, %58
%60 = icmp sle i32 %56, %59
br i1 %60, label %61, label %164
61: ; preds = %55
%62 = load i32, i32* %23
%63 = load i32, i32* %20
%64 = srem i32 %62, %63
%65 = icmp sgt i32 %64, 0
br i1 %65, label %66, label %164
66: ; preds = %61
%67 = load i32, i32* %23
%68 = load i32, i32* %20
%69 = srem i32 %67, %68
%70 = load i32, i32* %20
%71 = sub nsw i32 %70, 1
%72 = icmp slt i32 %69, %71
br i1 %72, label %73, label %164
73: ; preds = %66
%74 = load i32, i32* %23
%75 = load i32, i32* %20
%76 = sub nsw i32 %74, %75
store i32 %76, i32* %29
%77 = load i32, i32* %23
%78 = load i32, i32* %20
%79 = add nsw i32 %77, %78
store i32 %79, i32* %30
%80 = load i32, i32* %23
%81 = add nsw i32 %80, 1
store i32 %81, i32* %31
%82 = load i32, i32* %23
%83 = sub nsw i32 %82, 1
store i32 %83, i32* %32
%84 = load double*, double** %14
%85 = load i32, i32* %23
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds double, double* %84, i64 %86
%88 = load double, double* %87
%89 = load double*, double** %12
%90 = load i32, i32* %29
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds double, double* %89, i64 %91
%93 = load double, double* %92
%94 = load double*, double** %15
%95 = load i32, i32* %23
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds double, double* %94, i64 %96
%98 = load double, double* %97
%99 = load double*, double** %12
%100 = load i32, i32* %30
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds double, double* %99, i64 %101
%103 = load double, double* %102
%104 = fmul double %98, %103
%105 = call double @llvm.fmuladd.f64(double %88, double %93, double %104)
%106 = load double*, double** %16
%107 = load i32, i32* %23
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds double, double* %106, i64 %108
%110 = load double, double* %109
%111 = load double*, double** %12
%112 = load i32, i32* %31
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds double, double* %111, i64 %113
%115 = load double, double* %114
%116 = call double @llvm.fmuladd.f64(double %110, double %115, double %105)
%117 = load double*, double** %17
%118 = load i32, i32* %23
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds double, double* %117, i64 %119
%121 = load double, double* %120
%122 = load double*, double** %12
%123 = load i32, i32* %32
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds double, double* %122, i64 %124
%126 = load double, double* %125
%127 = call double @llvm.fmuladd.f64(double %121, double %126, double %116)
%128 = load double*, double** %13
%129 = load i32, i32* %23
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds double, double* %128, i64 %130
%132 = load double, double* %131
%133 = fdiv double %127, %132
%134 = load double*, double** %34
%135 = load i32, i32* %23
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds double, double* %134, i64 %136
store double %133, double* %137
%138 = load double*, double** %34
%139 = load i32, i32* %23
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds double, double* %138, i64 %140
%142 = load double, double* %141
%143 = load double*, double** %12
%144 = load i32, i32* %23
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds double, double* %143, i64 %145
%147 = load double, double* %146
%148 = fsub double %142, %147
%149 = load double, double* %33
%150 = fcmp ogt double %148, %149
br i1 %150, label %151, label %163
151: ; preds = %73
%152 = load double*, double** %34
%153 = load i32, i32* %23
%154 = sext i32 %153 to i64
%155 = getelementptr inbounds double, double* %152, i64 %154
%156 = load double, double* %155
%157 = load double*, double** %12
%158 = load i32, i32* %23
%159 = sext i32 %158 to i64
%160 = getelementptr inbounds double, double* %157, i64 %159
%161 = load double, double* %160
%162 = fsub double %156, %161
store double %162, double* %33
br label %163
163: ; preds = %151, %73
br label %164
164: ; preds = %163, %66, %61, %55, %51
br label %165
165: ; preds = %164
%166 = load i32, i32* %23
%167 = add nsw i32 %166, 1
store i32 %167, i32* %23
br label %47
168: ; preds = %47
store i32 0, i32* %23
br label %169
169: ; preds = %183, %168
%170 = load i32, i32* %23
%171 = load i32, i32* %28
%172 = icmp slt i32 %170, %171
br i1 %172, label %173, label %186
173: ; preds = %169
%174 = load double*, double** %34
%175 = load i32, i32* %23
%176 = sext i32 %175 to i64
%177 = getelementptr inbounds double, double* %174, i64 %176
%178 = load double, double* %177
%179 = load double*, double** %12
%180 = load i32, i32* %23
%181 = sext i32 %180 to i64
%182 = getelementptr inbounds double, double* %179, i64 %181
store double %178, double* %182
br label %183
183: ; preds = %173
%184 = load i32, i32* %23
%185 = add nsw i32 %184, 1
store i32 %185, i32* %23
br label %169
186: ; preds = %169
%187 = load i32, i32* %25
%188 = add nsw i32 %187, 1
store i32 %188, i32* %25
%189 = load i32, i32* %25
%190 = srem i32 %189, 1
%191 = icmp eq i32 %190, 0
br i1 %191, label %192, label %196
192: ; preds = %186
%193 = load i32, i32* %25
%194 = load double, double* %33
%195 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %193, double %194)
br label %196
196: ; preds = %192, %186
br label %197
197: ; preds = %196
%198 = load double, double* %33
%199 = load double, double* %22
%200 = fcmp ogt double %198, %199
br i1 %200, label %201, label %205
201: ; preds = %197
%202 = load i32, i32* %25
%203 = load i32, i32* %21
%204 = icmp slt i32 %202, %203
br label %205
205: ; preds = %201, %197
%206 = phi i1 [ false, %197 ], [ %204, %201 ]
br i1 %206, label %46, label %207
207: ; preds = %205
%208 = load i32, i32* %25
%209 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %208)
%210 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%211 = load double*, double** %34
%212 = call i32 @free(double* %211)
ret void
}

LLVM IR (-O2):
@.str.2 = [9 x i8] c"%d \09 %f\0A\00"
@.str.3 = [28 x i8] c"Converged in %d iterations\0A\00"
@str = [20 x i8] c"Begin Jacobi solver\00"
@str.5 = [19 x i8] c"ITERATIONS \09 ERROR\00"
@str.6 = [20 x i8] c"End Jacobi solver\0A\0A\00"
define void @jacobi(double* nocapture %0, double* nocapture %1, double* nocapture %2, double* nocapture %3, double* nocapture %4, double* nocapture %5, double* nocapture readnone %6, i32 %7, i32 %8, i32 %9, double %10) {
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%13 = mul nsw i32 %8, %7
%14 = shl i32 %13, 3
%15 = tail call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to double*
%17 = inttoptr i64 %15 to i8*
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.5, i64 0, i64 0))
%19 = icmp sgt i32 %13, 0
%20 = sub nsw i32 %13, %8
%21 = add nsw i32 %8, -1
%22 = sext i32 %20 to i64
%23 = sext i32 %8 to i64
%24 = zext i32 %13 to i64
%25 = zext i32 %13 to i64
%26 = getelementptr double, double* %0, i64 %24
%27 = bitcast double* %26 to i8*
%28 = getelementptr double, double* %16, i64 %24
%29 = and i64 %24, 4294967292
%30 = add nsw i64 %29, -4
%31 = lshr exact i64 %30, 2
%32 = add nuw nsw i64 %31, 1
%33 = icmp ult i32 %13, 4
%34 = icmp ugt double* %28, %0
%35 = icmp ult i8* %17, %27
%36 = and i1 %34, %35
%37 = and i64 %24, 4294967292
%38 = and i64 %32, 3
%39 = icmp ult i64 %30, 12
%40 = and i64 %32, 9223372036854775804
%41 = icmp eq i64 %38, 0
%42 = icmp eq i64 %37, %24
%43 = and i64 %24, 3
%44 = icmp eq i64 %43, 0
br label %45
45: ; preds = %204, %11
%46 = phi i32 [ 0, %11 ], [ %206, %204 ]
br i1 %19, label %135, label %204
47: ; preds = %181
br i1 %19, label %48, label %204
48: ; preds = %47
%49 = select i1 %33, i1 true, i1 %36
br i1 %49, label %119, label %50
50: ; preds = %48
br i1 %39, label %100, label %51
51: ; preds = %50, %51
%52 = phi i64 [ %97, %51 ], [ 0, %50 ]
%53 = phi i64 [ %98, %51 ], [ 0, %50 ]
%54 = getelementptr inbounds double, double* %16, i64 %52
%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 = getelementptr inbounds double, double* %0, i64 %52
%61 = bitcast double* %60 to <2 x double>*
store <2 x double> %56, <2 x double>* %61
%62 = getelementptr inbounds double, double* %60, i64 2
%63 = bitcast double* %62 to <2 x double>*
store <2 x double> %59, <2 x double>* %63
%64 = or i64 %52, 4
%65 = getelementptr inbounds double, double* %16, i64 %64
%66 = bitcast double* %65 to <2 x double>*
%67 = load <2 x double>, <2 x double>* %66
%68 = getelementptr inbounds double, double* %65, i64 2
%69 = bitcast double* %68 to <2 x double>*
%70 = load <2 x double>, <2 x double>* %69
%71 = getelementptr inbounds double, double* %0, i64 %64
%72 = bitcast double* %71 to <2 x double>*
store <2 x double> %67, <2 x double>* %72
%73 = getelementptr inbounds double, double* %71, i64 2
%74 = bitcast double* %73 to <2 x double>*
store <2 x double> %70, <2 x double>* %74
%75 = or i64 %52, 8
%76 = getelementptr inbounds double, double* %16, i64 %75
%77 = bitcast double* %76 to <2 x double>*
%78 = load <2 x double>, <2 x double>* %77
%79 = getelementptr inbounds double, double* %76, i64 2
%80 = bitcast double* %79 to <2 x double>*
%81 = load <2 x double>, <2 x double>* %80
%82 = getelementptr inbounds double, double* %0, i64 %75
%83 = bitcast double* %82 to <2 x double>*
store <2 x double> %78, <2 x double>* %83
%84 = getelementptr inbounds double, double* %82, i64 2
%85 = bitcast double* %84 to <2 x double>*
store <2 x double> %81, <2 x double>* %85
%86 = or i64 %52, 12
%87 = getelementptr inbounds double, double* %16, i64 %86
%88 = bitcast double* %87 to <2 x double>*
%89 = load <2 x double>, <2 x double>* %88
%90 = getelementptr inbounds double, double* %87, i64 2
%91 = bitcast double* %90 to <2 x double>*
%92 = load <2 x double>, <2 x double>* %91
%93 = getelementptr inbounds double, double* %0, i64 %86
%94 = bitcast double* %93 to <2 x double>*
store <2 x double> %89, <2 x double>* %94
%95 = getelementptr inbounds double, double* %93, i64 2
%96 = bitcast double* %95 to <2 x double>*
store <2 x double> %92, <2 x double>* %96
%97 = add nuw i64 %52, 16
%98 = add nuw i64 %53, 4
%99 = icmp eq i64 %98, %40
br i1 %99, label %100, label %51
100: ; preds = %51, %50
%101 = phi i64 [ 0, %50 ], [ %97, %51 ]
br i1 %41, label %118, label %102
102: ; preds = %100, %102
%103 = phi i64 [ %115, %102 ], [ %101, %100 ]
%104 = phi i64 [ %116, %102 ], [ 0, %100 ]
%105 = getelementptr inbounds double, double* %16, i64 %103
%106 = bitcast double* %105 to <2 x double>*
%107 = load <2 x double>, <2 x double>* %106
%108 = getelementptr inbounds double, double* %105, i64 2
%109 = bitcast double* %108 to <2 x double>*
%110 = load <2 x double>, <2 x double>* %109
%111 = getelementptr inbounds double, double* %0, i64 %103
%112 = bitcast double* %111 to <2 x double>*
store <2 x double> %107, <2 x double>* %112
%113 = getelementptr inbounds double, double* %111, i64 2
%114 = bitcast double* %113 to <2 x double>*
store <2 x double> %110, <2 x double>* %114
%115 = add nuw i64 %103, 4
%116 = add i64 %104, 1
%117 = icmp eq i64 %116, %38
br i1 %117, label %118, label %102
118: ; preds = %102, %100
br i1 %42, label %204, label %119
119: ; preds = %48, %118
%120 = phi i64 [ 0, %48 ], [ %37, %118 ]
%121 = xor i64 %120, -1
%122 = add nsw i64 %121, %24
br i1 %44, label %132, label %123
123: ; preds = %119, %123
%124 = phi i64 [ %129, %123 ], [ %120, %119 ]
%125 = phi i64 [ %130, %123 ], [ 0, %119 ]
%126 = getelementptr inbounds double, double* %16, i64 %124
%127 = load double, double* %126
%128 = getelementptr inbounds double, double* %0, i64 %124
store double %127, double* %128
%129 = add nuw nsw i64 %124, 1
%130 = add i64 %125, 1
%131 = icmp eq i64 %130, %43
br i1 %131, label %132, label %123
132: ; preds = %123, %119
%133 = phi i64 [ %120, %119 ], [ %129, %123 ]
%134 = icmp ult i64 %122, 3
br i1 %134, label %204, label %185
135: ; preds = %45, %181
%136 = phi i64 [ %183, %181 ], [ 0, %45 ]
%137 = phi double [ %182, %181 ], [ 0.000000e+00, %45 ]
%138 = icmp slt i64 %136, %23
%139 = icmp sgt i64 %136, %22
%140 = select i1 %138, i1 true, i1 %139
br i1 %140, label %181, label %141
141: ; preds = %135
%142 = trunc i64 %136 to i32
%143 = srem i32 %142, %8
%144 = icmp ne i32 %143, 0
%145 = icmp slt i32 %143, %21
%146 = select i1 %144, i1 %145, i1 false
br i1 %146, label %147, label %181
147: ; preds = %141
%148 = sub nsw i64 %136, %23
%149 = add nsw i64 %136, %23
%150 = add nuw nsw i64 %136, 1
%151 = add nsw i64 %136, -1
%152 = getelementptr inbounds double, double* %2, i64 %136
%153 = load double, double* %152
%154 = getelementptr inbounds double, double* %0, i64 %148
%155 = load double, double* %154
%156 = getelementptr inbounds double, double* %3, i64 %136
%157 = load double, double* %156
%158 = getelementptr inbounds double, double* %0, i64 %149
%159 = load double, double* %158
%160 = fmul double %157, %159
%161 = tail call double @llvm.fmuladd.f64(double %153, double %155, double %160)
%162 = getelementptr inbounds double, double* %4, i64 %136
%163 = load double, double* %162
%164 = getelementptr inbounds double, double* %0, i64 %150
%165 = load double, double* %164
%166 = tail call double @llvm.fmuladd.f64(double %163, double %165, double %161)
%167 = getelementptr inbounds double, double* %5, i64 %136
%168 = load double, double* %167
%169 = getelementptr inbounds double, double* %0, i64 %151
%170 = load double, double* %169
%171 = tail call double @llvm.fmuladd.f64(double %168, double %170, double %166)
%172 = getelementptr inbounds double, double* %1, i64 %136
%173 = load double, double* %172
%174 = fdiv double %171, %173
%175 = getelementptr inbounds double, double* %16, i64 %136
store double %174, double* %175
%176 = getelementptr inbounds double, double* %0, i64 %136
%177 = load double, double* %176
%178 = fsub double %174, %177
%179 = fcmp ogt double %178, %137
br i1 %179, label %180, label %181
180: ; preds = %147
br label %181
181: ; preds = %135, %141, %180, %147
%182 = phi double [ %178, %180 ], [ %137, %147 ], [ %137, %141 ], [ %137, %135 ]
%183 = add nuw nsw i64 %136, 1
%184 = icmp eq i64 %183, %24
br i1 %184, label %47, label %135
185: ; preds = %132, %185
%186 = phi i64 [ %202, %185 ], [ %133, %132 ]
%187 = getelementptr inbounds double, double* %16, i64 %186
%188 = load double, double* %187
%189 = getelementptr inbounds double, double* %0, i64 %186
store double %188, double* %189
%190 = add nuw nsw i64 %186, 1
%191 = getelementptr inbounds double, double* %16, i64 %190
%192 = load double, double* %191
%193 = getelementptr inbounds double, double* %0, i64 %190
store double %192, double* %193
%194 = add nuw nsw i64 %186, 2
%195 = getelementptr inbounds double, double* %16, i64 %194
%196 = load double, double* %195
%197 = getelementptr inbounds double, double* %0, i64 %194
store double %196, double* %197
%198 = add nuw nsw i64 %186, 3
%199 = getelementptr inbounds double, double* %16, i64 %198
%200 = load double, double* %199
%201 = getelementptr inbounds double, double* %0, i64 %198
store double %200, double* %201
%202 = add nuw nsw i64 %186, 4
%203 = icmp eq i64 %202, %25
br i1 %203, label %204, label %185
204: ; preds = %132, %185, %118, %45, %47
%205 = phi double [ %182, %47 ], [ 0.000000e+00, %45 ], [ %182, %118 ], [ %182, %185 ], [ %182, %132 ]
%206 = add nuw nsw i32 %46, 1
%207 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %206, double %205)
%208 = fcmp ogt double %205, %10
%209 = icmp slt i32 %206, %9
%210 = and i1 %209, %208
br i1 %210, label %45, label %211
211: ; preds = %204
%212 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %206)
%213 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.6, i64 0, i64 0))
%214 = tail call i32 @free(double* %16)
ret void
}