#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 j;
typedef int i;

/* Variables and functions */
int /*<<< orphan*/ allocate(float **, float **, int const);
int atoi(char *);
int /*<<< orphan*/ free(float *);
int /*<<< orphan*/ initialize(float *, float *, float *, float const,
                              float const, int const);
int /*<<< orphan*/ printf(char *, double);
double seconds();
int /*<<< orphan*/ write(float *, int, int const);
int main(int argc, char **argv) {
  int t;
  double t1, t2, num_flops;
  int num_timesteps = 0;
  if (argc > 1)
    num_timesteps = atoi(argv[1]);
  if (num_timesteps == 0)
    num_timesteps = 1000;
  const int size = 128 + 4;
  const float min_x = -1.0f;
  const float max_x = 1.0f;
  const float dx = (max_x - min_x) / (128 + 1);
  const float dt = dx / 20.0f;
  const float dt_dx_square = dt * dt / (dx * dx);
  float *_U_0, *U_0;
  float *_U_m1, *U_m1;
  float *_U_1, *U_1;
  allocate(&_U_0, &U_0, size);
  allocate(&_U_m1, &U_m1, size);
  allocate(&_U_1, &U_1, size);
  initialize(U_m1, U_0, U_1, min_x, dx, size);
  write(U_0, 0, size);
  const float c0 = 2.0f - 7.5f * dt_dx_square;
  const float c1 = 4.0f / 3.0f * dt_dx_square;
  const float c2 = -1.0f / 12.0f * dt_dx_square;
  t1 = seconds();
  for (t = 0; t < num_timesteps; t++) {
    int i, j, k;
#pragma omp parallel for private(i, j, k)
    for (k = 2; k < size - 2; k++) {
      for (j = 2; j < size - 2; j++) {
        for (i = 2; i < size - 2; i++) {
          U_1[((i) + size * ((j) + size * (k)))] =
              c0 * U_0[((i) + size * ((j) + size * (k)))] -
              U_m1[((i) + size * ((j) + size * (k)))] +
              c1 * (U_0[((i + 1) + size * ((j) + size * (k)))] +
                    U_0[((i - 1) + size * ((j) + size * (k)))] +
                    U_0[((i) + size * ((j + 1) + size * (k)))] +
                    U_0[((i) + size * ((j - 1) + size * (k)))] +
                    U_0[((i) + size * ((j) + size * (k + 1)))] +
                    U_0[((i) + size * ((j) + size * (k - 1)))]) +
              c2 * (U_0[((i + 2) + size * ((j) + size * (k)))] +
                    U_0[((i - 2) + size * ((j) + size * (k)))] +
                    U_0[((i) + size * ((j + 2) + size * (k)))] +
                    U_0[((i) + size * ((j - 2) + size * (k)))] +
                    U_0[((i) + size * ((j) + size * (k + 2)))] +
                    U_0[((i) + size * ((j) + size * (k - 2)))]);
        }
      }
    }
    if (t % 10 == 0)
      write(U_1, t + 1, size);
    float *tmp = U_m1;
    U_m1 = U_0;
    U_0 = U_1;
    U_1 = tmp;
  }
  t2 = seconds();
  num_flops = (double)(size - 4) * (double)(size - 4) * (double)(size - 4) *
              num_timesteps * 16.0;
  printf("Flops in stencil code:      %e\n", num_flops);
  printf("Time spent in stencil code: %f\n", t2 - t1);
  printf("Performance in GFlop/s:     %f\n", num_flops / (1e9 * (t2 - t1)));
  free(_U_m1);
  free(_U_0);
  free(_U_1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11aa <main+0x3a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    11bb <main+0x4b>
movl   $0x3e8,-0x34(%rbp)
movl   $0x84,-0x38(%rbp)
movss  0xe42(%rip),%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  0xe45(%rip),%xmm0
movss  %xmm0,-0x40(%rbp)
movss  0xe2c(%rip),%xmm0
movss  %xmm0,-0x44(%rbp)
movss  0xe27(%rip),%xmm0
movss  %xmm0,-0x48(%rbp)
movss  0xe16(%rip),%xmm0
movss  %xmm0,-0x4c(%rbp)
lea    -0x58(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    $0x84,%edx
call   1090 <allocate@plt>
lea    -0x68(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    $0x84,%edx
call   1090 <allocate@plt>
lea    -0x78(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x84,%edx
call   1090 <allocate@plt>
mov    -0x70(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x80(%rbp),%rdx
movss  0xdbf(%rip),%xmm0
movss  0xdbb(%rip),%xmm1
mov    $0x84,%ecx
call   1070 <initialize@plt>
mov    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x84,%edx
call   1040 <write@plt>
movss  0xd91(%rip),%xmm0
movss  %xmm0,-0x84(%rbp)
ff
movss  0xd7d(%rip),%xmm0
movss  %xmm0,-0x88(%rbp)
ff
movss  0xd69(%rip),%xmm0
movss  %xmm0,-0x8c(%rbp)
ff
mov    $0x0,%al
call   1050 <seconds@plt>
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    16ab <main+0x53b>
movl   $0x2,-0x98(%rbp)
cmpl   $0x82,-0x98(%rbp)
jge    164f <main+0x4df>
movl   $0x2,-0x94(%rbp)
cmpl   $0x82,-0x94(%rbp)
jge    1636 <main+0x4c6>
movl   $0x2,-0x90(%rbp)
cmpl   $0x82,-0x90(%rbp)
jge    161d <main+0x4ad>
mov    -0x60(%rbp),%rax
mov    -0x90(%rbp),%ecx
mov    -0x94(%rbp),%edx
imul   $0x84,-0x98(%rbp),%esi
add    %esi,%edx
imul   $0x84,%edx,%edx
add    %edx,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x70(%rbp),%rax
mov    -0x90(%rbp),%ecx
mov    -0x94(%rbp),%edx
imul   $0x84,-0x98(%rbp),%esi
add    %esi,%edx
imul   $0x84,%edx,%edx
add    %edx,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
movss  0xc8f(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x60(%rbp),%rax
mov    -0x90(%rbp),%ecx
add    $0x1,%ecx
mov    -0x94(%rbp),%edx
imul   $0x84,-0x98(%rbp),%esi
add    %esi,%edx
imul   $0x84,%edx,%edx
add    %edx,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm1
mov    -0x60(%rbp),%rax
mov    -0x90(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x94(%rbp),%edx
imul   $0x84,-0x98(%rbp),%esi
add    %esi,%edx
imul   $0x84,%edx,%edx
add    %edx,%ecx
movslq %ecx,%rcx
addss  (%rax,%rcx,4),%xmm1
mov    -0x60(%rbp),%rax
mov    -0x90(%rbp),%ecx
mov    -0x94(%rbp),%edx
add    $0x1,%edx
imul   $0x84,-0x98(%rbp),%esi
add    %esi,%edx
imul   $0x84,%edx,%edx
add    %edx,%ecx
movslq %ecx,%rcx
addss  (%rax,%rcx,4),%xmm1
mov    -0x60(%rbp),%rax
mov    -0x90(%rbp),%ecx
mov    -0x94(%rbp),%edx
sub    $0x1,%edx
imul   $0x84,-0x98(%rbp),%esi
add    %esi,%edx
imul   $0x84,%edx,%edx
add    %edx,%ecx
movslq %ecx,%rcx
addss  (%rax,%rcx,4),%xmm1
mov    -0x60(%rbp),%rax
mov    -0x90(%rbp),%ecx
mov    -0x94(%rbp),%edx
mov    -0x98(%rbp),%esi
add    $0x1,%esi
imul   $0x84,%esi,%esi
add    %esi,%edx
imul   $0x84,%edx,%edx
add    %edx,%ecx
movslq %ecx,%rcx
addss  (%rax,%rcx,4),%xmm1
mov    -0x60(%rbp),%rax
mov    -0x90(%rbp),%ecx
mov    -0x94(%rbp),%edx
mov    -0x98(%rbp),%esi
sub    $0x1,%esi
imul   $0x84,%esi,%esi
add    %esi,%edx
imul   $0x84,%edx,%edx
add    %edx,%ecx
movslq %ecx,%rcx
addss  (%rax,%rcx,4),%xmm1
movss  0xb5d(%rip),%xmm2
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
mov    -0x60(%rbp),%rax
mov    -0x90(%rbp),%ecx
add    $0x2,%ecx
mov    -0x94(%rbp),%edx
imul   $0x84,-0x98(%rbp),%esi
add    %esi,%edx
imul   $0x84,%edx,%edx
add    %edx,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x60(%rbp),%rax
mov    -0x90(%rbp),%ecx
sub    $0x2,%ecx
mov    -0x94(%rbp),%edx
imul   $0x84,-0x98(%rbp),%esi
add    %esi,%edx
imul   $0x84,%edx,%edx
add    %edx,%ecx
movslq %ecx,%rcx
addss  (%rax,%rcx,4),%xmm0
mov    -0x60(%rbp),%rax
mov    -0x90(%rbp),%ecx
mov    -0x94(%rbp),%edx
add    $0x2,%edx
imul   $0x84,-0x98(%rbp),%esi
add    %esi,%edx
imul   $0x84,%edx,%edx
add    %edx,%ecx
movslq %ecx,%rcx
addss  (%rax,%rcx,4),%xmm0
mov    -0x60(%rbp),%rax
mov    -0x90(%rbp),%ecx
mov    -0x94(%rbp),%edx
sub    $0x2,%edx
imul   $0x84,-0x98(%rbp),%esi
add    %esi,%edx
imul   $0x84,%edx,%edx
add    %edx,%ecx
movslq %ecx,%rcx
addss  (%rax,%rcx,4),%xmm0
mov    -0x60(%rbp),%rax
mov    -0x90(%rbp),%ecx
mov    -0x94(%rbp),%edx
mov    -0x98(%rbp),%esi
add    $0x2,%esi
imul   $0x84,%esi,%esi
add    %esi,%edx
imul   $0x84,%edx,%edx
add    %edx,%ecx
movslq %ecx,%rcx
addss  (%rax,%rcx,4),%xmm0
mov    -0x60(%rbp),%rax
mov    -0x90(%rbp),%ecx
mov    -0x94(%rbp),%edx
mov    -0x98(%rbp),%esi
sub    $0x2,%esi
imul   $0x84,%esi,%esi
add    %esi,%edx
imul   $0x84,%edx,%edx
add    %edx,%ecx
movslq %ecx,%rcx
addss  (%rax,%rcx,4),%xmm0
movss  0xa2b(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x80(%rbp),%rax
mov    -0x90(%rbp),%ecx
mov    -0x94(%rbp),%edx
imul   $0x84,-0x98(%rbp),%esi
add    %esi,%edx
imul   $0x84,%edx,%edx
add    %edx,%ecx
movslq %ecx,%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x90(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x90(%rbp)
jmp    12fc <main+0x18c>
jmp    1622 <main+0x4b2>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    12e2 <main+0x172>
jmp    163b <main+0x4cb>
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    12c8 <main+0x158>
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1677 <main+0x507>
mov    -0x80(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    $0x84,%edx
call   1040 <write@plt>
mov    -0x70(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x80(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0xa0(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12b2 <main+0x142>
mov    $0x0,%al
call   1050 <seconds@plt>
movsd  %xmm0,-0x28(%rbp)
cvtsi2sdl -0x34(%rbp),%xmm1
movsd  0x96c(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0x958(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
lea    0x953(%rip),%rdi
call   1060 <printf@plt>
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
lea    0x95d(%rip),%rdi
call   1060 <printf@plt>
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
subsd  -0x20(%rbp),%xmm2
movsd  0x909(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
lea    0x952(%rip),%rdi
call   1060 <printf@plt>
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x78(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x50,%rsp
cmp    $0x2,%edi
jl     1191 <main+0x21>
mov    0x8(%rsi),%rdi
call   1080 <atoi@plt>
mov    %eax,%r14d
test   %eax,%eax
jne    1197 <main+0x27>
mov    $0x3e8,%r14d
lea    0x48(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    $0x84,%edx
call   1090 <allocate@plt>
lea    0x40(%rsp),%rdi
lea    0x18(%rsp),%rsi
mov    $0x84,%edx
call   1090 <allocate@plt>
lea    0x38(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    $0x84,%edx
call   1090 <allocate@plt>
mov    0x18(%rsp),%rdi
mov    0x8(%rsp),%rsi
mov    0x10(%rsp),%rdx
movss  0xe16(%rip),%xmm0
movss  0xe12(%rip),%xmm1
mov    $0x84,%ecx
call   1070 <initialize@plt>
mov    0x8(%rsp),%rdi
xor    %r15d,%r15d
xor    %esi,%esi
mov    $0x84,%edx
call   1040 <write@plt>
xor    %eax,%eax
call   1050 <seconds@plt>
movsd  %xmm0,0x30(%rsp)
test   %r14d,%r14d
jle    13ed <main+0x27d>
mov    0x8(%rsp),%r8
mov    0x18(%rsp),%r9
mov    0x10(%rsp),%rdi
movss  0xdcb(%rip),%xmm3
movss  0xdc7(%rip),%xmm4
movss  0xdc3(%rip),%xmm5
jmp    1274 <main+0x104>
nop
mov    %rdi,%rax
mov    %r8,0x18(%rsp)
mov    %rdi,0x8(%rsp)
mov    %r9,0x10(%rsp)
mov    %r9,%rdi
mov    %r8,%r9
mov    %rax,%r8
cmp    %r14d,%r15d
je     13ed <main+0x27d>
lea    0x428(%r8),%r10
lea    0x224a8(%rdi),%r11
lea    0x224a8(%r9),%rax
mov    $0x2,%r12d
nop
mov    %rax,%rbp
mov    %r11,%rsi
mov    %r10,%rdx
mov    $0x2,%ecx
xchg   %ax,%ax
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movss  0x22084(%rdx,%rbx,1),%xmm0
movss  0x22080(%rdx,%rbx,1),%xmm1
mulss  %xmm3,%xmm1
subss  0x0(%rbp,%rbx,1),%xmm1
addss  0x2207c(%rdx,%rbx,1),%xmm0
addss  0x22290(%rdx,%rbx,1),%xmm0
addss  0x21e70(%rdx,%rbx,1),%xmm0
addss  0x330c0(%rdx,%rbx,1),%xmm0
addss  0x11040(%rdx,%rbx,1),%xmm0
mulss  %xmm4,%xmm0
movss  0x22088(%rdx,%rbx,1),%xmm2
addss  0x22078(%rdx,%rbx,1),%xmm2
addss  0x224a0(%rdx,%rbx,1),%xmm2
addss  0x21c60(%rdx,%rbx,1),%xmm2
addss  0x44100(%rdx,%rbx,1),%xmm2
addss  %xmm1,%xmm0
addss  (%rdx,%rbx,1),%xmm2
mulss  %xmm5,%xmm2
addss  %xmm0,%xmm2
movss  %xmm2,(%rsi,%rbx,1)
add    $0x4,%rbx
cmp    $0x200,%rbx
jne    12b0 <main+0x140>
add    $0x1,%rcx
add    $0x210,%rdx
add    $0x210,%rsi
add    $0x210,%rbp
cmp    $0x82,%rcx
jne    12a0 <main+0x130>
add    $0x1,%r12
add    $0x11040,%r10
add    $0x11040,%r11
add    $0x11040,%rax
cmp    $0x82,%r12
jne    1290 <main+0x120>
imul   $0xcccccccd,%r15d,%eax
ror    %eax
add    $0x1,%r15d
cmp    $0x19999999,%eax
ja     1250 <main+0xe0>
mov    %r15d,%esi
mov    $0x84,%edx
call   1040 <write@plt>
movss  0xc47(%rip),%xmm5
movss  0xc3b(%rip),%xmm4
movss  0xc2f(%rip),%xmm3
mov    0x18(%rsp),%r9
mov    0x8(%rsp),%r8
mov    0x10(%rsp),%rdi
jmp    1250 <main+0xe0>
xor    %eax,%eax
call   1050 <seconds@plt>
movsd  %xmm0,0x20(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
mulsd  0xc0e(%rip),%xmm0
mulsd  0xc0e(%rip),%xmm0
movsd  %xmm0,0x28(%rsp)
lea    0xc11(%rip),%rdi
call   1060 <printf@plt>
movsd  0x20(%rsp),%xmm0
subsd  0x30(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
lea    0xc13(%rip),%rdi
call   1060 <printf@plt>
movsd  0x20(%rsp),%xmm1
mulsd  0xbd8(%rip),%xmm1
movsd  0x28(%rsp),%xmm0
divsd  %xmm1,%xmm0
lea    0xc0f(%rip),%rdi
call   1060 <printf@plt>
mov    0x40(%rsp),%rdi
call   1030 <free@plt>
mov    0x48(%rsp),%rdi
call   1030 <free@plt>
mov    0x38(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Flops in stencil code: %e\0A\00"
@.str.1 = [32 x i8] c"Time spent in stencil code: %f\0A\00"
@.str.2 = [32 x i8] c"Performance in GFlop/s: %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float*
%18 = alloca float*
%19 = alloca float*
%20 = alloca float*
%21 = alloca float*
%22 = alloca float*
%23 = alloca float
%24 = alloca float
%25 = alloca float
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
%29 = alloca float*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %10
%30 = load i32, i32* %4
%31 = icmp sgt i32 %30, 1
br i1 %31, label %32, label %37
32: ; preds = %2
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32 @atoi(i8* %35)
store i32 %36, i32* %10
br label %37
37: ; preds = %32, %2
%38 = load i32, i32* %10
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %37
store i32 1000, i32* %10
br label %41
41: ; preds = %40, %37
store i32 132, i32* %11
store float -1.000000e+00, float* %12
store float 1.000000e+00, float* %13
store float 0x3F8FC07F00000000, float* %14
store float 0x3F4966CC00000000, float* %15
store float 0x3F647AE160000000, float* %16
%42 = call i32 @allocate(float** %17, float** %18, i32 132)
%43 = call i32 @allocate(float** %19, float** %20, i32 132)
%44 = call i32 @allocate(float** %21, float** %22, i32 132)
%45 = load float*, float** %20
%46 = load float*, float** %18
%47 = load float*, float** %22
%48 = call i32 @initialize(float* %45, float* %46, float* %47, float -1.000000e+00, float 0x3F8FC07F00000000, i32 132)
%49 = load float*, float** %18
%50 = call i32 @write(float* %49, i32 0, i32 132)
store float 0x3FFFB33340000000, float* %23
store float 0x3F6B4E81E0000000, float* %24
store float 0xBF2B4E81E0000000, float* %25
%51 = call double (...) @seconds()
store double %51, double* %7
store i32 0, i32* %6
br label %52
52: ; preds = %284, %41
%53 = load i32, i32* %6
%54 = load i32, i32* %10
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %287
56: ; preds = %52
store i32 2, i32* %28
br label %57
57: ; preds = %267, %56
%58 = load i32, i32* %28
%59 = icmp slt i32 %58, 130
br i1 %59, label %60, label %270
60: ; preds = %57
store i32 2, i32* %27
br label %61
61: ; preds = %263, %60
%62 = load i32, i32* %27
%63 = icmp slt i32 %62, 130
br i1 %63, label %64, label %266
64: ; preds = %61
store i32 2, i32* %26
br label %65
65: ; preds = %259, %64
%66 = load i32, i32* %26
%67 = icmp slt i32 %66, 130
br i1 %67, label %68, label %262
68: ; preds = %65
%69 = load float*, float** %18
%70 = load i32, i32* %26
%71 = load i32, i32* %27
%72 = load i32, i32* %28
%73 = mul nsw i32 132, %72
%74 = add nsw i32 %71, %73
%75 = mul nsw i32 132, %74
%76 = add nsw i32 %70, %75
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds float, float* %69, i64 %77
%79 = load float, float* %78
%80 = load float*, float** %20
%81 = load i32, i32* %26
%82 = load i32, i32* %27
%83 = load i32, i32* %28
%84 = mul nsw i32 132, %83
%85 = add nsw i32 %82, %84
%86 = mul nsw i32 132, %85
%87 = add nsw i32 %81, %86
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds float, float* %80, i64 %88
%90 = load float, float* %89
%91 = fneg float %90
%92 = call float @llvm.fmuladd.f32(float 0x3FFFB33340000000, float %79, float %91)
%93 = load float*, float** %18
%94 = load i32, i32* %26
%95 = add nsw i32 %94, 1
%96 = load i32, i32* %27
%97 = load i32, i32* %28
%98 = mul nsw i32 132, %97
%99 = add nsw i32 %96, %98
%100 = mul nsw i32 132, %99
%101 = add nsw i32 %95, %100
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds float, float* %93, i64 %102
%104 = load float, float* %103
%105 = load float*, float** %18
%106 = load i32, i32* %26
%107 = sub nsw i32 %106, 1
%108 = load i32, i32* %27
%109 = load i32, i32* %28
%110 = mul nsw i32 132, %109
%111 = add nsw i32 %108, %110
%112 = mul nsw i32 132, %111
%113 = add nsw i32 %107, %112
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds float, float* %105, i64 %114
%116 = load float, float* %115
%117 = fadd float %104, %116
%118 = load float*, float** %18
%119 = load i32, i32* %26
%120 = load i32, i32* %27
%121 = add nsw i32 %120, 1
%122 = load i32, i32* %28
%123 = mul nsw i32 132, %122
%124 = add nsw i32 %121, %123
%125 = mul nsw i32 132, %124
%126 = add nsw i32 %119, %125
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds float, float* %118, i64 %127
%129 = load float, float* %128
%130 = fadd float %117, %129
%131 = load float*, float** %18
%132 = load i32, i32* %26
%133 = load i32, i32* %27
%134 = sub nsw i32 %133, 1
%135 = load i32, i32* %28
%136 = mul nsw i32 132, %135
%137 = add nsw i32 %134, %136
%138 = mul nsw i32 132, %137
%139 = add nsw i32 %132, %138
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds float, float* %131, i64 %140
%142 = load float, float* %141
%143 = fadd float %130, %142
%144 = load float*, float** %18
%145 = load i32, i32* %26
%146 = load i32, i32* %27
%147 = load i32, i32* %28
%148 = add nsw i32 %147, 1
%149 = mul nsw i32 132, %148
%150 = add nsw i32 %146, %149
%151 = mul nsw i32 132, %150
%152 = add nsw i32 %145, %151
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds float, float* %144, i64 %153
%155 = load float, float* %154
%156 = fadd float %143, %155
%157 = load float*, float** %18
%158 = load i32, i32* %26
%159 = load i32, i32* %27
%160 = load i32, i32* %28
%161 = sub nsw i32 %160, 1
%162 = mul nsw i32 132, %161
%163 = add nsw i32 %159, %162
%164 = mul nsw i32 132, %163
%165 = add nsw i32 %158, %164
%166 = sext i32 %165 to i64
%167 = getelementptr inbounds float, float* %157, i64 %166
%168 = load float, float* %167
%169 = fadd float %156, %168
%170 = call float @llvm.fmuladd.f32(float 0x3F6B4E81E0000000, float %169, float %92)
%171 = load float*, float** %18
%172 = load i32, i32* %26
%173 = add nsw i32 %172, 2
%174 = load i32, i32* %27
%175 = load i32, i32* %28
%176 = mul nsw i32 132, %175
%177 = add nsw i32 %174, %176
%178 = mul nsw i32 132, %177
%179 = add nsw i32 %173, %178
%180 = sext i32 %179 to i64
%181 = getelementptr inbounds float, float* %171, i64 %180
%182 = load float, float* %181
%183 = load float*, float** %18
%184 = load i32, i32* %26
%185 = sub nsw i32 %184, 2
%186 = load i32, i32* %27
%187 = load i32, i32* %28
%188 = mul nsw i32 132, %187
%189 = add nsw i32 %186, %188
%190 = mul nsw i32 132, %189
%191 = add nsw i32 %185, %190
%192 = sext i32 %191 to i64
%193 = getelementptr inbounds float, float* %183, i64 %192
%194 = load float, float* %193
%195 = fadd float %182, %194
%196 = load float*, float** %18
%197 = load i32, i32* %26
%198 = load i32, i32* %27
%199 = add nsw i32 %198, 2
%200 = load i32, i32* %28
%201 = mul nsw i32 132, %200
%202 = add nsw i32 %199, %201
%203 = mul nsw i32 132, %202
%204 = add nsw i32 %197, %203
%205 = sext i32 %204 to i64
%206 = getelementptr inbounds float, float* %196, i64 %205
%207 = load float, float* %206
%208 = fadd float %195, %207
%209 = load float*, float** %18
%210 = load i32, i32* %26
%211 = load i32, i32* %27
%212 = sub nsw i32 %211, 2
%213 = load i32, i32* %28
%214 = mul nsw i32 132, %213
%215 = add nsw i32 %212, %214
%216 = mul nsw i32 132, %215
%217 = add nsw i32 %210, %216
%218 = sext i32 %217 to i64
%219 = getelementptr inbounds float, float* %209, i64 %218
%220 = load float, float* %219
%221 = fadd float %208, %220
%222 = load float*, float** %18
%223 = load i32, i32* %26
%224 = load i32, i32* %27
%225 = load i32, i32* %28
%226 = add nsw i32 %225, 2
%227 = mul nsw i32 132, %226
%228 = add nsw i32 %224, %227
%229 = mul nsw i32 132, %228
%230 = add nsw i32 %223, %229
%231 = sext i32 %230 to i64
%232 = getelementptr inbounds float, float* %222, i64 %231
%233 = load float, float* %232
%234 = fadd float %221, %233
%235 = load float*, float** %18
%236 = load i32, i32* %26
%237 = load i32, i32* %27
%238 = load i32, i32* %28
%239 = sub nsw i32 %238, 2
%240 = mul nsw i32 132, %239
%241 = add nsw i32 %237, %240
%242 = mul nsw i32 132, %241
%243 = add nsw i32 %236, %242
%244 = sext i32 %243 to i64
%245 = getelementptr inbounds float, float* %235, i64 %244
%246 = load float, float* %245
%247 = fadd float %234, %246
%248 = call float @llvm.fmuladd.f32(float 0xBF2B4E81E0000000, float %247, float %170)
%249 = load float*, float** %22
%250 = load i32, i32* %26
%251 = load i32, i32* %27
%252 = load i32, i32* %28
%253 = mul nsw i32 132, %252
%254 = add nsw i32 %251, %253
%255 = mul nsw i32 132, %254
%256 = add nsw i32 %250, %255
%257 = sext i32 %256 to i64
%258 = getelementptr inbounds float, float* %249, i64 %257
store float %248, float* %258
br label %259
259: ; preds = %68
%260 = load i32, i32* %26
%261 = add nsw i32 %260, 1
store i32 %261, i32* %26
br label %65
262: ; preds = %65
br label %263
263: ; preds = %262
%264 = load i32, i32* %27
%265 = add nsw i32 %264, 1
store i32 %265, i32* %27
br label %61
266: ; preds = %61
br label %267
267: ; preds = %266
%268 = load i32, i32* %28
%269 = add nsw i32 %268, 1
store i32 %269, i32* %28
br label %57
270: ; preds = %57
%271 = load i32, i32* %6
%272 = srem i32 %271, 10
%273 = icmp eq i32 %272, 0
br i1 %273, label %274, label %279
274: ; preds = %270
%275 = load float*, float** %22
%276 = load i32, i32* %6
%277 = add nsw i32 %276, 1
%278 = call i32 @write(float* %275, i32 %277, i32 132)
br label %279
279: ; preds = %274, %270
%280 = load float*, float** %20
store float* %280, float** %29
%281 = load float*, float** %18
store float* %281, float** %20
%282 = load float*, float** %22
store float* %282, float** %18
%283 = load float*, float** %29
store float* %283, float** %22
br label %284
284: ; preds = %279
%285 = load i32, i32* %6
%286 = add nsw i32 %285, 1
store i32 %286, i32* %6
br label %52
287: ; preds = %52
%288 = call double (...) @seconds()
store double %288, double* %8
%289 = load i32, i32* %10
%290 = sitofp i32 %289 to double
%291 = fmul double 0x4140000000000000, %290
%292 = fmul double %291, 1.600000e+01
store double %292, double* %9
%293 = load double, double* %9
%294 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), double %293)
%295 = load double, double* %8
%296 = load double, double* %7
%297 = fsub double %295, %296
%298 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), double %297)
%299 = load double, double* %9
%300 = load double, double* %8
%301 = load double, double* %7
%302 = fsub double %300, %301
%303 = fmul double 1.000000e+09, %302
%304 = fdiv double %299, %303
%305 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), double %304)
%306 = load float*, float** %19
%307 = call i32 @free(float* %306)
%308 = load float*, float** %17
%309 = call i32 @free(float* %308)
%310 = load float*, float** %21
%311 = call i32 @free(float* %310)
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c"Flops in stencil code: %e\0A\00"
@.str.1 = [32 x i8] c"Time spent in stencil code: %f\0A\00"
@.str.2 = [32 x i8] c"Performance in GFlop/s: %f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca float*
%4 = alloca float*
%5 = alloca float*
%6 = alloca float*
%7 = alloca float*
%8 = alloca float*
%9 = icmp sgt i32 %0, 1
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %2, %10
br label %16
16: ; preds = %10, %15
%17 = phi i32 [ 1000, %15 ], [ %13, %10 ]
%18 = bitcast float** %3 to i8*
%19 = bitcast float** %4 to i8*
%20 = bitcast float** %5 to i8*
%21 = bitcast float** %6 to i8*
%22 = bitcast float** %7 to i8*
%23 = bitcast float** %8 to i8*
%24 = call i32 @allocate(float** %3, float** %4, i32 132)
%25 = call i32 @allocate(float** %5, float** %6, i32 132)
%26 = call i32 @allocate(float** %7, float** %8, i32 132)
%27 = load float*, float** %6
%28 = load float*, float** %4
%29 = load float*, float** %8
%30 = call i32 @initialize(float* %27, float* %28, float* %29, float -1.000000e+00, float 0x3F8FC07F00000000, i32 132)
%31 = load float*, float** %4
%32 = call i32 @write(float* %31, i32 0, i32 132)
%33 = call double (...) @seconds()
%34 = icmp sgt i32 %17, 0
br i1 %34, label %35, label %139
35: ; preds = %16
%36 = load float*, float** %4
%37 = load float*, float** %6
%38 = load float*, float** %8
br label %39
39: ; preds = %35, %134
%40 = phi float* [ %137, %134 ], [ %38, %35 ]
%41 = phi float* [ %136, %134 ], [ %37, %35 ]
%42 = phi float* [ %135, %134 ], [ %36, %35 ]
%43 = phi i32 [ %128, %134 ], [ 0, %35 ]
br label %44
44: ; preds = %39, %122
%45 = phi i64 [ 2, %39 ], [ %123, %122 ]
%46 = mul nuw nsw i64 %45, 132
br label %47
47: ; preds = %44, %119
%48 = phi i64 [ 2, %44 ], [ %120, %119 ]
%49 = add nuw nsw i64 %48, %46
%50 = mul nuw nsw i64 %49, 132
%51 = add nuw nsw i64 %50, 132
%52 = add nsw i64 %50, -132
%53 = add nuw nsw i64 %50, 17424
%54 = add nsw i64 %50, -17424
%55 = add nuw nsw i64 %50, 264
%56 = add nsw i64 %50, -264
%57 = add nuw nsw i64 %50, 34848
%58 = add nsw i64 %50, -34848
br label %59
59: ; preds = %47, %59
%60 = phi i64 [ 2, %47 ], [ %68, %59 ]
%61 = add nuw nsw i64 %60, %50
%62 = getelementptr inbounds float, float* %42, i64 %61
%63 = load float, float* %62
%64 = getelementptr inbounds float, float* %41, i64 %61
%65 = load float, float* %64
%66 = fneg float %65
%67 = call float @llvm.fmuladd.f32(float %63, float 0x3FFFB33340000000, float %66)
%68 = add nuw nsw i64 %60, 1
%69 = add nuw nsw i64 %68, %50
%70 = getelementptr inbounds float, float* %42, i64 %69
%71 = load float, float* %70
%72 = add nsw i64 %61, -1
%73 = getelementptr inbounds float, float* %42, i64 %72
%74 = load float, float* %73
%75 = fadd float %71, %74
%76 = add nuw nsw i64 %60, %51
%77 = getelementptr inbounds float, float* %42, i64 %76
%78 = load float, float* %77
%79 = fadd float %75, %78
%80 = add nuw nsw i64 %60, %52
%81 = getelementptr inbounds float, float* %42, i64 %80
%82 = load float, float* %81
%83 = fadd float %79, %82
%84 = add nuw nsw i64 %60, %53
%85 = getelementptr inbounds float, float* %42, i64 %84
%86 = load float, float* %85
%87 = fadd float %83, %86
%88 = add nuw nsw i64 %60, %54
%89 = getelementptr inbounds float, float* %42, i64 %88
%90 = load float, float* %89
%91 = fadd float %87, %90
%92 = call float @llvm.fmuladd.f32(float %91, float 0x3F6B4E81E0000000, float %67)
%93 = add nuw nsw i64 %61, 2
%94 = getelementptr inbounds float, float* %42, i64 %93
%95 = load float, float* %94
%96 = add nsw i64 %61, -2
%97 = getelementptr inbounds float, float* %42, i64 %96
%98 = load float, float* %97
%99 = fadd float %95, %98
%100 = add nuw nsw i64 %60, %55
%101 = getelementptr inbounds float, float* %42, i64 %100
%102 = load float, float* %101
%103 = fadd float %99, %102
%104 = add nuw nsw i64 %60, %56
%105 = getelementptr inbounds float, float* %42, i64 %104
%106 = load float, float* %105
%107 = fadd float %103, %106
%108 = add nuw nsw i64 %60, %57
%109 = getelementptr inbounds float, float* %42, i64 %108
%110 = load float, float* %109
%111 = fadd float %107, %110
%112 = add nuw nsw i64 %60, %58
%113 = getelementptr inbounds float, float* %42, i64 %112
%114 = load float, float* %113
%115 = fadd float %111, %114
%116 = call float @llvm.fmuladd.f32(float %115, float 0xBF2B4E81E0000000, float %92)
%117 = getelementptr inbounds float, float* %40, i64 %61
store float %116, float* %117
%118 = icmp eq i64 %68, 130
br i1 %118, label %119, label %59
119: ; preds = %59
%120 = add nuw nsw i64 %48, 1
%121 = icmp eq i64 %120, 130
br i1 %121, label %122, label %47
122: ; preds = %119
%123 = add nuw nsw i64 %45, 1
%124 = icmp eq i64 %123, 130
br i1 %124, label %125, label %44
125: ; preds = %122
%126 = urem i32 %43, 10
%127 = icmp eq i32 %126, 0
%128 = add nuw nsw i32 %43, 1
br i1 %127, label %129, label %134
129: ; preds = %125
%130 = call i32 @write(float* %40, i32 %128, i32 132)
%131 = load float*, float** %6
%132 = load float*, float** %4
%133 = load float*, float** %8
br label %134
134: ; preds = %125, %129
%135 = phi float* [ %133, %129 ], [ %40, %125 ]
%136 = phi float* [ %132, %129 ], [ %42, %125 ]
%137 = phi float* [ %131, %129 ], [ %41, %125 ]
store float* %136, float** %6
store float* %135, float** %4
store float* %137, float** %8
%138 = icmp eq i32 %128, %17
br i1 %138, label %139, label %39
139: ; preds = %134, %16
%140 = call double (...) @seconds()
%141 = sitofp i32 %17 to double
%142 = fmul double %141, 0x4140000000000000
%143 = fmul double %142, 1.600000e+01
%144 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), double %143)
%145 = fsub double %140, %33
%146 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), double %145)
%147 = fmul double %145, 1.000000e+09
%148 = fdiv double %143, %147
%149 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), double %148)
%150 = load float*, float** %5
%151 = call i32 @free(float* %150)
%152 = load float*, float** %3
%153 = call i32 @free(float* %152)
%154 = load float*, float** %7
%155 = call i32 @free(float* %154)
ret i32 0
}