#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_matrix2(const char *szDebug, int timeStepNumber, double ***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, "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(314,
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/EvaBr/CFD-Lab/refs/heads/"
               "master/Backup/FinalProjectPresentation/helper.c",
               szBuff);
  }
  for (k = nll; k <= nlh; k++) {
    for (j = ncl; j <= nch; j++) {
      for (i = nrl; i <= nrh; i++) {
        fprintf(fh, "%f ", 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(333,
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/EvaBr/CFD-Lab/refs/heads/"
               "master/Backup/FinalProjectPresentation/helper.c",
               szBuff);
  };
}


x86 assembly (clang, -O0):
<write_matrix2>:
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    0xe61(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11f4 <write_matrix2+0xa4>
lea    -0xe0(%rbp),%rdi
lea    -0x90(%rbp),%rdx
lea    0xe3a(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0xe0(%rbp),%rdx
mov    $0x13a,%edi
lea    0xe40(%rip),%rsi
call   1030 <errhandler@plt>
mov    0x18(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    0x20(%rbp),%eax
jg     12a7 <write_matrix2+0x157>
mov    -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    0x10(%rbp),%eax
jg     1287 <write_matrix2+0x137>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     1267 <write_matrix2+0x117>
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
movsd  (%rax,%rcx,8),%xmm0
lea    0xe80(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    121e <write_matrix2+0xce>
mov    -0x38(%rbp),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    120c <write_matrix2+0xbc>
mov    -0x38(%rbp),%rdi
lea    0xe44(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11fa <write_matrix2+0xaa>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
cmp    $0x0,%rax
je     12ee <write_matrix2+0x19e>
lea    -0x130(%rbp),%rdi
lea    -0x90(%rbp),%rdx
lea    0xe44(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x130(%rbp),%rdx
mov    $0x14d,%edi
lea    0xd46(%rip),%rsi
call   1030 <errhandler@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_matrix2>:
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    0xe4a(%rip),%rsi
mov    %rbp,%rdi
call   1070 <fopen@plt>
mov    %rax,%rbp
test   %rax,%rax
je     11dd <write_matrix2+0x6d>
cmp    %ebx,%r15d
jg     1214 <write_matrix2+0xa4>
jmp    1265 <write_matrix2+0xf5>
lea    0xe2b(%rip),%rsi
lea    0x90(%rsp),%r12
lea    0x40(%rsp),%rdx
mov    %r12,%rdi
xor    %eax,%eax
call   1080 <sprintf@plt>
lea    0xe2d(%rip),%rsi
mov    $0x13a,%edi
mov    %r12,%rdx
call   1030 <errhandler@plt>
cmp    %ebx,%r15d
jle    1265 <write_matrix2+0xf5>
mov    %rbp,%rdi
call   1040 <fclose@plt>
test   %rax,%rax
je     1253 <write_matrix2+0xe3>
lea    0xeeb(%rip),%rsi
lea    0x90(%rsp),%rbx
lea    0x40(%rsp),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <sprintf@plt>
lea    0xde9(%rip),%rsi
mov    $0x14d,%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_matrix2+0x16e>
nopw   0x0(%rax,%rax,1)
mov    $0x3c,%esi
mov    $0x1,%edx
lea    0xe15(%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_matrix2+0xa4>
mov    %rdx,0x18(%rsp)
mov    0x120(%rsp),%eax
cmp    %eax,0x4(%rsp)
jg     12b0 <write_matrix2+0x140>
mov    0x20(%rsp),%r14
jmp    131b <write_matrix2+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_matrix2+0x140>
mov    0x8(%rsp),%eax
cmp    0xc(%rsp),%eax
mov    %rbp,%rcx
lea    0xda5(%rip),%r12
mov    0x18(%rsp),%r13
mov    0x30(%rsp),%rbp
jg     1300 <write_matrix2+0x190>
xor    %ebx,%ebx
mov    %r14,0x38(%rsp)
mov    0x0(%rbp,%rbx,8),%rax
mov    (%rax,%r14,8),%rax
movsd  (%rax,%r13,8),%xmm0
mov    %rcx,%rdi
mov    %rcx,%r14
mov    %r12,%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    %r14,%rcx
mov    0x38(%rsp),%r14
add    $0x1,%rbx
cmp    %ebx,%r15d
jne    1340 <write_matrix2+0x1d0>
jmp    1300 <write_matrix2+0x190>

LLVM IR (-O0):
@.str = [13 x i8] c"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 = [163 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/FinalProjectPresentation/helper.c\00"
@.str.4 = [4 x i8] c"%f \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_matrix2(i8* %0, i32 %1, double*** %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8) {
%10 = alloca i8*
%11 = alloca i32
%12 = alloca double***
%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 double*** %2, double**** %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 ([13 x i8], [13 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 314, i8* getelementptr inbounds ([163 x i8], [163 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 double***, double**** %12
%61 = load i32, i32* %19
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double**, double*** %60, i64 %62
%64 = load double**, double*** %63
%65 = load i32, i32* %20
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double*, double** %64, i64 %66
%68 = load double*, double** %67
%69 = load i32, i32* %21
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds double, double* %68, i64 %70
%72 = load double, double* %71
%73 = call i32 (i32*, i8*, ...) @fprintf(i32* %59, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double %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 333, i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.3, i64 0, i64 0), i8* %97)
br label %99
99: ; preds = %93, %89
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"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 = [163 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/FinalProjectPresentation/helper.c\00"
@.str.4 = [4 x i8] c"%f \00"
@.str.6 = [61 x i8] c"-----------------------------------------------------------\0A\00"
@.str.7 = [31 x i8] c"Outputfile %s cannot be closed\00"
define void @write_matrix2(i8* %0, i32 %1, double*** 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 ([13 x i8], [13 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 314, i8* getelementptr inbounds ([163 x i8], [163 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 double**, double*** %2, i64 %37
%39 = load double**, double*** %38
%40 = getelementptr inbounds double*, double** %39, i64 %35
%41 = load double*, double** %40
%42 = getelementptr inbounds double, double* %41, i64 %33
%43 = load double, double* %42
%44 = call i32 (i32*, i8*, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double %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 333, i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.3, i64 0, i64 0), i8* %62)
br label %65
65: ; preds = %61, %58
ret void
}