#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 /*<<< orphan*/ errhandler(int, char *, char *);
scalar_t__ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, ...);
void write_imatrix2(const char *szDebug, int timeStepNumber, int ***m, int nrl,
                    int nrh, int ncl, int nch, int nll, int nlh) {
  int i, j, k;
  FILE *fh = 0;
  char szFileName[80];
  sprintf(szFileName,
          "/media/norbert/940CB6150CB5F27A/Documents/simulation/debug/d%i_%s",
          timeStepNumber, szDebug);
  fh = fopen(szFileName, "w");
  if (fh == NULL) {
    char szBuff[80];
    sprintf(szBuff, "Outputfile %s cannot be created", szFileName);
    errhandler(808,
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/EvaBr/CFD-Lab/refs/heads/"
               "master/Backup/FinalProject/helper.c",
               szBuff);
  }
  for (k = nll; k <= nlh; k++) {
    for (j = ncl; j <= nch; j++) {
      for (i = nrl; i <= nrh; i++) {
        fprintf(fh, "%d ", m[i][j][k]);
      }
      fprintf(fh, "\n");
    }
    fprintf(fh,
            "-----------------------------------------------------------\n");
  }
  if (fclose(fh)) {
    char szBuff[80];
    sprintf(szBuff, "Outputfile %s cannot be closed", szFileName);
    errhandler(827,
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/EvaBr/CFD-Lab/refs/heads/"
               "master/Backup/FinalProject/helper.c",
               szBuff);
  };
}


x86 assembly (clang, -O0):
<write_imatrix2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
movq   $0x0,-0x38(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%rcx
lea    0xe69(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x90(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11f4 <write_imatrix2+0xa4>
lea    -0xe0(%rbp),%rdi
lea    -0x90(%rbp),%rdx
lea    0xe6f(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0xe0(%rbp),%rdx
mov    $0x328,%edi
lea    0xe75(%rip),%rsi
call   1030 <errhandler@plt>
mov    0x18(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    0x20(%rbp),%eax
jg     12a5 <write_imatrix2+0x155>
mov    -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    0x10(%rbp),%eax
jg     1285 <write_imatrix2+0x135>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     1265 <write_imatrix2+0x115>
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xeab(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    121e <write_imatrix2+0xce>
mov    -0x38(%rbp),%rdi
lea    0xeca(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    120c <write_imatrix2+0xbc>
mov    -0x38(%rbp),%rdi
lea    0xe6f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11fa <write_imatrix2+0xaa>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
cmp    $0x0,%rax
je     12ec <write_imatrix2+0x19c>
lea    -0x130(%rbp),%rdi
lea    -0x90(%rbp),%rdx
lea    0xe6f(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x130(%rbp),%rdx
mov    $0x33b,%edi
lea    0xd7d(%rip),%rsi
call   1030 <errhandler@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_imatrix2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
mov    %r9d,0x4(%rsp)
mov    %r8d,0xc(%rsp)
mov    %ecx,0x8(%rsp)
mov    %rdx,%r14
mov    %esi,%edx
mov    %rdi,%rcx
mov    0x130(%rsp),%ebx
mov    0x128(%rsp),%r15d
lea    0xe53(%rip),%rsi
lea    0x40(%rsp),%rbp
mov    %rbp,%rdi
xor    %eax,%eax
call   1080 <sprintf@plt>
lea    0xe7f(%rip),%rsi
mov    %rbp,%rdi
call   1070 <fopen@plt>
mov    %rax,%rbp
test   %rax,%rax
je     11dd <write_imatrix2+0x6d>
cmp    %ebx,%r15d
jg     1214 <write_imatrix2+0xa4>
jmp    1265 <write_imatrix2+0xf5>
lea    0xe60(%rip),%rsi
lea    0x90(%rsp),%r12
lea    0x40(%rsp),%rdx
mov    %r12,%rdi
xor    %eax,%eax
call   1080 <sprintf@plt>
lea    0xe62(%rip),%rsi
mov    $0x328,%edi
mov    %r12,%rdx
call   1030 <errhandler@plt>
cmp    %ebx,%r15d
jle    1265 <write_imatrix2+0xf5>
mov    %rbp,%rdi
call   1040 <fclose@plt>
test   %rax,%rax
je     1253 <write_imatrix2+0xe3>
lea    0xf14(%rip),%rsi
lea    0x90(%rsp),%rbx
lea    0x40(%rsp),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <sprintf@plt>
lea    0xe1e(%rip),%rsi
mov    $0x33b,%edi
mov    %rbx,%rdx
call   1030 <errhandler@plt>
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x120(%rsp),%ecx
movslq 0x8(%rsp),%rax
movslq 0x4(%rsp),%rdx
mov    %rdx,0x20(%rsp)
add    $0x1,%ecx
mov    %ecx,0x14(%rsp)
movslq %r15d,%rdx
add    $0x1,%ebx
lea    (%r14,%rax,8),%rcx
mov    %rcx,0x30(%rsp)
mov    0xc(%rsp),%ecx
sub    %eax,%ecx
add    $0x1,%ecx
mov    %rcx,0x28(%rsp)
mov    %ebx,0x10(%rsp)
mov    0x28(%rsp),%r15
jmp    12de <write_imatrix2+0x16e>
nopw   0x0(%rax,%rax,1)
mov    $0x3c,%esi
mov    $0x1,%edx
lea    0xe3e(%rip),%rdi
mov    %rbp,%rcx
call   1090 <fwrite@plt>
mov    0x18(%rsp),%rdx
add    $0x1,%rdx
mov    0x10(%rsp),%ebx
cmp    %edx,%ebx
je     1214 <write_imatrix2+0xa4>
mov    %rdx,0x18(%rsp)
mov    0x120(%rsp),%eax
cmp    %eax,0x4(%rsp)
jg     12b0 <write_imatrix2+0x140>
mov    0x20(%rsp),%r14
jmp    131b <write_imatrix2+0x1ab>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
mov    %rcx,%rbp
mov    %rcx,%rsi
call   1050 <fputc@plt>
add    $0x1,%r14
cmp    %r14d,0x14(%rsp)
je     12b0 <write_imatrix2+0x140>
mov    0x8(%rsp),%eax
cmp    0xc(%rsp),%eax
mov    %rbp,%rcx
lea    0xdce(%rip),%r12
mov    0x18(%rsp),%r13
mov    0x30(%rsp),%rbp
jg     1300 <write_imatrix2+0x190>
xor    %ebx,%ebx
mov    %r14,0x38(%rsp)
mov    0x0(%rbp,%rbx,8),%rax
mov    (%rax,%r14,8),%rax
mov    (%rax,%r13,4),%edx
mov    %rcx,%rdi
mov    %rcx,%r14
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r14,%rcx
mov    0x38(%rsp),%r14
add    $0x1,%rbx
cmp    %ebx,%r15d
jne    1340 <write_imatrix2+0x1d0>
jmp    1300 <write_imatrix2+0x190>

LLVM IR (-O0):
@.str = [66 x i8] c"/media/norbert/940CB6150CB5F27A/Documents/simulation/debug/d%i_%s\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [32 x i8] c"Outputfile %s cannot be created\00"
@.str.3 = [151 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/EvaBr/CFD-Lab/refs/heads/master/Backup/FinalProject/helper.c\00"
@.str.4 = [4 x i8] c"%d \00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [61 x i8] c"-----------------------------------------------------------\0A\00"
@.str.7 = [31 x i8] c"Outputfile %s cannot be closed\00"
define void @write_imatrix2(i8* %0, i32 %1, i32*** %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8) {
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32***
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32*
%23 = alloca [80 x i8]
%24 = alloca [80 x i8]
%25 = alloca [80 x i8]
store i8* %0, i8** %10
store i32 %1, i32* %11
store i32*** %2, i32**** %12
store i32 %3, i32* %13
store i32 %4, i32* %14
store i32 %5, i32* %15
store i32 %6, i32* %16
store i32 %7, i32* %17
store i32 %8, i32* %18
store i32* null, i32** %22
%26 = getelementptr inbounds [80 x i8], [80 x i8]* %23, i64 0, i64 0
%27 = load i32, i32* %11
%28 = load i8*, i8** %10
%29 = call i32 (i8*, i8*, ...) @sprintf(i8* %26, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i32 %27, i8* %28)
%30 = getelementptr inbounds [80 x i8], [80 x i8]* %23, i64 0, i64 0
%31 = call i32* @fopen(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %31, i32** %22
%32 = load i32*, i32** %22
%33 = icmp eq i32* %32, null
br i1 %33, label %34, label %40
34: ; preds = %9
%35 = getelementptr inbounds [80 x i8], [80 x i8]* %24, i64 0, i64 0
%36 = getelementptr inbounds [80 x i8], [80 x i8]* %23, i64 0, i64 0
%37 = call i32 (i8*, i8*, ...) @sprintf(i8* %35, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %36)
%38 = getelementptr inbounds [80 x i8], [80 x i8]* %24, i64 0, i64 0
%39 = call i32 @errhandler(i32 808, i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.3, i64 0, i64 0), i8* %38)
br label %40
40: ; preds = %34, %9
%41 = load i32, i32* %17
store i32 %41, i32* %21
br label %42
42: ; preds = %86, %40
%43 = load i32, i32* %21
%44 = load i32, i32* %18
%45 = icmp sle i32 %43, %44
br i1 %45, label %46, label %89
46: ; preds = %42
%47 = load i32, i32* %15
store i32 %47, i32* %20
br label %48
48: ; preds = %80, %46
%49 = load i32, i32* %20
%50 = load i32, i32* %16
%51 = icmp sle i32 %49, %50
br i1 %51, label %52, label %83
52: ; preds = %48
%53 = load i32, i32* %13
store i32 %53, i32* %19
br label %54
54: ; preds = %74, %52
%55 = load i32, i32* %19
%56 = load i32, i32* %14
%57 = icmp sle i32 %55, %56
br i1 %57, label %58, label %77
58: ; preds = %54
%59 = load i32*, i32** %22
%60 = load i32***, i32**** %12
%61 = load i32, i32* %19
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i32**, i32*** %60, i64 %62
%64 = load i32**, i32*** %63
%65 = load i32, i32* %20
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i32*, i32** %64, i64 %66
%68 = load i32*, i32** %67
%69 = load i32, i32* %21
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i32, i32* %68, i64 %70
%72 = load i32, i32* %71
%73 = call i32 (i32*, i8*, ...) @fprintf(i32* %59, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %72)
br label %74
74: ; preds = %58
%75 = load i32, i32* %19
%76 = add nsw i32 %75, 1
store i32 %76, i32* %19
br label %54
77: ; preds = %54
%78 = load i32*, i32** %22
%79 = call i32 (i32*, i8*, ...) @fprintf(i32* %78, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %80
80: ; preds = %77
%81 = load i32, i32* %20
%82 = add nsw i32 %81, 1
store i32 %82, i32* %20
br label %48
83: ; preds = %48
%84 = load i32*, i32** %22
%85 = call i32 (i32*, i8*, ...) @fprintf(i32* %84, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.6, i64 0, i64 0))
br label %86
86: ; preds = %83
%87 = load i32, i32* %21
%88 = add nsw i32 %87, 1
store i32 %88, i32* %21
br label %42
89: ; preds = %42
%90 = load i32*, i32** %22
%91 = call i64 @fclose(i32* %90)
%92 = icmp ne i64 %91, 0
br i1 %92, label %93, label %99
93: ; preds = %89
%94 = getelementptr inbounds [80 x i8], [80 x i8]* %25, i64 0, i64 0
%95 = getelementptr inbounds [80 x i8], [80 x i8]* %23, i64 0, i64 0
%96 = call i32 (i8*, i8*, ...) @sprintf(i8* %94, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i8* %95)
%97 = getelementptr inbounds [80 x i8], [80 x i8]* %25, i64 0, i64 0
%98 = call i32 @errhandler(i32 827, i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.3, i64 0, i64 0), i8* %97)
br label %99
99: ; preds = %93, %89
ret void
}

LLVM IR (-O2):
@.str = [66 x i8] c"/media/norbert/940CB6150CB5F27A/Documents/simulation/debug/d%i_%s\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [32 x i8] c"Outputfile %s cannot be created\00"
@.str.3 = [151 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/EvaBr/CFD-Lab/refs/heads/master/Backup/FinalProject/helper.c\00"
@.str.4 = [4 x i8] c"%d \00"
@.str.6 = [61 x i8] c"-----------------------------------------------------------\0A\00"
@.str.7 = [31 x i8] c"Outputfile %s cannot be closed\00"
define void @write_imatrix2(i8* %0, i32 %1, i32*** nocapture %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8) {
%10 = alloca [80 x i8]
%11 = alloca [80 x i8]
%12 = alloca [80 x i8]
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%14 = call i32 (i8*, i8*, ...) @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i32 %1, i8* %0)
%15 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %21
17: ; preds = %9
%18 = getelementptr inbounds [80 x i8], [80 x i8]* %11, i64 0, i64 0
%19 = call i32 (i8*, i8*, ...) @sprintf(i8* %18, i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%20 = call i32 @errhandler(i32 808, i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.3, i64 0, i64 0), i8* %18)
br label %21
21: ; preds = %17, %9
%22 = icmp sgt i32 %7, %8
br i1 %22, label %58, label %23
23: ; preds = %21
%24 = icmp sgt i32 %5, %6
%25 = icmp sgt i32 %3, %4
%26 = sext i32 %3 to i64
%27 = add i32 %4, 1
%28 = sext i32 %5 to i64
%29 = add i32 %6, 1
%30 = sext i32 %7 to i64
%31 = add i32 %8, 1
br label %32
32: ; preds = %23, %53
%33 = phi i64 [ %30, %23 ], [ %55, %53 ]
br i1 %24, label %53, label %34
34: ; preds = %32, %48
%35 = phi i64 [ %50, %48 ], [ %28, %32 ]
br i1 %25, label %48, label %36
36: ; preds = %34, %36
%37 = phi i64 [ %45, %36 ], [ %26, %34 ]
%38 = getelementptr inbounds i32**, i32*** %2, i64 %37
%39 = load i32**, i32*** %38
%40 = getelementptr inbounds i32*, i32** %39, i64 %35
%41 = load i32*, i32** %40
%42 = getelementptr inbounds i32, i32* %41, i64 %33
%43 = load i32, i32* %42
%44 = call i32 (i32*, i8*, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %43)
%45 = add nsw i64 %37, 1
%46 = trunc i64 %45 to i32
%47 = icmp eq i32 %27, %46
br i1 %47, label %48, label %36
48: ; preds = %36, %34
%49 = call i32 @fputc(i32 10, i32* %15)
%50 = add nsw i64 %35, 1
%51 = trunc i64 %50 to i32
%52 = icmp eq i32 %29, %51
br i1 %52, label %53, label %34
53: ; preds = %48, %32
%54 = call i64 @fwrite(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.6, i64 0, i64 0), i64 60, i64 1, i32* %15)
%55 = add nsw i64 %33, 1
%56 = trunc i64 %55 to i32
%57 = icmp eq i32 %31, %56
br i1 %57, label %58, label %32
58: ; preds = %53, %21
%59 = call i64 @fclose(i32* %15)
%60 = icmp eq i64 %59, 0
br i1 %60, label %65, label %61
61: ; preds = %58
%62 = getelementptr inbounds [80 x i8], [80 x i8]* %12, i64 0, i64 0
%63 = call i32 (i8*, i8*, ...) @sprintf(i8* %62, i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i8* %13)
%64 = call i32 @errhandler(i32 827, i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.3, i64 0, i64 0), i8* %62)
br label %65
65: ; preds = %61, %58
ret void
}