#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 */
typedef int uint;
typedef double clock_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ CLOCKS_PER_SEC;
scalar_t__ calloc(int, int);
double clock();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fill_coeffs(int, int, double, double, double, double, double,
                               double *, double *, double *, double *, double *,
                               double *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ gauss_seidel(double *, double *, double *, double *,
                                double *, double *, double *, double *);
int /*<<< orphan*/ printf(char *, double);
double sqrt(double);
int main(void) {
  double L = 1.0;
  double H = 1.0;
  double width = 0.01;
  double th_cond = 1.0;
  double TN = 1.0;
  double tol = 1.e-6;
  uint num_rows = 128 + 2;
  uint num_cols = 128 + 2;
  uint size_temp = num_rows * num_cols;
  uint size = 128 * 128;
  double dx = L / 128;
  double dy = H / 128;
  uint iter;
  uint it_max = 1e6;
  double *aP, *aW, *aE, *aS, *aN, *b, *temp, *temp_old;
  aP = (double *)calloc(size, sizeof(double));
  aW = (double *)calloc(size, sizeof(double));
  aE = (double *)calloc(size, sizeof(double));
  aS = (double *)calloc(size, sizeof(double));
  aN = (double *)calloc(size, sizeof(double));
  b = (double *)calloc(size, sizeof(double));
  temp = (double *)calloc(size_temp, sizeof(double));
  temp_old = (double *)calloc(size_temp, sizeof(double));
  fill_coeffs(num_rows - 2, num_cols - 2, th_cond, dx, dy, width, TN, aP, aW,
              aE, aS, aN, b);
  for (uint i = 0; i < size_temp; ++i) {
    temp[i] = 0.0;
    temp_old[i] = 0.0;
  }
  clock_t start_time = clock();
  for (iter = 1; iter <= it_max; ++iter) {
    double norm_L2 = 0.0;
    gauss_seidel(aP, aW, aE, aS, aN, b, temp, &norm_L2);
    norm_L2 = sqrt(norm_L2 / (size));
    if (norm_L2 < tol) {
      break;
    }
  }
  clock_t end_time = clock();
  printf("CPU\nIterations: %i\n", iter);
  printf("Time: %f\n", (end_time - start_time) / (double)CLOCKS_PER_SEC);
  FILE *pfile;
  pfile = fopen("temp_cpu.dat", "w");
  if (pfile != NULL) {
    fprintf(pfile, "#x\ty\ttemp(K)\n");
    for (uint row = 1; row < num_rows - 1; ++row) {
      for (uint col = 1; col < num_cols - 1; ++col) {
        uint ind = col * num_rows + row;
        double x_pos = (col - 1) * dx + (dx / 2);
        double y_pos = (row - 1) * dy + (dy / 2);
        fprintf(pfile, "%f\t%f\t%f\n", x_pos, y_pos, temp[ind]);
      }
      fprintf(pfile, "\n");
    }
  }
  fclose(pfile);
  free(aP);
  free(aW);
  free(aE);
  free(aS);
  free(aN);
  free(b);
  free(temp);
  free(temp_old);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xe56(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe49(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe44(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe2f(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe22(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe0d(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x82,-0x3c(%rbp)
movl   $0x82,-0x40(%rbp)
mov    -0x3c(%rbp),%eax
imul   -0x40(%rbp),%eax
mov    %eax,-0x44(%rbp)
movl   $0x4000,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xdd4(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xdbe(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0xf4240,-0x60(%rbp)
mov    -0x48(%rbp),%edi
mov    $0x8,%esi
call   1080 <calloc@plt>
mov    %rax,-0x68(%rbp)
mov    -0x48(%rbp),%edi
mov    $0x8,%esi
call   1080 <calloc@plt>
mov    %rax,-0x70(%rbp)
mov    -0x48(%rbp),%edi
mov    $0x8,%esi
call   1080 <calloc@plt>
mov    %rax,-0x78(%rbp)
mov    -0x48(%rbp),%edi
mov    $0x8,%esi
call   1080 <calloc@plt>
mov    %rax,-0x80(%rbp)
mov    -0x48(%rbp),%edi
mov    $0x8,%esi
call   1080 <calloc@plt>
mov    %rax,-0x88(%rbp)
mov    -0x48(%rbp),%edi
mov    $0x8,%esi
call   1080 <calloc@plt>
mov    %rax,-0x90(%rbp)
mov    -0x44(%rbp),%edi
mov    $0x8,%esi
call   1080 <calloc@plt>
mov    %rax,-0x98(%rbp)
mov    -0x44(%rbp),%edi
mov    $0x8,%esi
call   1080 <calloc@plt>
mov    %rax,-0xa0(%rbp)
mov    -0x3c(%rbp),%edi
sub    $0x2,%edi
mov    -0x40(%rbp),%esi
sub    $0x2,%esi
movsd  -0x28(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
movsd  -0x30(%rbp),%xmm4
mov    -0x68(%rbp),%rdx
mov    -0x70(%rbp),%rcx
mov    -0x78(%rbp),%r8
mov    -0x80(%rbp),%r9
mov    -0x88(%rbp),%r10
mov    -0x90(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   10a0 <fill_coeffs@plt>
movl   $0x0,-0xa4(%rbp)
mov    -0xa4(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    1390 <main+0x1f0>
mov    -0x98(%rbp),%rax
movslq -0xa4(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0xa0(%rbp),%rax
movslq -0xa4(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    1341 <main+0x1a1>
mov    $0x0,%al
call   1040 <clock@plt>
movsd  %xmm0,-0xb0(%rbp)
ff
movl   $0x1,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x60(%rbp),%eax
jg     1444 <main+0x2a4>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
mov    -0x68(%rbp),%rdi
mov    -0x70(%rbp),%rsi
mov    -0x78(%rbp),%rdx
mov    -0x80(%rbp),%rcx
mov    -0x88(%rbp),%r8
mov    -0x90(%rbp),%r9
mov    -0x98(%rbp),%r10
lea    -0xb8(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1070 <gauss_seidel@plt>
movsd  -0xb8(%rbp),%xmm0
ff
cvtsi2sdl -0x48(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   10c0 <sqrt@plt>
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0xb8(%rbp),%xmm1
ff
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1431 <main+0x291>
jmp    1444 <main+0x2a4>
jmp    1436 <main+0x296>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    13a6 <main+0x206>
mov    $0x0,%al
call   1040 <clock@plt>
movsd  %xmm0,-0xc0(%rbp)
ff
cvtsi2sdl -0x5c(%rbp),%xmm0
lea    0xbc9(%rip),%rdi
call   1060 <printf@plt>
movsd  -0xc0(%rbp),%xmm0
ff
subsd  -0xb0(%rbp),%xmm0
ff
mov    0x2b6d(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
lea    0xbb1(%rip),%rdi
call   1060 <printf@plt>
lea    0xbaf(%rip),%rdi
lea    0xbb5(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0xc8(%rbp)
cmpq   $0x0,-0xc8(%rbp)
je     15ff <main+0x45f>
mov    -0xc8(%rbp),%rdi
lea    0xb8f(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0xcc(%rbp)
mov    -0xcc(%rbp),%eax
mov    -0x3c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    15fa <main+0x45a>
movl   $0x1,-0xd0(%rbp)
mov    -0xd0(%rbp),%eax
mov    -0x40(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    15d1 <main+0x431>
mov    -0xd0(%rbp),%eax
imul   -0x3c(%rbp),%eax
add    -0xcc(%rbp),%eax
mov    %eax,-0xd4(%rbp)
mov    -0xd0(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
movsd  0xae2(%rip),%xmm3
divsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xe0(%rbp)
ff
mov    -0xcc(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  -0x58(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm1
movsd  0xaaf(%rip),%xmm3
divsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xe8(%rbp)
ff
mov    -0xc8(%rbp),%rdi
movsd  -0xe0(%rbp),%xmm0
ff
movsd  -0xe8(%rbp),%xmm1
ff
mov    -0x98(%rbp),%rax
movslq -0xd4(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
lea    0xaad(%rip),%rsi
mov    $0x3,%al
call   1090 <fprintf@plt>
mov    -0xd0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd0(%rbp)
jmp    14f5 <main+0x355>
mov    -0xc8(%rbp),%rdi
lea    0xa82(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0xcc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xcc(%rbp)
jmp    14d7 <main+0x337>
jmp    15ff <main+0x45f>
mov    -0xc8(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
mov    -0x70(%rbp),%rdi
call   1030 <free@plt>
mov    -0x78(%rbp),%rdi
call   1030 <free@plt>
mov    -0x80(%rbp),%rdi
call   1030 <free@plt>
mov    -0x88(%rbp),%rdi
call   1030 <free@plt>
mov    -0x90(%rbp),%rdi
call   1030 <free@plt>
mov    -0x98(%rbp),%rdi
call   1030 <free@plt>
mov    -0xa0(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    $0x4000,%edi
mov    $0x8,%esi
call   1090 <calloc@plt>
mov    %rax,%r15
mov    $0x4000,%edi
mov    $0x8,%esi
call   1090 <calloc@plt>
mov    %rax,%r12
mov    $0x4000,%edi
mov    $0x8,%esi
call   1090 <calloc@plt>
mov    %rax,%r13
mov    $0x4000,%edi
mov    $0x8,%esi
call   1090 <calloc@plt>
mov    %rax,%rbp
mov    $0x4000,%edi
mov    $0x8,%esi
call   1090 <calloc@plt>
mov    %rax,%r14
mov    $0x4000,%edi
mov    $0x8,%esi
call   1090 <calloc@plt>
mov    %rax,%rbx
mov    $0x4204,%edi
mov    $0x8,%esi
call   1090 <calloc@plt>
mov    %rax,(%rsp)
mov    $0x4204,%edi
mov    $0x8,%esi
call   1090 <calloc@plt>
mov    %rax,0x10(%rsp)
movsd  0xd97(%rip),%xmm1
movsd  0xd97(%rip),%xmm3
movsd  0xd97(%rip),%xmm0
mov    $0x80,%edi
mov    $0x80,%esi
movapd %xmm1,%xmm2
movapd %xmm0,%xmm4
mov    %r15,%rdx
mov    %r12,%rcx
mov    %r13,%r8
mov    %rbp,%r9
mov    %rbx,0x18(%rsp)
push   %rbx
mov    %r14,0x28(%rsp)
push   %r14
call   10b0 <fill_coeffs@plt>
mov    0x20(%rsp),%rdx
mov    0x10(%rsp),%rcx
add    $0x10,%rsp
lea    0x21020(%rdx),%rax
cmp    %rax,%rcx
jae    1349 <main+0x189>
lea    0x21020(%rcx),%rax
cmp    %rax,%rdx
jae    1349 <main+0x189>
mov    $0x4,%eax
nopl   0x0(%rax,%rax,1)
movq   $0x0,-0x20(%rcx,%rax,8)
movq   $0x0,-0x20(%rdx,%rax,8)
movq   $0x0,-0x18(%rcx,%rax,8)
movq   $0x0,-0x18(%rdx,%rax,8)
movq   $0x0,-0x10(%rcx,%rax,8)
movq   $0x0,-0x10(%rdx,%rax,8)
movq   $0x0,-0x8(%rcx,%rax,8)
movq   $0x0,-0x8(%rdx,%rax,8)
movq   $0x0,(%rcx,%rax,8)
movq   $0x0,(%rdx,%rax,8)
add    $0x5,%rax
cmp    $0x4208,%rax
jne    12e0 <main+0x120>
jmp    13ec <main+0x22c>
mov    $0x12,%eax
xorpd  %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movupd %xmm0,-0x90(%rcx,%rax,8)
ff ff
movupd %xmm0,-0x80(%rcx,%rax,8)
movupd %xmm0,-0x90(%rdx,%rax,8)
ff ff
movupd %xmm0,-0x80(%rdx,%rax,8)
movupd %xmm0,-0x70(%rcx,%rax,8)
movupd %xmm0,-0x60(%rcx,%rax,8)
movupd %xmm0,-0x70(%rdx,%rax,8)
movupd %xmm0,-0x60(%rdx,%rax,8)
movupd %xmm0,-0x50(%rcx,%rax,8)
movupd %xmm0,-0x40(%rcx,%rax,8)
movupd %xmm0,-0x50(%rdx,%rax,8)
movupd %xmm0,-0x40(%rdx,%rax,8)
movupd %xmm0,-0x30(%rcx,%rax,8)
movupd %xmm0,-0x20(%rcx,%rax,8)
movupd %xmm0,-0x30(%rdx,%rax,8)
movupd %xmm0,-0x20(%rdx,%rax,8)
movupd %xmm0,-0x10(%rcx,%rax,8)
movupd %xmm0,(%rcx,%rax,8)
movupd %xmm0,-0x10(%rdx,%rax,8)
movupd %xmm0,(%rdx,%rax,8)
add    $0x14,%rax
cmp    $0x4216,%rax
jne    1360 <main+0x1a0>
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%ebx
lea    0x28(%rsp),%r14
mov    %r15,0x50(%rsp)
mov    %r12,0x48(%rsp)
mov    %r13,0x40(%rsp)
mov    %rbp,0x38(%rsp)
nopw   0x0(%rax,%rax,1)
movq   $0x0,0x28(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbp,%rcx
mov    0x20(%rsp),%r8
mov    0x18(%rsp),%r9
push   %r14
push   0x8(%rsp)
call   1080 <gauss_seidel@plt>
add    $0x10,%rsp
movsd  0x28(%rsp),%xmm0
mulsd  0xbbc(%rip),%xmm0
ucomisd 0xbcc(%rip),%xmm0
jb     1470 <main+0x2b0>
sqrtsd %xmm0,%xmm0
jmp    1475 <main+0x2b5>
nopl   0x0(%rax)
call   10d0 <sqrt@plt>
movsd  0xba3(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     1493 <main+0x2d3>
add    $0x1,%ebx
cmp    $0xf4241,%ebx
jne    1420 <main+0x260>
mov    $0xf4241,%ebx
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,0x30(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
lea    0xb8a(%rip),%rdi
call   1060 <printf@plt>
movsd  0x30(%rsp),%xmm1
subsd  0x8(%rsp),%xmm1
mov    0x2b22(%rip),%rax
xorps  %xmm0,%xmm0
cvtsi2sdq (%rax),%xmm0
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
lea    0xb6f(%rip),%rdi
call   1060 <printf@plt>
lea    0xb6d(%rip),%rdi
lea    0xb73(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%r12
test   %rax,%rax
je     15de <main+0x41e>
lea    0xb5d(%rip),%rdi
mov    $0x1,%ebx
mov    $0xd,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   10e0 <fwrite@plt>
mov    (%rsp),%rbp
add    $0x418,%rbp
movsd  0xaf6(%rip),%xmm1
lea    0xb3a(%rip),%r13
nopl   0x0(%rax)
lea    -0x1(%rbx),%eax
xorps  %xmm2,%xmm2
cvtsi2sd %eax,%xmm2
movsd  0xaae(%rip),%xmm0
mulsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
mov    %rbp,%r14
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
mulsd  0xa80(%rip),%xmm0
addsd  0xaa0(%rip),%xmm0
movsd  (%r14),%xmm2
mov    %r12,%rdi
mov    %r13,%rsi
movsd  0x8(%rsp),%xmm1
mov    $0x3,%al
call   10a0 <fprintf@plt>
add    $0x1,%r15
add    $0x410,%r14
cmp    $0x80,%r15
jne    1570 <main+0x3b0>
mov    $0xa,%edi
mov    %r12,%rsi
call   1070 <fputc@plt>
add    $0x1,%rbx
add    $0x8,%rbp
cmp    $0x81,%rbx
movsd  0xa50(%rip),%xmm1
jne    1540 <main+0x380>
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    0x50(%rsp),%rdi
call   1030 <free@plt>
mov    0x48(%rsp),%rdi
call   1030 <free@plt>
mov    0x40(%rsp),%rdi
call   1030 <free@plt>
mov    0x38(%rsp),%rdi
call   1030 <free@plt>
mov    0x20(%rsp),%rdi
call   1030 <free@plt>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [20 x i8] c"CPU\0AIterations: %i\0A\00"
@.str.1 = [10 x i8] c"Time: %f\0A\00"
@CLOCKS_PER_SEC = global i64 0
@.str.2 = [13 x i8] c"temp_cpu.dat\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [14 x i8] c"#x\09y\09temp(K)\0A\00"
@.str.5 = [10 x i8] c"%f\09%f\09%f\0A\00"
define i32 @main() {
%1 = alloca double
%2 = tail call i64 @calloc(i32 16384, i32 8)
%3 = inttoptr i64 %2 to double*
%4 = tail call i64 @calloc(i32 16384, i32 8)
%5 = inttoptr i64 %4 to double*
%6 = tail call i64 @calloc(i32 16384, i32 8)
%7 = inttoptr i64 %6 to double*
%8 = tail call i64 @calloc(i32 16384, i32 8)
%9 = inttoptr i64 %8 to double*
%10 = tail call i64 @calloc(i32 16384, i32 8)
%11 = inttoptr i64 %10 to double*
%12 = tail call i64 @calloc(i32 16384, i32 8)
%13 = inttoptr i64 %12 to double*
%14 = tail call i64 @calloc(i32 16900, i32 8)
%15 = inttoptr i64 %14 to double*
%16 = tail call i64 @calloc(i32 16900, i32 8)
%17 = inttoptr i64 %16 to double*
%18 = tail call i32 @fill_coeffs(i32 128, i32 128, double 1.000000e+00, double 7.812500e-03, double 7.812500e-03, double 1.000000e-02, double 1.000000e+00, double* %3, double* %5, double* %7, double* %9, double* %11, double* %13)
%19 = inttoptr i64 %16 to i8*
%20 = inttoptr i64 %14 to i8*
%21 = getelementptr double, double* %15, i64 16900
%22 = bitcast double* %21 to i8*
%23 = getelementptr double, double* %17, i64 16900
%24 = bitcast double* %23 to i8*
%25 = icmp ult i8* %20, %24
%26 = icmp ult i8* %19, %22
%27 = and i1 %25, %26
br i1 %27, label %79, label %28
28: ; preds = %0, %28
%29 = phi i64 [ %74, %28 ], [ 0, %0 ]
%30 = getelementptr inbounds double, double* %15, i64 %29
%31 = bitcast double* %30 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %31
%32 = getelementptr inbounds double, double* %30, i64 2
%33 = bitcast double* %32 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %33
%34 = getelementptr inbounds double, double* %17, i64 %29
%35 = bitcast double* %34 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %35
%36 = getelementptr inbounds double, double* %34, i64 2
%37 = bitcast double* %36 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %37
%38 = add nuw nsw i64 %29, 4
%39 = getelementptr inbounds double, double* %15, i64 %38
%40 = bitcast double* %39 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %40
%41 = getelementptr inbounds double, double* %39, i64 2
%42 = bitcast double* %41 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %42
%43 = getelementptr inbounds double, double* %17, i64 %38
%44 = bitcast double* %43 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %44
%45 = getelementptr inbounds double, double* %43, i64 2
%46 = bitcast double* %45 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %46
%47 = add nuw nsw i64 %29, 8
%48 = getelementptr inbounds double, double* %15, i64 %47
%49 = bitcast double* %48 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %49
%50 = getelementptr inbounds double, double* %48, i64 2
%51 = bitcast double* %50 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %51
%52 = getelementptr inbounds double, double* %17, i64 %47
%53 = bitcast double* %52 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %53
%54 = getelementptr inbounds double, double* %52, i64 2
%55 = bitcast double* %54 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %55
%56 = add nuw nsw i64 %29, 12
%57 = getelementptr inbounds double, double* %15, i64 %56
%58 = bitcast double* %57 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %58
%59 = getelementptr inbounds double, double* %57, i64 2
%60 = bitcast double* %59 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %60
%61 = getelementptr inbounds double, double* %17, i64 %56
%62 = bitcast double* %61 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %62
%63 = getelementptr inbounds double, double* %61, i64 2
%64 = bitcast double* %63 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %64
%65 = add nuw nsw i64 %29, 16
%66 = getelementptr inbounds double, double* %15, i64 %65
%67 = bitcast double* %66 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %67
%68 = getelementptr inbounds double, double* %66, i64 2
%69 = bitcast double* %68 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %69
%70 = getelementptr inbounds double, double* %17, i64 %65
%71 = bitcast double* %70 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %71
%72 = getelementptr inbounds double, double* %70, i64 2
%73 = bitcast double* %72 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %73
%74 = add nuw nsw i64 %29, 20
%75 = icmp eq i64 %74, 16900
br i1 %75, label %76, label %28
76: ; preds = %28, %79
%77 = tail call double (...) @clock()
%78 = bitcast double* %1 to i8*
br label %97
79: ; preds = %0, %79
%80 = phi i64 [ %95, %79 ], [ 0, %0 ]
%81 = getelementptr inbounds double, double* %15, i64 %80
store double 0.000000e+00, double* %81
%82 = getelementptr inbounds double, double* %17, i64 %80
store double 0.000000e+00, double* %82
%83 = add nuw nsw i64 %80, 1
%84 = getelementptr inbounds double, double* %15, i64 %83
store double 0.000000e+00, double* %84
%85 = getelementptr inbounds double, double* %17, i64 %83
store double 0.000000e+00, double* %85
%86 = add nuw nsw i64 %80, 2
%87 = getelementptr inbounds double, double* %15, i64 %86
store double 0.000000e+00, double* %87
%88 = getelementptr inbounds double, double* %17, i64 %86
store double 0.000000e+00, double* %88
%89 = add nuw nsw i64 %80, 3
%90 = getelementptr inbounds double, double* %15, i64 %89
store double 0.000000e+00, double* %90
%91 = getelementptr inbounds double, double* %17, i64 %89
store double 0.000000e+00, double* %91
%92 = add nuw nsw i64 %80, 4
%93 = getelementptr inbounds double, double* %15, i64 %92
store double 0.000000e+00, double* %93
%94 = getelementptr inbounds double, double* %17, i64 %92
store double 0.000000e+00, double* %94
%95 = add nuw nsw i64 %80, 5
%96 = icmp eq i64 %95, 16900
br i1 %96, label %76, label %79
97: ; preds = %76, %104
%98 = phi i32 [ 1, %76 ], [ %105, %104 ]
store double 0.000000e+00, double* %1
%99 = call i32 @gauss_seidel(double* %3, double* %5, double* %7, double* %9, double* %11, double* %13, double* %15, double* %1)
%100 = load double, double* %1
%101 = fmul double %100, 0x3F10000000000000
%102 = call double @sqrt(double %101)
%103 = fcmp olt double %102, 0x3EB0C6F7A0B5ED8D
br i1 %103, label %107, label %104
104: ; preds = %97
%105 = add nuw nsw i32 %98, 1
%106 = icmp eq i32 %105, 1000001
br i1 %106, label %107, label %97
107: ; preds = %97, %104
%108 = phi i32 [ %98, %97 ], [ 1000001, %104 ]
%109 = call double (...) @clock()
%110 = sitofp i32 %108 to double
%111 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), double %110)
%112 = fsub double %109, %77
%113 = load i64, i64* @CLOCKS_PER_SEC
%114 = sitofp i64 %113 to double
%115 = fdiv double %112, %114
%116 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double %115)
%117 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%118 = icmp eq i32* %117, null
br i1 %118, label %144, label %119
119: ; preds = %107
%120 = call i64 @fwrite(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i64 13, i64 1, i32* %117)
br label %121
121: ; preds = %119, %127
%122 = phi i64 [ 1, %119 ], [ %129, %127 ]
%123 = trunc i64 %122 to i32
%124 = add i32 %123, -1
%125 = sitofp i32 %124 to double
%126 = call double @llvm.fmuladd.f64(double %125, double 7.812500e-03, double 3.906250e-03)
br label %131
127: ; preds = %131
%128 = call i32 @fputc(i32 10, i32* %117)
%129 = add nuw nsw i64 %122, 1
%130 = icmp eq i64 %129, 129
br i1 %130, label %144, label %121
131: ; preds = %121, %131
%132 = phi i64 [ 1, %121 ], [ %142, %131 ]
%133 = mul nuw nsw i64 %132, 130
%134 = add nuw nsw i64 %133, %122
%135 = trunc i64 %132 to i32
%136 = add i32 %135, -1
%137 = sitofp i32 %136 to double
%138 = call double @llvm.fmuladd.f64(double %137, double 7.812500e-03, double 3.906250e-03)
%139 = getelementptr inbounds double, double* %15, i64 %134
%140 = load double, double* %139
%141 = call i32 (i32*, i8*, ...) @fprintf(i32* %117, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), double %138, double %126, double %140)
%142 = add nuw nsw i64 %132, 1
%143 = icmp eq i64 %142, 129
br i1 %143, label %127, label %131
144: ; preds = %127, %107
%145 = call i32 @fclose(i32* %117)
%146 = call i32 @free(double* %3)
%147 = call i32 @free(double* %5)
%148 = call i32 @free(double* %7)
%149 = call i32 @free(double* %9)
%150 = call i32 @free(double* %11)
%151 = call i32 @free(double* %13)
%152 = call i32 @free(double* %15)
%153 = call i32 @free(double* %17)
ret i32 0
}