#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*/ checkForbiddenPatterns(int **, int *);
int /*<<< orphan*/ free_imatrix(int **, int /*<<< orphan*/, int,
                                int /*<<< orphan*/, int);
int /*<<< orphan*/ initialiseCell(double *, double *, int *, int *, int, int,
                                  int, int);
int /*<<< orphan*/ printf(char *, ...);
int **read_pgm(char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void initialiseFields(double *collideField, double *streamField, int *flagField,
                      int *length, int *boundaries, char *argv[]) {
  int x, y, z;
  int **image;
  char filename[20];
  strcpy(filename, argv[1]);
  strcat(filename, ".pgm");
  image = read_pgm(filename);
  checkForbiddenPatterns(image, length);
  for (z = 0; z <= length[0]; z++) {
    for (x = 0; x <= length[2]; x++) {
      printf("%d ", image[x][z]);
    }
    printf("\n");
  }
  z = 0;
  for (y = 0; y <= length[1] + 1; ++y) {
    for (x = 0; x <= length[2] + 1; ++x) {
      initialiseCell(collideField, streamField, flagField, length, x, y, z,
                     boundaries[4]);
    }
  }
  for (z = 1; z <= length[0]; ++z) {
    y = 0;
    for (x = 0; x <= length[2] + 1; ++x) {
      initialiseCell(collideField, streamField, flagField, length, x, y, z,
                     boundaries[2]);
    }
    for (y = 1; y <= length[1]; ++y) {
      x = 0;
      initialiseCell(collideField, streamField, flagField, length, x, y, z,
                     boundaries[0]);
      for (x = 1; x <= length[2]; ++x) {
        initialiseCell(collideField, streamField, flagField, length, x, y, z,
                       image[x][z]);
      }
      x = length[2] + 1;
      initialiseCell(collideField, streamField, flagField, length, x, y, z,
                     boundaries[1]);
    }
    y = length[1] + 1;
    for (x = 0; x <= length[2] + 1; ++x) {
      initialiseCell(collideField, streamField, flagField, length, x, y, z,
                     boundaries[3]);
    }
  }
  z = length[0] + 1;
  for (y = 0; y <= length[1] + 1; ++y) {
    for (x = 0; x < length[2] + 2; ++x) {
      initialiseCell(collideField, streamField, flagField, length, x, y, z,
                     boundaries[5]);
    }
  }
  free_imatrix(image, 0, length[0] + 2, 0, length[2] + 2);
}


x86 assembly (clang, -O0):
<initialiseFields>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x60(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   1080 <strcat@plt>
lea    -0x60(%rbp),%rdi
call   1040 <read_pgm@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <checkForbiddenPatterns@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
jg     1243 <initialiseFields+0xd3>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    0x8(%rcx),%eax
jg     1227 <initialiseFields+0xb7>
mov    -0x48(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11e8 <initialiseFields+0x78>
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11d2 <initialiseFields+0x62>
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    -0x20(%rbp),%rcx
mov    0x4(%rcx),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jg     12d3 <initialiseFields+0x163>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x20(%rbp),%rcx
mov    0x8(%rcx),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jg     12c0 <initialiseFields+0x150>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x34(%rbp),%r8d
mov    -0x38(%rbp),%r9d
mov    -0x3c(%rbp),%r10d
mov    -0x28(%rbp),%rax
mov    0x10(%rax),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1090 <initialiseCell@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    126d <initialiseFields+0xfd>
jmp    12c5 <initialiseFields+0x155>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1251 <initialiseFields+0xe1>
movl   $0x1,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
jg     14be <initialiseFields+0x34e>
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x20(%rbp),%rcx
mov    0x8(%rcx),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jg     134a <initialiseFields+0x1da>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x34(%rbp),%r8d
mov    -0x38(%rbp),%r9d
mov    -0x3c(%rbp),%r10d
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1090 <initialiseCell@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    12f7 <initialiseFields+0x187>
movl   $0x1,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    0x4(%rcx),%eax
jg     1444 <initialiseFields+0x2d4>
movl   $0x0,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x34(%rbp),%r8d
mov    -0x38(%rbp),%r9d
mov    -0x3c(%rbp),%r10d
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1090 <initialiseCell@plt>
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    0x8(%rcx),%eax
jg     13f9 <initialiseFields+0x289>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x34(%rbp),%r8d
mov    -0x38(%rbp),%r9d
mov    -0x3c(%rbp),%r10d
mov    -0x48(%rbp),%rax
movslq -0x34(%rbp),%r11
mov    (%rax,%r11,8),%rax
movslq -0x3c(%rbp),%r11
mov    (%rax,%r11,4),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1090 <initialiseCell@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    139e <initialiseFields+0x22e>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x34(%rbp),%r8d
mov    -0x38(%rbp),%r9d
mov    -0x3c(%rbp),%r10d
mov    -0x28(%rbp),%rax
mov    0x4(%rax),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1090 <initialiseCell@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1351 <initialiseFields+0x1e1>
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x20(%rbp),%rcx
mov    0x8(%rcx),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jg     14ab <initialiseFields+0x33b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x34(%rbp),%r8d
mov    -0x38(%rbp),%r9d
mov    -0x3c(%rbp),%r10d
mov    -0x28(%rbp),%rax
mov    0xc(%rax),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1090 <initialiseCell@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1458 <initialiseFields+0x2e8>
jmp    14b0 <initialiseFields+0x340>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    12da <initialiseFields+0x16a>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    -0x20(%rbp),%rcx
mov    0x4(%rcx),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jg     1553 <initialiseFields+0x3e3>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x20(%rbp),%rcx
mov    0x8(%rcx),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jge    1540 <initialiseFields+0x3d0>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x34(%rbp),%r8d
mov    -0x38(%rbp),%r9d
mov    -0x3c(%rbp),%r10d
mov    -0x28(%rbp),%rax
mov    0x14(%rax),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1090 <initialiseCell@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    14ed <initialiseFields+0x37d>
jmp    1545 <initialiseFields+0x3d5>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    14d1 <initialiseFields+0x361>
mov    -0x48(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
add    $0x2,%edx
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%r8d
add    $0x2,%r8d
xor    %ecx,%ecx
mov    %ecx,%esi
call   1060 <free_imatrix@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initialiseFields>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r8,%r15
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %rsi,%r13
mov    %rdi,0x10(%rsp)
mov    0x8(%r9),%rsi
lea    0x40(%rsp),%rbp
mov    %rbp,%rdi
call   1040 <strcpy@plt>
lea    0xe49(%rip),%rsi
mov    %rbp,%rdi
call   1090 <strcat@plt>
mov    %rbp,%rdi
call   1050 <read_pgm@plt>
mov    %rax,0x18(%rsp)
mov    %rax,%rdi
mov    %rbx,%rsi
call   1080 <checkForbiddenPatterns@plt>
mov    %r15,%r11
mov    %r14,%rdx
mov    %rbx,(%rsp)
mov    (%rbx),%r10d
test   %r10d,%r10d
mov    %r14,0x8(%rsp)
mov    %r15,0x20(%rsp)
js     126c <initialiseFields+0xec>
lea    0xe0b(%rip),%r14
xor    %r12d,%r12d
mov    (%rsp),%r15
mov    0x18(%rsp),%rbx
jmp    122a <initialiseFields+0xaa>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%r12),%rax
movslq (%r15),%r10
cmp    %r10,%r12
mov    %rax,%r12
jge    1262 <initialiseFields+0xe2>
cmpl   $0x0,0x8(%r15)
js     1210 <initialiseFields+0x90>
mov    $0xffffffffffffffff,%rbp
nopl   0x0(%rax,%rax,1)
mov    0x8(%rbx,%rbp,8),%rax
mov    (%rax,%r12,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movslq 0x8(%r15),%rax
add    $0x1,%rbp
cmp    %rax,%rbp
jl     1240 <initialiseFields+0xc0>
jmp    1210 <initialiseFields+0x90>
mov    0x8(%rsp),%rdx
mov    0x20(%rsp),%r11
mov    (%rsp),%rcx
mov    0x4(%rcx),%eax
cmp    $0xffffffff,%eax
mov    %r13,0x28(%rsp)
jl     12f8 <initialiseFields+0x178>
mov    0x8(%rcx),%ecx
xor    %r14d,%r14d
mov    0x10(%rsp),%r15
jmp    129c <initialiseFields+0x11c>
nopw   0x0(%rax,%rax,1)
lea    0x1(%r14),%esi
cmp    %eax,%r14d
mov    %esi,%r14d
jg     12f1 <initialiseFields+0x171>
cmp    $0xffffffff,%ecx
jl     1290 <initialiseFields+0x110>
mov    $0xffffffff,%ebp
mov    (%rsp),%r13
mov    %r11,%r12
nopl   (%rax)
add    $0x1,%ebp
mov    0x10(%r12),%eax
mov    %r15,%rdi
mov    0x28(%rsp),%rsi
mov    %r13,%rcx
mov    %ebp,%r8d
mov    %rdx,%rbx
mov    %r14d,%r9d
push   %rax
push   $0x0
call   10a0 <initialiseCell@plt>
mov    %rbx,%rdx
add    $0x10,%rsp
mov    0x8(%r13),%ecx
cmp    %ecx,%ebp
jle    12b0 <initialiseFields+0x130>
mov    0x4(%r13),%eax
mov    %r12,%r11
mov    0x28(%rsp),%r13
jmp    1290 <initialiseFields+0x110>
mov    (%rsp),%rcx
mov    (%rcx),%r10d
mov    0x18(%rsp),%rdi
test   %r10d,%r10d
jle    150d <initialiseFields+0x38d>
mov    (%rsp),%rax
mov    0x8(%rax),%eax
mov    $0x1,%ecx
jmp    1334 <initialiseFields+0x1b4>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x1(%r14),%rcx
movslq 0x0(%r13),%r10
cmp    %r10,%r14
mov    %r15,%r13
jge    14fc <initialiseFields+0x37c>
cmp    $0xffffffff,%eax
mov    %rcx,%r15
mov    0x8(%rsp),%r12
mov    (%rsp),%rbx
jl     1384 <initialiseFields+0x204>
mov    $0xffffffff,%ebp
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    0x8(%r11),%eax
mov    0x10(%rsp),%rdi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %rbx,%rcx
mov    %ebp,%r8d
mov    %r11,%r14
xor    %r9d,%r9d
push   %rax
push   %r15
call   10a0 <initialiseCell@plt>
mov    %r14,%r11
add    $0x10,%rsp
mov    0x8(%rbx),%eax
cmp    %eax,%ebp
jle    1350 <initialiseFields+0x1d0>
mov    %r15,0x30(%rsp)
mov    0x4(%rbx),%r9d
test   %r9d,%r9d
mov    %rbx,%r13
jle    1494 <initialiseFields+0x314>
mov    $0x1,%eax
mov    0x20(%rsp),%rbp
mov    0x8(%rsp),%r15
mov    0x28(%rsp),%r14
jmp    13f2 <initialiseFields+0x272>
nop
add    $0x1,%r8d
mov    0x4(%rbp),%eax
mov    0x10(%rsp),%rdi
mov    %r14,%rsi
mov    0x8(%rsp),%r15
mov    %r15,%rdx
mov    %r13,%rcx
mov    0x38(%rsp),%r12
mov    %r12d,%r9d
push   %rax
push   0x38(%rsp)
call   10a0 <initialiseCell@plt>
add    $0x10,%rsp
lea    0x1(%r12),%eax
mov    0x4(%r13),%r9d
cmp    %r9d,%r12d
jge    1490 <initialiseFields+0x310>
mov    0x0(%rbp),%r10d
mov    0x10(%rsp),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r13,%rcx
xor    %r8d,%r8d
mov    %rax,0x38(%rsp)
mov    %rax,%r9
push   %r10
push   0x38(%rsp)
call   10a0 <initialiseCell@plt>
add    $0x10,%rsp
mov    0x8(%r13),%r8d
test   %r8d,%r8d
jle    13b0 <initialiseFields+0x230>
mov    $0x1,%ebp
mov    0x30(%rsp),%rbx
mov    0x18(%rsp),%r12
mov    0x38(%rsp),%r15
nopl   0x0(%rax,%rax,1)
mov    (%r12,%rbp,8),%rax
mov    (%rax,%rbx,4),%eax
mov    0x10(%rsp),%rdi
mov    %r14,%rsi
mov    0x8(%rsp),%rdx
mov    %r13,%rcx
mov    %ebp,%r8d
mov    %r15d,%r9d
push   %rax
push   %rbx
call   10a0 <initialiseCell@plt>
add    $0x10,%rsp
lea    0x1(%rbp),%rax
movslq 0x8(%r13),%r8
cmp    %r8,%rbp
mov    %rax,%rbp
jl     1440 <initialiseFields+0x2c0>
mov    0x20(%rsp),%rbp
jmp    13b0 <initialiseFields+0x230>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x8(%r13),%eax
cmp    $0xffffffff,%eax
mov    0x20(%rsp),%r11
mov    0x8(%rsp),%r12
mov    0x28(%rsp),%r15
mov    0x30(%rsp),%r14
jl     1320 <initialiseFields+0x1a0>
add    $0x1,%r9d
mov    $0xffffffff,%ebp
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    0xc(%r11),%eax
mov    0x10(%rsp),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %ebp,%r8d
push   %rax
push   %r14
mov    %r9d,%ebx
call   10a0 <initialiseCell@plt>
mov    0x30(%rsp),%r11
mov    %ebx,%r9d
add    $0x10,%rsp
mov    0x8(%r13),%eax
cmp    %eax,%ebp
jle    14c0 <initialiseFields+0x340>
jmp    1320 <initialiseFields+0x1a0>
mov    (%rsp),%rax
mov    0x4(%rax),%eax
mov    0x8(%rsp),%rdx
mov    0x18(%rsp),%rdi
cmp    $0xfffffffe,%eax
jg     151f <initialiseFields+0x39f>
mov    (%rsp),%rax
mov    0x8(%rax),%r8d
jmp    15b4 <initialiseFields+0x434>
add    $0x1,%r10d
mov    (%rsp),%rcx
mov    0x8(%rcx),%r8d
xor    %r15d,%r15d
mov    (%rsp),%rbx
jmp    154c <initialiseFields+0x3cc>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x1(%r15),%ecx
cmp    %eax,%r15d
mov    %ecx,%r15d
jg     15a8 <initialiseFields+0x428>
cmp    $0xffffffff,%r8d
jl     1540 <initialiseFields+0x3c0>
mov    $0xffffffff,%ebp
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    0x20(%rsp),%rax
mov    0x14(%rax),%eax
mov    0x10(%rsp),%rdi
mov    %r13,%rsi
mov    %rbx,%rcx
mov    %ebp,%r8d
mov    %r13,%r14
mov    %rdx,%r13
mov    %r15d,%r9d
push   %rax
push   %r10
mov    %r10,%r12
call   10a0 <initialiseCell@plt>
mov    %r12,%r10
mov    %r13,%rdx
mov    %r14,%r13
add    $0x10,%rsp
mov    0x8(%rbx),%r8d
cmp    %r8d,%ebp
jle    1560 <initialiseFields+0x3e0>
mov    0x4(%rbx),%eax
jmp    1540 <initialiseFields+0x3c0>
mov    (%rsp),%rax
mov    (%rax),%r10d
mov    0x18(%rsp),%rdi
add    $0x2,%r10d
add    $0x2,%r8d
xor    %esi,%esi
mov    %r10d,%edx
xor    %ecx,%ecx
call   1070 <free_imatrix@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c".pgm\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @initialiseFields(double* %0, double* %1, i32* %2, i32* %3, i32* %4, i8** %5) {
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i8**
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32**
%17 = alloca [20 x i8]
store double* %0, double** %7
store double* %1, double** %8
store i32* %2, i32** %9
store i32* %3, i32** %10
store i32* %4, i32** %11
store i8** %5, i8*** %12
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %17, i64 0, i64 0
%19 = load i8**, i8*** %12
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @strcpy(i8* %18, i8* %21)
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %17, i64 0, i64 0
%24 = call i32 @strcat(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %17, i64 0, i64 0
%26 = call i32** @read_pgm(i8* %25)
store i32** %26, i32*** %16
%27 = load i32**, i32*** %16
%28 = load i32*, i32** %10
%29 = call i32 @checkForbiddenPatterns(i32** %27, i32* %28)
store i32 0, i32* %15
br label %30
30: ; preds = %59, %6
%31 = load i32, i32* %15
%32 = load i32*, i32** %10
%33 = getelementptr inbounds i32, i32* %32, i64 0
%34 = load i32, i32* %33
%35 = icmp sle i32 %31, %34
br i1 %35, label %36, label %62
36: ; preds = %30
store i32 0, i32* %13
br label %37
37: ; preds = %54, %36
%38 = load i32, i32* %13
%39 = load i32*, i32** %10
%40 = getelementptr inbounds i32, i32* %39, i64 2
%41 = load i32, i32* %40
%42 = icmp sle i32 %38, %41
br i1 %42, label %43, label %57
43: ; preds = %37
%44 = load i32**, i32*** %16
%45 = load i32, i32* %13
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i32*, i32** %44, i64 %46
%48 = load i32*, i32** %47
%49 = load i32, i32* %15
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32, i32* %48, i64 %50
%52 = load i32, i32* %51
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %52)
br label %54
54: ; preds = %43
%55 = load i32, i32* %13
%56 = add nsw i32 %55, 1
store i32 %56, i32* %13
br label %37
57: ; preds = %37
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %59
59: ; preds = %57
%60 = load i32, i32* %15
%61 = add nsw i32 %60, 1
store i32 %61, i32* %15
br label %30
62: ; preds = %30
store i32 0, i32* %15
store i32 0, i32* %14
br label %63
63: ; preds = %94, %62
%64 = load i32, i32* %14
%65 = load i32*, i32** %10
%66 = getelementptr inbounds i32, i32* %65, i64 1
%67 = load i32, i32* %66
%68 = add nsw i32 %67, 1
%69 = icmp sle i32 %64, %68
br i1 %69, label %70, label %97
70: ; preds = %63
store i32 0, i32* %13
br label %71
71: ; preds = %90, %70
%72 = load i32, i32* %13
%73 = load i32*, i32** %10
%74 = getelementptr inbounds i32, i32* %73, i64 2
%75 = load i32, i32* %74
%76 = add nsw i32 %75, 1
%77 = icmp sle i32 %72, %76
br i1 %77, label %78, label %93
78: ; preds = %71
%79 = load double*, double** %7
%80 = load double*, double** %8
%81 = load i32*, i32** %9
%82 = load i32*, i32** %10
%83 = load i32, i32* %13
%84 = load i32, i32* %14
%85 = load i32, i32* %15
%86 = load i32*, i32** %11
%87 = getelementptr inbounds i32, i32* %86, i64 4
%88 = load i32, i32* %87
%89 = call i32 @initialiseCell(double* %79, double* %80, i32* %81, i32* %82, i32 %83, i32 %84, i32 %85, i32 %88)
br label %90
90: ; preds = %78
%91 = load i32, i32* %13
%92 = add nsw i32 %91, 1
store i32 %92, i32* %13
br label %71
93: ; preds = %71
br label %94
94: ; preds = %93
%95 = load i32, i32* %14
%96 = add nsw i32 %95, 1
store i32 %96, i32* %14
br label %63
97: ; preds = %63
store i32 1, i32* %15
br label %98
98: ; preds = %220, %97
%99 = load i32, i32* %15
%100 = load i32*, i32** %10
%101 = getelementptr inbounds i32, i32* %100, i64 0
%102 = load i32, i32* %101
%103 = icmp sle i32 %99, %102
br i1 %103, label %104, label %223
104: ; preds = %98
store i32 0, i32* %14
store i32 0, i32* %13
br label %105
105: ; preds = %124, %104
%106 = load i32, i32* %13
%107 = load i32*, i32** %10
%108 = getelementptr inbounds i32, i32* %107, i64 2
%109 = load i32, i32* %108
%110 = add nsw i32 %109, 1
%111 = icmp sle i32 %106, %110
br i1 %111, label %112, label %127
112: ; preds = %105
%113 = load double*, double** %7
%114 = load double*, double** %8
%115 = load i32*, i32** %9
%116 = load i32*, i32** %10
%117 = load i32, i32* %13
%118 = load i32, i32* %14
%119 = load i32, i32* %15
%120 = load i32*, i32** %11
%121 = getelementptr inbounds i32, i32* %120, i64 2
%122 = load i32, i32* %121
%123 = call i32 @initialiseCell(double* %113, double* %114, i32* %115, i32* %116, i32 %117, i32 %118, i32 %119, i32 %122)
br label %124
124: ; preds = %112
%125 = load i32, i32* %13
%126 = add nsw i32 %125, 1
store i32 %126, i32* %13
br label %105
127: ; preds = %105
store i32 1, i32* %14
br label %128
128: ; preds = %189, %127
%129 = load i32, i32* %14
%130 = load i32*, i32** %10
%131 = getelementptr inbounds i32, i32* %130, i64 1
%132 = load i32, i32* %131
%133 = icmp sle i32 %129, %132
br i1 %133, label %134, label %192
134: ; preds = %128
store i32 0, i32* %13
%135 = load double*, double** %7
%136 = load double*, double** %8
%137 = load i32*, i32** %9
%138 = load i32*, i32** %10
%139 = load i32, i32* %13
%140 = load i32, i32* %14
%141 = load i32, i32* %15
%142 = load i32*, i32** %11
%143 = getelementptr inbounds i32, i32* %142, i64 0
%144 = load i32, i32* %143
%145 = call i32 @initialiseCell(double* %135, double* %136, i32* %137, i32* %138, i32 %139, i32 %140, i32 %141, i32 %144)
store i32 1, i32* %13
br label %146
146: ; preds = %170, %134
%147 = load i32, i32* %13
%148 = load i32*, i32** %10
%149 = getelementptr inbounds i32, i32* %148, i64 2
%150 = load i32, i32* %149
%151 = icmp sle i32 %147, %150
br i1 %151, label %152, label %173
152: ; preds = %146
%153 = load double*, double** %7
%154 = load double*, double** %8
%155 = load i32*, i32** %9
%156 = load i32*, i32** %10
%157 = load i32, i32* %13
%158 = load i32, i32* %14
%159 = load i32, i32* %15
%160 = load i32**, i32*** %16
%161 = load i32, i32* %13
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds i32*, i32** %160, i64 %162
%164 = load i32*, i32** %163
%165 = load i32, i32* %15
%166 = sext i32 %165 to i64
%167 = getelementptr inbounds i32, i32* %164, i64 %166
%168 = load i32, i32* %167
%169 = call i32 @initialiseCell(double* %153, double* %154, i32* %155, i32* %156, i32 %157, i32 %158, i32 %159, i32 %168)
br label %170
170: ; preds = %152
%171 = load i32, i32* %13
%172 = add nsw i32 %171, 1
store i32 %172, i32* %13
br label %146
173: ; preds = %146
%174 = load i32*, i32** %10
%175 = getelementptr inbounds i32, i32* %174, i64 2
%176 = load i32, i32* %175
%177 = add nsw i32 %176, 1
store i32 %177, i32* %13
%178 = load double*, double** %7
%179 = load double*, double** %8
%180 = load i32*, i32** %9
%181 = load i32*, i32** %10
%182 = load i32, i32* %13
%183 = load i32, i32* %14
%184 = load i32, i32* %15
%185 = load i32*, i32** %11
%186 = getelementptr inbounds i32, i32* %185, i64 1
%187 = load i32, i32* %186
%188 = call i32 @initialiseCell(double* %178, double* %179, i32* %180, i32* %181, i32 %182, i32 %183, i32 %184, i32 %187)
br label %189
189: ; preds = %173
%190 = load i32, i32* %14
%191 = add nsw i32 %190, 1
store i32 %191, i32* %14
br label %128
192: ; preds = %128
%193 = load i32*, i32** %10
%194 = getelementptr inbounds i32, i32* %193, i64 1
%195 = load i32, i32* %194
%196 = add nsw i32 %195, 1
store i32 %196, i32* %14
store i32 0, i32* %13
br label %197
197: ; preds = %216, %192
%198 = load i32, i32* %13
%199 = load i32*, i32** %10
%200 = getelementptr inbounds i32, i32* %199, i64 2
%201 = load i32, i32* %200
%202 = add nsw i32 %201, 1
%203 = icmp sle i32 %198, %202
br i1 %203, label %204, label %219
204: ; preds = %197
%205 = load double*, double** %7
%206 = load double*, double** %8
%207 = load i32*, i32** %9
%208 = load i32*, i32** %10
%209 = load i32, i32* %13
%210 = load i32, i32* %14
%211 = load i32, i32* %15
%212 = load i32*, i32** %11
%213 = getelementptr inbounds i32, i32* %212, i64 3
%214 = load i32, i32* %213
%215 = call i32 @initialiseCell(double* %205, double* %206, i32* %207, i32* %208, i32 %209, i32 %210, i32 %211, i32 %214)
br label %216
216: ; preds = %204
%217 = load i32, i32* %13
%218 = add nsw i32 %217, 1
store i32 %218, i32* %13
br label %197
219: ; preds = %197
br label %220
220: ; preds = %219
%221 = load i32, i32* %15
%222 = add nsw i32 %221, 1
store i32 %222, i32* %15
br label %98
223: ; preds = %98
%224 = load i32*, i32** %10
%225 = getelementptr inbounds i32, i32* %224, i64 0
%226 = load i32, i32* %225
%227 = add nsw i32 %226, 1
store i32 %227, i32* %15
store i32 0, i32* %14
br label %228
228: ; preds = %259, %223
%229 = load i32, i32* %14
%230 = load i32*, i32** %10
%231 = getelementptr inbounds i32, i32* %230, i64 1
%232 = load i32, i32* %231
%233 = add nsw i32 %232, 1
%234 = icmp sle i32 %229, %233
br i1 %234, label %235, label %262
235: ; preds = %228
store i32 0, i32* %13
br label %236
236: ; preds = %255, %235
%237 = load i32, i32* %13
%238 = load i32*, i32** %10
%239 = getelementptr inbounds i32, i32* %238, i64 2
%240 = load i32, i32* %239
%241 = add nsw i32 %240, 2
%242 = icmp slt i32 %237, %241
br i1 %242, label %243, label %258
243: ; preds = %236
%244 = load double*, double** %7
%245 = load double*, double** %8
%246 = load i32*, i32** %9
%247 = load i32*, i32** %10
%248 = load i32, i32* %13
%249 = load i32, i32* %14
%250 = load i32, i32* %15
%251 = load i32*, i32** %11
%252 = getelementptr inbounds i32, i32* %251, i64 5
%253 = load i32, i32* %252
%254 = call i32 @initialiseCell(double* %244, double* %245, i32* %246, i32* %247, i32 %248, i32 %249, i32 %250, i32 %253)
br label %255
255: ; preds = %243
%256 = load i32, i32* %13
%257 = add nsw i32 %256, 1
store i32 %257, i32* %13
br label %236
258: ; preds = %236
br label %259
259: ; preds = %258
%260 = load i32, i32* %14
%261 = add nsw i32 %260, 1
store i32 %261, i32* %14
br label %228
262: ; preds = %228
%263 = load i32**, i32*** %16
%264 = load i32*, i32** %10
%265 = getelementptr inbounds i32, i32* %264, i64 0
%266 = load i32, i32* %265
%267 = add nsw i32 %266, 2
%268 = load i32*, i32** %10
%269 = getelementptr inbounds i32, i32* %268, i64 2
%270 = load i32, i32* %269
%271 = add nsw i32 %270, 2
%272 = call i32 @free_imatrix(i32** %263, i32 0, i32 %267, i32 0, i32 %271)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c".pgm\00"
@.str.1 = [4 x i8] c"%d \00"
define void @initialiseFields(double* %0, double* %1, i32* %2, i32* %3, i32* nocapture %4, i8** nocapture %5) {
%7 = alloca [20 x i8]
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%9 = getelementptr inbounds i8*, i8** %5, i64 1
%10 = load i8*, i8** %9
%11 = call i32 @strcpy(i8* %8, i8* %10)
%12 = call i32 @strcat(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%13 = call i32** @read_pgm(i8* %8)
%14 = call i32 @checkForbiddenPatterns(i32** %13, i32* %3)
%15 = load i32, i32* %3
%16 = icmp slt i32 %15, 0
br i1 %16, label %23, label %17
17: ; preds = %6
%18 = getelementptr inbounds i32, i32* %3, i64 2
br label %19
19: ; preds = %17, %43
%20 = phi i64 [ 0, %17 ], [ %45, %43 ]
%21 = load i32, i32* %18
%22 = icmp slt i32 %21, 0
br i1 %22, label %43, label %32
23: ; preds = %43, %6
%24 = phi i32 [ %15, %6 ], [ %46, %43 ]
%25 = getelementptr inbounds i32, i32* %3, i64 1
%26 = load i32, i32* %25
%27 = icmp slt i32 %26, -1
br i1 %27, label %56, label %28
28: ; preds = %23
%29 = getelementptr inbounds i32, i32* %3, i64 2
%30 = getelementptr inbounds i32, i32* %4, i64 4
%31 = load i32, i32* %29
br label %49
32: ; preds = %19, %32
%33 = phi i64 [ %39, %32 ], [ 0, %19 ]
%34 = getelementptr inbounds i32*, i32** %13, i64 %33
%35 = load i32*, i32** %34
%36 = getelementptr inbounds i32, i32* %35, i64 %20
%37 = load i32, i32* %36
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %37)
%39 = add nuw nsw i64 %33, 1
%40 = load i32, i32* %18
%41 = sext i32 %40 to i64
%42 = icmp slt i64 %33, %41
br i1 %42, label %32, label %43
43: ; preds = %32, %19
%44 = call i32 @putchar(i32 10)
%45 = add nuw nsw i64 %20, 1
%46 = load i32, i32* %3
%47 = sext i32 %46 to i64
%48 = icmp slt i64 %20, %47
br i1 %48, label %19, label %23
49: ; preds = %28, %75
%50 = phi i32 [ %26, %28 ], [ %76, %75 ]
%51 = phi i32 [ %31, %28 ], [ %77, %75 ]
%52 = phi i32 [ 0, %28 ], [ %78, %75 ]
%53 = icmp slt i32 %51, -1
br i1 %53, label %75, label %66
54: ; preds = %75
%55 = load i32, i32* %3
br label %56
56: ; preds = %54, %23
%57 = phi i32 [ %76, %54 ], [ %26, %23 ]
%58 = phi i32 [ %55, %54 ], [ %24, %23 ]
%59 = icmp slt i32 %58, 1
br i1 %59, label %149, label %60
60: ; preds = %56
%61 = getelementptr inbounds i32, i32* %3, i64 2
%62 = getelementptr inbounds i32, i32* %4, i64 2
%63 = getelementptr inbounds i32, i32* %4, i64 1
%64 = getelementptr inbounds i32, i32* %4, i64 3
%65 = load i32, i32* %61
br label %80
66: ; preds = %49, %66
%67 = phi i32 [ %70, %66 ], [ 0, %49 ]
%68 = load i32, i32* %30
%69 = call i32 @initialiseCell(double* %0, double* %1, i32* %2, i32* %3, i32 %67, i32 %52, i32 0, i32 %68)
%70 = add nuw nsw i32 %67, 1
%71 = load i32, i32* %29
%72 = icmp sgt i32 %67, %71
br i1 %72, label %73, label %66
73: ; preds = %66
%74 = load i32, i32* %25
br label %75
75: ; preds = %73, %49
%76 = phi i32 [ %74, %73 ], [ %50, %49 ]
%77 = phi i32 [ %71, %73 ], [ %51, %49 ]
%78 = add nuw nsw i32 %52, 1
%79 = icmp sgt i32 %52, %76
br i1 %79, label %54, label %49
80: ; preds = %60, %141
%81 = phi i32 [ %65, %60 ], [ %142, %141 ]
%82 = phi i64 [ 1, %60 ], [ %143, %141 ]
%83 = icmp slt i32 %81, -1
br i1 %83, label %86, label %84
84: ; preds = %80
%85 = trunc i64 %82 to i32
br label %92
86: ; preds = %92, %80
%87 = phi i32 [ %81, %80 ], [ %97, %92 ]
%88 = load i32, i32* %25
%89 = icmp slt i32 %88, 1
br i1 %89, label %127, label %90
90: ; preds = %86
%91 = trunc i64 %82 to i32
br label %99
92: ; preds = %84, %92
%93 = phi i32 [ %96, %92 ], [ 0, %84 ]
%94 = load i32, i32* %62
%95 = call i32 @initialiseCell(double* %0, double* %1, i32* %2, i32* %3, i32 %93, i32 0, i32 %85, i32 %94)
%96 = add nuw nsw i32 %93, 1
%97 = load i32, i32* %61
%98 = icmp sgt i32 %93, %97
br i1 %98, label %86, label %92
99: ; preds = %90, %117
%100 = phi i32 [ 1, %90 ], [ %122, %117 ]
%101 = load i32, i32* %4
%102 = call i32 @initialiseCell(double* %0, double* %1, i32* %2, i32* %3, i32 0, i32 %100, i32 %91, i32 %101)
%103 = load i32, i32* %61
%104 = icmp slt i32 %103, 1
br i1 %104, label %117, label %105
105: ; preds = %99, %105
%106 = phi i64 [ %113, %105 ], [ 1, %99 ]
%107 = getelementptr inbounds i32*, i32** %13, i64 %106
%108 = load i32*, i32** %107
%109 = getelementptr inbounds i32, i32* %108, i64 %82
%110 = load i32, i32* %109
%111 = trunc i64 %106 to i32
%112 = call i32 @initialiseCell(double* %0, double* %1, i32* %2, i32* %3, i32 %111, i32 %100, i32 %91, i32 %110)
%113 = add nuw nsw i64 %106, 1
%114 = load i32, i32* %61
%115 = sext i32 %114 to i64
%116 = icmp slt i64 %106, %115
br i1 %116, label %105, label %117
117: ; preds = %105, %99
%118 = phi i32 [ %103, %99 ], [ %114, %105 ]
%119 = add nsw i32 %118, 1
%120 = load i32, i32* %63
%121 = call i32 @initialiseCell(double* %0, double* %1, i32* %2, i32* %3, i32 %119, i32 %100, i32 %91, i32 %120)
%122 = add nuw nsw i32 %100, 1
%123 = load i32, i32* %25
%124 = icmp slt i32 %100, %123
br i1 %124, label %99, label %125
125: ; preds = %117
%126 = load i32, i32* %61
br label %127
127: ; preds = %125, %86
%128 = phi i32 [ %87, %86 ], [ %126, %125 ]
%129 = phi i32 [ %88, %86 ], [ %123, %125 ]
%130 = add nsw i32 %129, 1
%131 = icmp slt i32 %128, -1
br i1 %131, label %141, label %132
132: ; preds = %127
%133 = trunc i64 %82 to i32
br label %134
134: ; preds = %132, %134
%135 = phi i32 [ %138, %134 ], [ 0, %132 ]
%136 = load i32, i32* %64
%137 = call i32 @initialiseCell(double* %0, double* %1, i32* %2, i32* %3, i32 %135, i32 %130, i32 %133, i32 %136)
%138 = add nuw nsw i32 %135, 1
%139 = load i32, i32* %61
%140 = icmp sgt i32 %135, %139
br i1 %140, label %141, label %134
141: ; preds = %134, %127
%142 = phi i32 [ %128, %127 ], [ %139, %134 ]
%143 = add nuw nsw i64 %82, 1
%144 = load i32, i32* %3
%145 = sext i32 %144 to i64
%146 = icmp slt i64 %82, %145
br i1 %146, label %80, label %147
147: ; preds = %141
%148 = load i32, i32* %25
br label %149
149: ; preds = %147, %56
%150 = phi i32 [ %57, %56 ], [ %148, %147 ]
%151 = phi i32 [ %58, %56 ], [ %144, %147 ]
%152 = add nsw i32 %151, 1
%153 = icmp slt i32 %150, -1
%154 = getelementptr inbounds i32, i32* %3, i64 2
br i1 %153, label %155, label %157
155: ; preds = %149
%156 = load i32, i32* %154
br label %181
157: ; preds = %149
%158 = getelementptr inbounds i32, i32* %4, i64 5
%159 = load i32, i32* %154
br label %160
160: ; preds = %157, %174
%161 = phi i32 [ %150, %157 ], [ %175, %174 ]
%162 = phi i32 [ %159, %157 ], [ %176, %174 ]
%163 = phi i32 [ 0, %157 ], [ %177, %174 ]
%164 = icmp sgt i32 %162, -2
br i1 %164, label %165, label %174
165: ; preds = %160, %165
%166 = phi i32 [ %169, %165 ], [ 0, %160 ]
%167 = load i32, i32* %158
%168 = call i32 @initialiseCell(double* %0, double* %1, i32* %2, i32* %3, i32 %166, i32 %163, i32 %152, i32 %167)
%169 = add nuw nsw i32 %166, 1
%170 = load i32, i32* %154
%171 = icmp sgt i32 %166, %170
br i1 %171, label %172, label %165
172: ; preds = %165
%173 = load i32, i32* %25
br label %174
174: ; preds = %172, %160
%175 = phi i32 [ %173, %172 ], [ %161, %160 ]
%176 = phi i32 [ %170, %172 ], [ %162, %160 ]
%177 = add nuw nsw i32 %163, 1
%178 = icmp sgt i32 %163, %175
br i1 %178, label %179, label %160
179: ; preds = %174
%180 = load i32, i32* %3
br label %181
181: ; preds = %155, %179
%182 = phi i32 [ %176, %179 ], [ %156, %155 ]
%183 = phi i32 [ %180, %179 ], [ %151, %155 ]
%184 = add nsw i32 %183, 2
%185 = add nsw i32 %182, 2
%186 = call i32 @free_imatrix(i32** %13, i32 0, i32 %184, i32 0, i32 %185)
ret void
}