#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ errhandler(int, char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int **imatrix(int /*<<< orphan*/, int, int /*<<< orphan*/, int);
int /*<<< orphan*/ sprintf(char *, char *, char const *);
int /*<<< orphan*/ sscanf(char *, char *, int *, ...);
int **read_pgm(const char *filename) {
  FILE *input = NULL;
  char line[1024];
  int levels;
  int xsize, ysize;
  int i1, j1;
  int **pic = NULL;
  if ((input = fopen(filename, "rb")) == 0) {
    char szBuff[80];
    sprintf(szBuff, "Can not read file %s !!!", filename);
    errhandler(
        438,
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/grantathon/computational_fluid_dynamics/"
        "refs/heads/master/project/ns_sim_parallel/helper.c",
        szBuff);
  }
  if (fread(line, 1, 3, input) != 3) {
    fclose(input);
    errhandler(
        445,
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/grantathon/computational_fluid_dynamics/"
        "refs/heads/master/project/ns_sim_parallel/helper.c",
        "Error Wrong Magic field!");
  }
  do
    fgets(line, sizeof line, input);
  while (*line == '#');
  sscanf(line, "%d %d\n", &xsize, &ysize);
  fgets(line, sizeof line, input);
  sscanf(line, "%d\n", &levels);
  pic = imatrix(0, xsize + 1, 0, ysize + 1);
  for (j1 = 1; j1 < ysize + 1; j1++) {
    for (i1 = 1; i1 < xsize + 1; i1++) {
      int byte;
      fscanf(input, "%d", &byte);
      if (byte == EOF) {
        fclose(input);
        errhandler(
            478,
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/grantathon/computational_fluid_dynamics/"
            "refs/heads/master/project/ns_sim_parallel/helper.c",
            "read failed");
      } else {
        pic[i1][ysize + 1 - j1] = byte;
      }
    }
  }
  for (i1 = 0; i1 < xsize + 2; i1++) {
    pic[i1][0] = 0;
  }
  for (i1 = 0; i1 < xsize + 2; i1++) {
    pic[i1][ysize + 1] = 0;
  }
  for (j1 = 0; j1 < ysize + 2; j1++) {
    pic[0][j1] = 0;
    pic[xsize + 1][j1] = 0;
  }
  fclose(input);
  return pic;
}


x86 assembly (clang, -O0):
<read_pgm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x490,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x430(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe43(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11ff <read_pgm+0x6f>
lea    -0x480(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe21(%rip),%rsi
call   10b0 <sprintf@plt>
lea    -0x480(%rbp),%rdx
mov    $0x1b6,%edi
lea    0xe22(%rip),%rsi
call   1050 <errhandler@plt>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x3,%edx
call   1040 <fread@plt>
cmp    $0x3,%eax
je     1243 <read_pgm+0xb3>
mov    -0x10(%rbp),%rdi
call   1060 <fclose@plt>
mov    $0x1bd,%edi
lea    0xde5(%rip),%rsi
lea    0xe93(%rip),%rdx
call   1050 <errhandler@plt>
jmp    1248 <read_pgm+0xb8>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x400,%esi
call   1080 <fgets@plt>
movsbl -0x410(%rbp),%eax
cmp    $0x23,%eax
je     1248 <read_pgm+0xb8>
lea    -0x410(%rbp),%rdi
lea    0xe6f(%rip),%rsi
lea    -0x418(%rbp),%rdx
lea    -0x41c(%rbp),%rcx
mov    $0x0,%al
call   1090 <sscanf@plt>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x400,%esi
call   1080 <fgets@plt>
lea    -0x410(%rbp),%rdi
lea    0xe3a(%rip),%rsi
lea    -0x414(%rbp),%rdx
mov    $0x0,%al
call   1090 <sscanf@plt>
mov    -0x418(%rbp),%esi
add    $0x1,%esi
mov    -0x41c(%rbp),%ecx
add    $0x1,%ecx
xor    %edx,%edx
mov    %edx,%edi
call   1030 <imatrix@plt>
mov    %rax,-0x430(%rbp)
movl   $0x1,-0x424(%rbp)
mov    -0x424(%rbp),%eax
mov    -0x41c(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    13d6 <read_pgm+0x246>
movl   $0x1,-0x420(%rbp)
mov    -0x420(%rbp),%eax
mov    -0x418(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    13bd <read_pgm+0x22d>
mov    -0x10(%rbp),%rdi
lea    0xdc1(%rip),%rsi
lea    -0x484(%rbp),%rdx
call   1070 <fscanf@plt>
mov    -0x484(%rbp),%eax
mov    0x2c9f(%rip),%rcx
cmp    (%rcx),%eax
jne    1377 <read_pgm+0x1e7>
mov    -0x10(%rbp),%rdi
call   1060 <fclose@plt>
mov    $0x1de,%edi
lea    0xcb6(%rip),%rsi
lea    0xd87(%rip),%rdx
call   1050 <errhandler@plt>
jmp    13a4 <read_pgm+0x214>
mov    -0x484(%rbp),%edx
mov    -0x430(%rbp),%rax
movslq -0x420(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x41c(%rbp),%ecx
add    $0x1,%ecx
sub    -0x424(%rbp),%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
jmp    13a9 <read_pgm+0x219>
mov    -0x420(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x420(%rbp)
jmp    130e <read_pgm+0x17e>
jmp    13c2 <read_pgm+0x232>
mov    -0x424(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x424(%rbp)
jmp    12ed <read_pgm+0x15d>
movl   $0x0,-0x420(%rbp)
mov    -0x420(%rbp),%eax
mov    -0x418(%rbp),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jge    1423 <read_pgm+0x293>
mov    -0x430(%rbp),%rax
movslq -0x420(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movl   $0x0,(%rax)
mov    -0x420(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x420(%rbp)
jmp    13e0 <read_pgm+0x250>
movl   $0x0,-0x420(%rbp)
mov    -0x420(%rbp),%eax
mov    -0x418(%rbp),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jge    147d <read_pgm+0x2ed>
mov    -0x430(%rbp),%rax
movslq -0x420(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x41c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x420(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x420(%rbp)
jmp    142d <read_pgm+0x29d>
movl   $0x0,-0x424(%rbp)
mov    -0x424(%rbp),%eax
mov    -0x41c(%rbp),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jge    14ef <read_pgm+0x35f>
mov    -0x430(%rbp),%rax
mov    (%rax),%rax
movslq -0x424(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x430(%rbp),%rax
mov    -0x418(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x424(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x424(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x424(%rbp)
jmp    1487 <read_pgm+0x2f7>
mov    -0x10(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x430(%rbp),%rax
add    $0x490,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_pgm>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x438,%rsp
mov    %rdi,%rbp
lea    0xe55(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11e3 <read_pgm+0x53>
lea    0xe44(%rip),%rsi
lea    0x30(%rsp),%r14
mov    %r14,%rdi
mov    %rbp,%rdx
call   10b0 <sprintf@plt>
lea    0xe46(%rip),%rsi
mov    $0x1b6,%edi
mov    %r14,%rdx
call   1050 <errhandler@plt>
lea    0x30(%rsp),%rdi
mov    $0x1,%esi
mov    $0x3,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
cmp    $0x3,%eax
je     121f <read_pgm+0x8f>
mov    %rbx,%rdi
call   1060 <fclose@plt>
lea    0xe0e(%rip),%rsi
lea    0xebc(%rip),%rdx
mov    $0x1bd,%edi
call   1050 <errhandler@plt>
lea    0x30(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbp,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1080 <fgets@plt>
cmpb   $0x23,0x30(%rsp)
je     1230 <read_pgm+0xa0>
lea    0xe9c(%rip),%rsi
lea    0x30(%rsp),%rbp
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %rbp,%rdi
xor    %eax,%eax
call   1090 <sscanf@plt>
mov    %rbp,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1080 <fgets@plt>
lea    0xe6f(%rip),%rsi
lea    0x2c(%rsp),%rdx
mov    %rbp,%rdi
xor    %eax,%eax
call   1090 <sscanf@plt>
mov    0x10(%rsp),%esi
add    $0x1,%esi
mov    0xc(%rsp),%ecx
add    $0x1,%ecx
xor    %edi,%edi
xor    %edx,%edx
call   1030 <imatrix@plt>
mov    %rax,0x18(%rsp)
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
jle    136e <read_pgm+0x1de>
mov    $0x1,%esi
mov    0x10(%rsp),%eax
lea    0xe2c(%rip),%r15
lea    0x14(%rsp),%r12
mov    0x2d17(%rip),%rbp
jmp    12f6 <read_pgm+0x166>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0xc(%rsp),%ecx
mov    0x20(%rsp),%rsi
lea    0x1(%rsi),%edx
cmp    %ecx,%esi
mov    %edx,%esi
jge    1372 <read_pgm+0x1e2>
test   %eax,%eax
jle    12e9 <read_pgm+0x159>
mov    $0x1,%r13d
mov    %rsi,0x20(%rsp)
sub    %esi,%r13d
xor    %r14d,%r14d
jmp    1335 <read_pgm+0x1a5>
nopl   (%rax)
mov    0x18(%rsp),%rcx
mov    0x8(%rcx,%r14,8),%rcx
mov    0xc(%rsp),%edx
add    %r13d,%edx
movslq %edx,%rdx
mov    %eax,(%rcx,%rdx,4)
movslq 0x10(%rsp),%rax
add    $0x1,%r14
cmp    %rax,%r14
jge    12e0 <read_pgm+0x150>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1070 <fscanf@plt>
mov    0x14(%rsp),%eax
cmp    0x0(%rbp),%eax
jne    1310 <read_pgm+0x180>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    $0x1de,%edi
lea    0xcbc(%rip),%rsi
lea    0xd8d(%rip),%rdx
call   1050 <errhandler@plt>
jmp    1327 <read_pgm+0x197>
mov    0x10(%rsp),%eax
cmp    $0xffffffff,%eax
mov    0x18(%rsp),%rbp
jl     13e0 <read_pgm+0x250>
mov    $0xffffffffffffffff,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x8(%rbp,%rax,8),%rcx
movl   $0x0,(%rcx)
movslq 0x10(%rsp),%rcx
add    $0x1,%rax
cmp    %rcx,%rax
jle    1390 <read_pgm+0x200>
cmp    $0xffffffff,%ecx
jl     13e0 <read_pgm+0x250>
mov    $0xffffffffffffffff,%rax
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x8(%rbp,%rax,8),%rcx
movslq 0xc(%rsp),%rdx
movl   $0x0,0x4(%rcx,%rdx,4)
movslq 0x10(%rsp),%rcx
add    $0x1,%rax
cmp    %rcx,%rax
jle    13c0 <read_pgm+0x230>
cmpl   $0xffffffff,0xc(%rsp)
jl     1428 <read_pgm+0x298>
mov    0x0(%rbp),%rax
mov    $0xffffffffffffffff,%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movl   $0x0,0x4(%rax,%rcx,4)
movslq 0x10(%rsp),%rdx
mov    0x8(%rbp,%rdx,8),%rdx
movl   $0x0,0x4(%rdx,%rcx,4)
movslq 0xc(%rsp),%rdx
add    $0x1,%rcx
cmp    %rdx,%rcx
jle    1400 <read_pgm+0x270>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    %rbp,%rax
add    $0x438,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [25 x i8] c"Can not read file %s !!!\00"
@.str.2 = [181 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/grantathon/computational_fluid_dynamics/refs/heads/master/project/ns_sim_parallel/helper.c\00"
@.str.3 = [25 x i8] c"Error Wrong Magic field!\00"
@.str.4 = [7 x i8] c"%d %d\0A\00"
@.str.5 = [4 x i8] c"%d\0A\00"
@.str.6 = [3 x i8] c"%d\00"
@EOF = global i32 0
@.str.7 = [12 x i8] c"read failed\00"
define i32** @read_pgm(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [1024 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32**
%11 = alloca [80 x i8]
%12 = alloca i32
store i8* %0, i8** %2
store i32* null, i32** %3
store i32** null, i32*** %10
%13 = load i8*, i8** %2
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %3
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %22
16: ; preds = %1
%17 = getelementptr inbounds [80 x i8], [80 x i8]* %11, i64 0, i64 0
%18 = load i8*, i8** %2
%19 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = getelementptr inbounds [80 x i8], [80 x i8]* %11, i64 0, i64 0
%21 = call i32 @errhandler(i32 438, i8* getelementptr inbounds ([181 x i8], [181 x i8]* @.str.2, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %16, %1
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%24 = load i32*, i32** %3
%25 = call i32 @fread(i8* %23, i32 1, i32 3, i32* %24)
%26 = icmp ne i32 %25, 3
br i1 %26, label %27, label %31
27: ; preds = %22
%28 = load i32*, i32** %3
%29 = call i32 @fclose(i32* %28)
%30 = call i32 @errhandler(i32 445, i8* getelementptr inbounds ([181 x i8], [181 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
br label %31
31: ; preds = %27, %22
br label %32
32: ; preds = %36, %31
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%34 = load i32*, i32** %3
%35 = call i32 @fgets(i8* %33, i32 1024, i32* %34)
br label %36
36: ; preds = %32
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 35
br i1 %40, label %32, label %41
41: ; preds = %36
%42 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%43 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %42, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32* %6, i32* %7)
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%45 = load i32*, i32** %3
%46 = call i32 @fgets(i8* %44, i32 1024, i32* %45)
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%48 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %47, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32* %5)
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
%51 = load i32, i32* %7
%52 = add nsw i32 %51, 1
%53 = call i32** @imatrix(i32 0, i32 %50, i32 0, i32 %52)
store i32** %53, i32*** %10
store i32 1, i32* %9
br label %54
54: ; preds = %93, %41
%55 = load i32, i32* %9
%56 = load i32, i32* %7
%57 = add nsw i32 %56, 1
%58 = icmp slt i32 %55, %57
br i1 %58, label %59, label %96
59: ; preds = %54
store i32 1, i32* %8
br label %60
60: ; preds = %89, %59
%61 = load i32, i32* %8
%62 = load i32, i32* %6
%63 = add nsw i32 %62, 1
%64 = icmp slt i32 %61, %63
br i1 %64, label %65, label %92
65: ; preds = %60
%66 = load i32*, i32** %3
%67 = call i32 @fscanf(i32* %66, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %12)
%68 = load i32, i32* %12
%69 = load i32, i32* @EOF
%70 = icmp eq i32 %68, %69
br i1 %70, label %71, label %75
71: ; preds = %65
%72 = load i32*, i32** %3
%73 = call i32 @fclose(i32* %72)
%74 = call i32 @errhandler(i32 478, i8* getelementptr inbounds ([181 x i8], [181 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
br label %88
75: ; preds = %65
%76 = load i32, i32* %12
%77 = load i32**, i32*** %10
%78 = load i32, i32* %8
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i32*, i32** %77, i64 %79
%81 = load i32*, i32** %80
%82 = load i32, i32* %7
%83 = add nsw i32 %82, 1
%84 = load i32, i32* %9
%85 = sub nsw i32 %83, %84
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i32, i32* %81, i64 %86
store i32 %76, i32* %87
br label %88
88: ; preds = %75, %71
br label %89
89: ; preds = %88
%90 = load i32, i32* %8
%91 = add nsw i32 %90, 1
store i32 %91, i32* %8
br label %60
92: ; preds = %60
br label %93
93: ; preds = %92
%94 = load i32, i32* %9
%95 = add nsw i32 %94, 1
store i32 %95, i32* %9
br label %54
96: ; preds = %54
store i32 0, i32* %8
br label %97
97: ; preds = %109, %96
%98 = load i32, i32* %8
%99 = load i32, i32* %6
%100 = add nsw i32 %99, 2
%101 = icmp slt i32 %98, %100
br i1 %101, label %102, label %112
102: ; preds = %97
%103 = load i32**, i32*** %10
%104 = load i32, i32* %8
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i32*, i32** %103, i64 %105
%107 = load i32*, i32** %106
%108 = getelementptr inbounds i32, i32* %107, i64 0
store i32 0, i32* %108
br label %109
109: ; preds = %102
%110 = load i32, i32* %8
%111 = add nsw i32 %110, 1
store i32 %111, i32* %8
br label %97
112: ; preds = %97
store i32 0, i32* %8
br label %113
113: ; preds = %128, %112
%114 = load i32, i32* %8
%115 = load i32, i32* %6
%116 = add nsw i32 %115, 2
%117 = icmp slt i32 %114, %116
br i1 %117, label %118, label %131
118: ; preds = %113
%119 = load i32**, i32*** %10
%120 = load i32, i32* %8
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds i32*, i32** %119, i64 %121
%123 = load i32*, i32** %122
%124 = load i32, i32* %7
%125 = add nsw i32 %124, 1
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds i32, i32* %123, i64 %126
store i32 0, i32* %127
br label %128
128: ; preds = %118
%129 = load i32, i32* %8
%130 = add nsw i32 %129, 1
store i32 %130, i32* %8
br label %113
131: ; preds = %113
store i32 0, i32* %9
br label %132
132: ; preds = %153, %131
%133 = load i32, i32* %9
%134 = load i32, i32* %7
%135 = add nsw i32 %134, 2
%136 = icmp slt i32 %133, %135
br i1 %136, label %137, label %156
137: ; preds = %132
%138 = load i32**, i32*** %10
%139 = getelementptr inbounds i32*, i32** %138, i64 0
%140 = load i32*, i32** %139
%141 = load i32, i32* %9
%142 = sext i32 %141 to i64
%143 = getelementptr inbounds i32, i32* %140, i64 %142
store i32 0, i32* %143
%144 = load i32**, i32*** %10
%145 = load i32, i32* %6
%146 = add nsw i32 %145, 1
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds i32*, i32** %144, i64 %147
%149 = load i32*, i32** %148
%150 = load i32, i32* %9
%151 = sext i32 %150 to i64
%152 = getelementptr inbounds i32, i32* %149, i64 %151
store i32 0, i32* %152
br label %153
153: ; preds = %137
%154 = load i32, i32* %9
%155 = add nsw i32 %154, 1
store i32 %155, i32* %9
br label %132
156: ; preds = %132
%157 = load i32*, i32** %3
%158 = call i32 @fclose(i32* %157)
%159 = load i32**, i32*** %10
ret i32** %159
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [25 x i8] c"Can not read file %s !!!\00"
@.str.2 = [181 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/grantathon/computational_fluid_dynamics/refs/heads/master/project/ns_sim_parallel/helper.c\00"
@.str.3 = [25 x i8] c"Error Wrong Magic field!\00"
@.str.4 = [7 x i8] c"%d %d\0A\00"
@.str.5 = [4 x i8] c"%d\0A\00"
@.str.6 = [3 x i8] c"%d\00"
@EOF = global i32 0
@.str.7 = [12 x i8] c"read failed\00"
define i32** @read_pgm(i8* %0) {
%2 = alloca [1024 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [80 x i8]
%7 = alloca i32
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%9 = bitcast i32* %3 to i8*
%10 = bitcast i32* %4 to i8*
%11 = bitcast i32* %5 to i8*
%12 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %18
14: ; preds = %1
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%16 = call i32 @sprintf(i8* %15, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%17 = call i32 @errhandler(i32 438, i8* getelementptr inbounds ([181 x i8], [181 x i8]* @.str.2, i64 0, i64 0), i8* %15)
br label %18
18: ; preds = %14, %1
%19 = call i32 @fread(i8* %8, i32 1, i32 3, i32* %12)
%20 = icmp eq i32 %19, 3
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = call i32 @fclose(i32* %12)
%23 = call i32 @errhandler(i32 445, i8* getelementptr inbounds ([181 x i8], [181 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %21, %18
br label %25
25: ; preds = %24, %25
%26 = call i32 @fgets(i8* %8, i32 1024, i32* %12)
%27 = load i8, i8* %8
%28 = icmp eq i8 %27, 35
br i1 %28, label %25, label %29
29: ; preds = %25
%30 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32* %4, i32* %5)
%31 = call i32 @fgets(i8* %8, i32 1024, i32* %12)
%32 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32* %3)
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
%37 = call i32** @imatrix(i32 0, i32 %34, i32 0, i32 %36)
%38 = load i32, i32* %5
%39 = icmp slt i32 %38, 1
br i1 %39, label %40, label %42
40: ; preds = %29
%41 = load i32, i32* %4
br label %52
42: ; preds = %29
%43 = bitcast i32* %7 to i8*
%44 = load i32, i32* %4
br label %45
45: ; preds = %42, %78
%46 = phi i32 [ %38, %42 ], [ %79, %78 ]
%47 = phi i32 [ %44, %42 ], [ %80, %78 ]
%48 = phi i32 [ 1, %42 ], [ %81, %78 ]
%49 = icmp slt i32 %47, 1
br i1 %49, label %78, label %50
50: ; preds = %45
%51 = sub nsw i32 1, %48
br label %55
52: ; preds = %78, %40
%53 = phi i32 [ %41, %40 ], [ %80, %78 ]
%54 = icmp sgt i32 %53, -2
br i1 %54, label %85, label %93
55: ; preds = %50, %71
%56 = phi i64 [ 1, %50 ], [ %72, %71 ]
%57 = call i32 @fscanf(i32* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %7)
%58 = load i32, i32* %7
%59 = load i32, i32* @EOF
%60 = icmp eq i32 %58, %59
br i1 %60, label %61, label %64
61: ; preds = %55
%62 = call i32 @fclose(i32* %12)
%63 = call i32 @errhandler(i32 478, i8* getelementptr inbounds ([181 x i8], [181 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
br label %71
64: ; preds = %55
%65 = getelementptr inbounds i32*, i32** %37, i64 %56
%66 = load i32*, i32** %65
%67 = load i32, i32* %5
%68 = add i32 %51, %67
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32, i32* %66, i64 %69
store i32 %58, i32* %70
br label %71
71: ; preds = %64, %61
%72 = add nuw nsw i64 %56, 1
%73 = load i32, i32* %4
%74 = sext i32 %73 to i64
%75 = icmp slt i64 %56, %74
br i1 %75, label %55, label %76
76: ; preds = %71
%77 = load i32, i32* %5
br label %78
78: ; preds = %76, %45
%79 = phi i32 [ %77, %76 ], [ %46, %45 ]
%80 = phi i32 [ %73, %76 ], [ %47, %45 ]
%81 = add nuw nsw i32 %48, 1
%82 = icmp slt i32 %48, %79
br i1 %82, label %45, label %52
83: ; preds = %85
%84 = icmp sgt i32 %90, -2
br i1 %84, label %98, label %93
85: ; preds = %52, %85
%86 = phi i64 [ %89, %85 ], [ 0, %52 ]
%87 = getelementptr inbounds i32*, i32** %37, i64 %86
%88 = load i32*, i32** %87
store i32 0, i32* %88
%89 = add nuw nsw i64 %86, 1
%90 = load i32, i32* %4
%91 = sext i32 %90 to i64
%92 = icmp sgt i64 %86, %91
br i1 %92, label %83, label %85
93: ; preds = %98, %52, %83
%94 = load i32, i32* %5
%95 = icmp sgt i32 %94, -2
br i1 %95, label %96, label %123
96: ; preds = %93
%97 = load i32*, i32** %37
br label %110
98: ; preds = %83, %98
%99 = phi i64 [ %106, %98 ], [ 0, %83 ]
%100 = getelementptr inbounds i32*, i32** %37, i64 %99
%101 = load i32*, i32** %100
%102 = load i32, i32* %5
%103 = add nsw i32 %102, 1
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds i32, i32* %101, i64 %104
store i32 0, i32* %105
%106 = add nuw nsw i64 %99, 1
%107 = load i32, i32* %4
%108 = sext i32 %107 to i64
%109 = icmp sgt i64 %99, %108
br i1 %109, label %93, label %98
110: ; preds = %96, %110
%111 = phi i64 [ 0, %96 ], [ %119, %110 ]
%112 = getelementptr inbounds i32, i32* %97, i64 %111
store i32 0, i32* %112
%113 = load i32, i32* %4
%114 = add nsw i32 %113, 1
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i32*, i32** %37, i64 %115
%117 = load i32*, i32** %116
%118 = getelementptr inbounds i32, i32* %117, i64 %111
store i32 0, i32* %118
%119 = add nuw nsw i64 %111, 1
%120 = load i32, i32* %5
%121 = sext i32 %120 to i64
%122 = icmp sgt i64 %111, %121
br i1 %122, label %123, label %110
123: ; preds = %110, %93
%124 = call i32 @fclose(i32* %12)
ret i32** %37
}