#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int const, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ free_matrix3(double ***);
double ***new_matrix3(int, int, int);
int sscanf(char *, char *, ...);
int /*<<< orphan*/ stderr;
char *sword(char *, char *, int);
double ***load_matrix3(char *fin, int *n, int *m, int *p) {
  FILE *f = fopen(fin, "r");
  if (f == NULL) {
    fprintf(stderr, "Invalid filename: %s\n", fin);
    return NULL;
  }
  char sbuf0[128], *s = sbuf0;
  if (fgets(s, 128, f) == NULL || sscanf(s, "%d %d %d", n, m, p) < 3) {
    fprintf(stderr, "Corrupt matrix header in file %s\n", fin);
    fclose(f);
    return NULL;
  }
  double ***X = new_matrix3(*n, *m, *p);
  const int CHARS_PER_FLOAT = 20;
  const int buflen = CHARS_PER_FLOAT * (*p);
  char sbuf[buflen];
  int i, j, k;
  for (i = 0; i < *n; i++) {
    for (j = 0; j < *m; j++) {
      s = sbuf;
      if (fgets(s, buflen, f) == NULL)
        break;
      for (k = 0; k < *p; k++) {
        if (sscanf(s, "%lf", &X[i][j][k]) < 1)
          break;
        s = sword(s, " \t", 1);
      }
      if (k < *p)
        break;
    }
    if (j < *m)
      break;
  }
  if (i < *n) {
    fprintf(stderr, "Corrupt matrix file '%s' at line %d\n", fin,
            i * (*m) + j + 2);
    fclose(f);
    free_matrix3(X);
    return NULL;
  }
  fclose(f);
  return X;
}


x86 assembly (clang, -O0):
<load_matrix3>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11e2 <load_matrix3+0x62>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe34(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    14d7 <load_matrix3+0x357>
lea    -0xb0(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0xb8(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    $0x80,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1239 <load_matrix3+0xb9>
mov    -0xb8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
lea    0xdef(%rip),%rsi
mov    $0x0,%al
call   1080 <sscanf@plt>
cmp    $0x3,%eax
jge    126a <load_matrix3+0xea>
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xdd4(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
movq   $0x0,-0x8(%rbp)
jmp    14d7 <load_matrix3+0x357>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%rax
mov    (%rax),%edx
call   1050 <new_matrix3@plt>
mov    %rax,-0xc0(%rbp)
movl   $0x14,-0xc4(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
shl    $0x2,%ecx
mov    %ecx,%eax
lea    (%rax,%rax,4),%eax
mov    %eax,-0xc8(%rbp)
mov    -0xc8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0xd0(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xf0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xd8(%rbp)
movl   $0x0,-0xdc(%rbp)
mov    -0xdc(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jge    1440 <load_matrix3+0x2c0>
movl   $0x0,-0xe0(%rbp)
mov    -0xe0(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
jge    1410 <load_matrix3+0x290>
mov    -0xf0(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0xb8(%rbp),%rdi
mov    -0xc8(%rbp),%esi
mov    -0x30(%rbp),%rdx
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    1343 <load_matrix3+0x1c3>
jmp    1410 <load_matrix3+0x290>
movl   $0x0,-0xe4(%rbp)
mov    -0xe4(%rbp),%eax
mov    -0x28(%rbp),%rcx
cmp    (%rcx),%eax
jge    13e0 <load_matrix3+0x260>
mov    -0xb8(%rbp),%rdi
mov    -0xc0(%rbp),%rax
movslq -0xdc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0xe0(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
movslq -0xe4(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
lea    0xcab(%rip),%rsi
mov    $0x0,%al
call   1080 <sscanf@plt>
cmp    $0x1,%eax
jge    13ad <load_matrix3+0x22d>
jmp    13e0 <load_matrix3+0x260>
mov    -0xb8(%rbp),%rdi
lea    0xc8c(%rip),%rsi
mov    $0x1,%edx
call   1090 <sword@plt>
mov    %rax,-0xb8(%rbp)
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    134d <load_matrix3+0x1cd>
mov    -0xe4(%rbp),%eax
mov    -0x28(%rbp),%rcx
cmp    (%rcx),%eax
jge    13f7 <load_matrix3+0x277>
jmp    1410 <load_matrix3+0x290>
jmp    13fc <load_matrix3+0x27c>
mov    -0xe0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe0(%rbp)
jmp    12fe <load_matrix3+0x17e>
mov    -0xe0(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
jge    1427 <load_matrix3+0x2a7>
jmp    1440 <load_matrix3+0x2c0>
jmp    142c <load_matrix3+0x2ac>
mov    -0xdc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xdc(%rbp)
jmp    12e2 <load_matrix3+0x162>
mov    -0xdc(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jge    14af <load_matrix3+0x32f>
mov    0x2b87(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0xdc(%rbp),%ecx
mov    -0x20(%rbp),%rax
imul   (%rax),%ecx
add    -0xe0(%rbp),%ecx
add    $0x2,%ecx
lea    0xbce(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0xc0(%rbp),%rdi
call   1030 <free_matrix3@plt>
movq   $0x0,-0x8(%rbp)
movl   $0x1,-0xe8(%rbp)
jmp    14cd <load_matrix3+0x34d>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0xc0(%rbp),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0xe8(%rbp)
mov    -0xd0(%rbp),%rax
mov    %rax,%rsp
mov    -0x8(%rbp),%rax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_matrix3>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
mov    %rcx,-0x38(%rbp)
mov    %rdx,-0x30(%rbp)
mov    %rsi,-0x40(%rbp)
mov    %rdi,%r14
lea    0xe56(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1220 <load_matrix3+0xa0>
mov    %rax,%r15
lea    -0xf0(%rbp),%rdi
mov    $0x80,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11f6 <load_matrix3+0x76>
lea    0xe41(%rip),%rsi
lea    -0xf0(%rbp),%rdi
mov    -0x40(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
xor    %eax,%eax
call   1080 <sscanf@plt>
cmp    $0x2,%eax
jg     1242 <load_matrix3+0xc2>
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
lea    0xe1b(%rip),%rsi
xor    %r13d,%r13d
mov    %r14,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
jmp    1418 <load_matrix3+0x298>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
lea    0xdd2(%rip),%rsi
xor    %r13d,%r13d
mov    %r14,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1418 <load_matrix3+0x298>
xor    %ebx,%ebx
mov    -0x40(%rbp),%r13
mov    0x0(%r13),%edi
mov    -0x30(%rbp),%rax
mov    (%rax),%esi
mov    -0x38(%rbp),%r12
mov    (%r12),%edx
call   1050 <new_matrix3@plt>
mov    %rax,-0x48(%rbp)
mov    %rsp,%rcx
mov    (%r12),%eax
shl    $0x2,%eax
lea    (%rax,%rax,4),%eax
mov    %rax,-0x70(%rbp)
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rdx
sub    %rax,%rdx
mov    %rdx,-0x50(%rbp)
mov    %rdx,%rsp
mov    0x0(%r13),%eax
test   %eax,%eax
mov    %r14,-0x58(%rbp)
mov    %rcx,-0x60(%rbp)
jle    13b7 <load_matrix3+0x237>
mov    -0x30(%rbp),%r14
mov    (%r14),%ecx
xor    %ebx,%ebx
mov    %r15,-0x68(%rbp)
nopw   0x0(%rax,%rax,1)
mov    $0x0,%r12d
test   %ecx,%ecx
jle    1396 <load_matrix3+0x216>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    -0x50(%rbp),%rdi
mov    -0x70(%rbp),%rsi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1393 <load_matrix3+0x213>
mov    -0x38(%rbp),%rax
mov    (%rax),%eax
test   %eax,%eax
jle    1360 <load_matrix3+0x1e0>
xor    %r14d,%r14d
xor    %r13d,%r13d
mov    -0x50(%rbp),%r15
nopl   (%rax)
mov    -0x48(%rbp),%rax
mov    (%rax,%rbx,8),%rax
mov    (%rax,%r12,8),%rdx
add    %r14,%rdx
mov    %r15,%rdi
lea    0xd2a(%rip),%rsi
xor    %eax,%eax
call   1080 <sscanf@plt>
test   %eax,%eax
jle    1370 <load_matrix3+0x1f0>
mov    %r15,%rdi
lea    0xd19(%rip),%rsi
mov    $0x1,%edx
call   1090 <sword@plt>
mov    %rax,%r15
add    $0x1,%r13
mov    -0x38(%rbp),%rax
movslq (%rax),%rax
add    $0x8,%r14
cmp    %rax,%r13
jl     1300 <load_matrix3+0x180>
jmp    1376 <load_matrix3+0x1f6>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %r13d,%r13d
cmp    %eax,%r13d
jge    1383 <load_matrix3+0x203>
jmp    1393 <load_matrix3+0x213>
nopw   0x0(%rax,%rax,1)
mov    -0x38(%rbp),%rax
mov    (%rax),%eax
mov    -0x68(%rbp),%r15
mov    -0x30(%rbp),%r14
cmp    %eax,%r13d
jl     1393 <load_matrix3+0x213>
add    $0x1,%r12
movslq (%r14),%rax
cmp    %rax,%r12
jl     12d0 <load_matrix3+0x150>
mov    (%r14),%ecx
cmp    %ecx,%r12d
jl     13cd <load_matrix3+0x24d>
mov    %rbx,%rdx
add    $0x1,%rdx
mov    -0x40(%rbp),%rax
movslq (%rax),%rax
mov    %rdx,%rbx
cmp    %rax,%rdx
jl     12b0 <load_matrix3+0x130>
jmp    13d3 <load_matrix3+0x253>
mov    -0x48(%rbp),%r13
mov    -0x30(%rbp),%r14
cmp    %eax,%ebx
jl     13db <load_matrix3+0x25b>
mov    %r15,%rdi
call   1040 <fclose@plt>
jmp    1414 <load_matrix3+0x294>
mov    -0x40(%rbp),%rax
mov    (%rax),%eax
mov    -0x48(%rbp),%r13
cmp    %eax,%ebx
jge    13c3 <load_matrix3+0x243>
mov    0x2bfe(%rip),%rax
mov    (%rax),%edi
imul   (%r14),%ebx
lea    (%r12,%rbx,1),%ecx
add    $0x2,%ecx
lea    0xc54(%rip),%rsi
mov    -0x58(%rbp),%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %r13,%rdi
call   1030 <free_matrix3@plt>
xor    %r13d,%r13d
mov    -0x60(%rbp),%rsp
mov    %r13,%rax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [22 x i8] c"Invalid filename: %s\0A\00"
@.str.2 = [9 x i8] c"%d %d %d\00"
@.str.3 = [34 x i8] c"Corrupt matrix header in file %s\0A\00"
@.str.4 = [4 x i8] c"%lf\00"
@.str.5 = [3 x i8] c" \09\00"
@.str.6 = [37 x i8] c"Corrupt matrix file '%s' at line %d\0A\00"
define double*** @load_matrix3(i8* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca double***
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca [128 x i8]
%12 = alloca i8*
%13 = alloca double***
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i64
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
store i8* %0, i8** %6
store i32* %1, i32** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
%22 = load i8*, i8** %6
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %23, i32** %10
%24 = load i32*, i32** %10
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %30
26: ; preds = %4
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %6
%29 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %28)
store double*** null, double**** %5
br label %157
30: ; preds = %4
%31 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
store i8* %31, i8** %12
%32 = load i8*, i8** %12
%33 = load i32*, i32** %10
%34 = call i32* @fgets(i8* %32, i32 128, i32* %33)
%35 = icmp eq i32* %34, null
br i1 %35, label %43, label %36
36: ; preds = %30
%37 = load i8*, i8** %12
%38 = load i32*, i32** %7
%39 = load i32*, i32** %8
%40 = load i32*, i32** %9
%41 = call i32 (i8*, i8*, ...) @sscanf(i8* %37, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %38, i32* %39, i32* %40)
%42 = icmp slt i32 %41, 3
br i1 %42, label %43, label %49
43: ; preds = %36, %30
%44 = load i32, i32* @stderr
%45 = load i8*, i8** %6
%46 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* %45)
%47 = load i32*, i32** %10
%48 = call i32 @fclose(i32* %47)
store double*** null, double**** %5
br label %157
49: ; preds = %36
%50 = load i32*, i32** %7
%51 = load i32, i32* %50
%52 = load i32*, i32** %8
%53 = load i32, i32* %52
%54 = load i32*, i32** %9
%55 = load i32, i32* %54
%56 = call double*** @new_matrix3(i32 %51, i32 %53, i32 %55)
store double*** %56, double**** %13
store i32 20, i32* %14
%57 = load i32*, i32** %9
%58 = load i32, i32* %57
%59 = mul nsw i32 20, %58
store i32 %59, i32* %15
%60 = load i32, i32* %15
%61 = zext i32 %60 to i64
%62 = call i8* @llvm.stacksave()
store i8* %62, i8** %16
%63 = alloca i8, i64 %61
store i64 %61, i64* %17
store i32 0, i32* %18
br label %64
64: ; preds = %128, %49
%65 = load i32, i32* %18
%66 = load i32*, i32** %7
%67 = load i32, i32* %66
%68 = icmp slt i32 %65, %67
br i1 %68, label %69, label %131
69: ; preds = %64
store i32 0, i32* %19
br label %70
70: ; preds = %118, %69
%71 = load i32, i32* %19
%72 = load i32*, i32** %8
%73 = load i32, i32* %72
%74 = icmp slt i32 %71, %73
br i1 %74, label %75, label %121
75: ; preds = %70
store i8* %63, i8** %12
%76 = load i8*, i8** %12
%77 = load i32, i32* %15
%78 = load i32*, i32** %10
%79 = call i32* @fgets(i8* %76, i32 %77, i32* %78)
%80 = icmp eq i32* %79, null
br i1 %80, label %81, label %82
81: ; preds = %75
br label %121
82: ; preds = %75
store i32 0, i32* %20
br label %83
83: ; preds = %108, %82
%84 = load i32, i32* %20
%85 = load i32*, i32** %9
%86 = load i32, i32* %85
%87 = icmp slt i32 %84, %86
br i1 %87, label %88, label %111
88: ; preds = %83
%89 = load i8*, i8** %12
%90 = load double***, double**** %13
%91 = load i32, i32* %18
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds double**, double*** %90, i64 %92
%94 = load double**, double*** %93
%95 = load i32, i32* %19
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds double*, double** %94, i64 %96
%98 = load double*, double** %97
%99 = load i32, i32* %20
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds double, double* %98, i64 %100
%102 = call i32 (i8*, i8*, ...) @sscanf(i8* %89, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %101)
%103 = icmp slt i32 %102, 1
br i1 %103, label %104, label %105
104: ; preds = %88
br label %111
105: ; preds = %88
%106 = load i8*, i8** %12
%107 = call i8* @sword(i8* %106, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 1)
store i8* %107, i8** %12
br label %108
108: ; preds = %105
%109 = load i32, i32* %20
%110 = add nsw i32 %109, 1
store i32 %110, i32* %20
br label %83
111: ; preds = %104, %83
%112 = load i32, i32* %20
%113 = load i32*, i32** %9
%114 = load i32, i32* %113
%115 = icmp slt i32 %112, %114
br i1 %115, label %116, label %117
116: ; preds = %111
br label %121
117: ; preds = %111
br label %118
118: ; preds = %117
%119 = load i32, i32* %19
%120 = add nsw i32 %119, 1
store i32 %120, i32* %19
br label %70
121: ; preds = %116, %81, %70
%122 = load i32, i32* %19
%123 = load i32*, i32** %8
%124 = load i32, i32* %123
%125 = icmp slt i32 %122, %124
br i1 %125, label %126, label %127
126: ; preds = %121
br label %131
127: ; preds = %121
br label %128
128: ; preds = %127
%129 = load i32, i32* %18
%130 = add nsw i32 %129, 1
store i32 %130, i32* %18
br label %64
131: ; preds = %126, %64
%132 = load i32, i32* %18
%133 = load i32*, i32** %7
%134 = load i32, i32* %133
%135 = icmp slt i32 %132, %134
br i1 %135, label %136, label %151
136: ; preds = %131
%137 = load i32, i32* @stderr
%138 = load i8*, i8** %6
%139 = load i32, i32* %18
%140 = load i32*, i32** %8
%141 = load i32, i32* %140
%142 = mul nsw i32 %139, %141
%143 = load i32, i32* %19
%144 = add nsw i32 %142, %143
%145 = add nsw i32 %144, 2
%146 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %137, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i8* %138, i32 %145)
%147 = load i32*, i32** %10
%148 = call i32 @fclose(i32* %147)
%149 = load double***, double**** %13
%150 = call i32 @free_matrix3(double*** %149)
store double*** null, double**** %5
store i32 1, i32* %21
br label %155
151: ; preds = %131
%152 = load i32*, i32** %10
%153 = call i32 @fclose(i32* %152)
%154 = load double***, double**** %13
store double*** %154, double**** %5
store i32 1, i32* %21
br label %155
155: ; preds = %151, %136
%156 = load i8*, i8** %16
br label %157
157: ; preds = %155, %43, %26
%158 = load double***, double**** %5
ret double*** %158
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [22 x i8] c"Invalid filename: %s\0A\00"
@.str.2 = [9 x i8] c"%d %d %d\00"
@.str.3 = [34 x i8] c"Corrupt matrix header in file %s\0A\00"
@.str.4 = [4 x i8] c"%lf\00"
@.str.5 = [3 x i8] c" \09\00"
@.str.6 = [37 x i8] c"Corrupt matrix file '%s' at line %d\0A\00"
define double*** @load_matrix3(i8* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca [128 x i8]
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %11
8: ; preds = %4
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %118
11: ; preds = %4
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%13 = call i32* @fgets(i8* %12, i32 128, i32* %6)
%14 = icmp eq i32* %13, null
br i1 %14, label %18, label %15
15: ; preds = %11
%16 = call i32 (i8*, i8*, ...) @sscanf(i8* %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%17 = icmp slt i32 %16, 3
br i1 %17, label %18, label %22
18: ; preds = %15, %11
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%21 = call i32 @fclose(i32* %6)
br label %116
22: ; preds = %15
%23 = load i32, i32* %1
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = call double*** @new_matrix3(i32 %23, i32 %24, i32 %25)
%27 = load i32, i32* %3
%28 = mul nsw i32 %27, 20
%29 = zext i32 %28 to i64
%30 = call i8* @llvm.stacksave()
%31 = alloca i8, i64 %29
%32 = load i32, i32* %1
%33 = icmp sgt i32 %32, 0
br i1 %33, label %34, label %98
34: ; preds = %22
%35 = load i32, i32* %2
br label %36
36: ; preds = %34, %89
%37 = phi i32 [ %35, %34 ], [ %84, %89 ]
%38 = phi i64 [ 0, %34 ], [ %90, %89 ]
%39 = icmp sgt i32 %37, 0
br i1 %39, label %40, label %83
40: ; preds = %36
%41 = getelementptr inbounds double**, double*** %26, i64 %38
br label %42
42: ; preds = %40, %74
%43 = phi i64 [ 0, %40 ], [ %75, %74 ]
%44 = call i32* @fgets(i8* %31, i32 %28, i32* %6)
%45 = icmp eq i32* %44, null
br i1 %45, label %79, label %46
46: ; preds = %42
%47 = load i32, i32* %3
%48 = icmp sgt i32 %47, 0
br i1 %48, label %49, label %70
49: ; preds = %46, %60
%50 = phi i64 [ %62, %60 ], [ 0, %46 ]
%51 = phi i8* [ %61, %60 ], [ %31, %46 ]
%52 = load double**, double*** %41
%53 = getelementptr inbounds double*, double** %52, i64 %43
%54 = load double*, double** %53
%55 = getelementptr inbounds double, double* %54, i64 %50
%56 = call i32 (i8*, i8*, ...) @sscanf(i8* %51, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %55)
%57 = icmp slt i32 %56, 1
br i1 %57, label %58, label %60
58: ; preds = %49
%59 = load i32, i32* %3
br label %66
60: ; preds = %49
%61 = call i8* @sword(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 1)
%62 = add nuw nsw i64 %50, 1
%63 = load i32, i32* %3
%64 = sext i32 %63 to i64
%65 = icmp slt i64 %62, %64
br i1 %65, label %49, label %66
66: ; preds = %60, %58
%67 = phi i32 [ %59, %58 ], [ %63, %60 ]
%68 = phi i64 [ %50, %58 ], [ %62, %60 ]
%69 = trunc i64 %68 to i32
br label %70
70: ; preds = %66, %46
%71 = phi i32 [ %47, %46 ], [ %67, %66 ]
%72 = phi i32 [ 0, %46 ], [ %69, %66 ]
%73 = icmp slt i32 %72, %71
br i1 %73, label %79, label %74
74: ; preds = %70
%75 = add nuw nsw i64 %43, 1
%76 = load i32, i32* %2
%77 = sext i32 %76 to i64
%78 = icmp slt i64 %75, %77
br i1 %78, label %42, label %79
79: ; preds = %70, %42, %74
%80 = phi i64 [ %75, %74 ], [ %43, %42 ], [ %43, %70 ]
%81 = trunc i64 %80 to i32
%82 = load i32, i32* %2
br label %83
83: ; preds = %79, %36
%84 = phi i32 [ %37, %36 ], [ %82, %79 ]
%85 = phi i32 [ 0, %36 ], [ %81, %79 ]
%86 = icmp slt i32 %85, %84
br i1 %86, label %87, label %89
87: ; preds = %83
%88 = load i32, i32* %1
br label %94
89: ; preds = %83
%90 = add nuw nsw i64 %38, 1
%91 = load i32, i32* %1
%92 = sext i32 %91 to i64
%93 = icmp slt i64 %90, %92
br i1 %93, label %36, label %94
94: ; preds = %89, %87
%95 = phi i32 [ %88, %87 ], [ %91, %89 ]
%96 = phi i64 [ %38, %87 ], [ %90, %89 ]
%97 = trunc i64 %96 to i32
br label %98
98: ; preds = %94, %22
%99 = phi i32 [ %32, %22 ], [ %95, %94 ]
%100 = phi i32 [ 0, %22 ], [ %97, %94 ]
%101 = phi i32 [ undef, %22 ], [ %85, %94 ]
%102 = icmp slt i32 %100, %99
br i1 %102, label %103, label %112
103: ; preds = %98
%104 = load i32, i32* @stderr
%105 = load i32, i32* %2
%106 = mul nsw i32 %105, %100
%107 = add i32 %101, 2
%108 = add i32 %107, %106
%109 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %104, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i8* %0, i32 %108)
%110 = call i32 @fclose(i32* %6)
%111 = call i32 @free_matrix3(double*** %26)
br label %114
112: ; preds = %98
%113 = call i32 @fclose(i32* %6)
br label %114
114: ; preds = %112, %103
%115 = phi double*** [ null, %103 ], [ %26, %112 ]
br label %116
116: ; preds = %114, %18
%117 = phi double*** [ null, %18 ], [ %115, %114 ]
br label %118
118: ; preds = %116, %8
%119 = phi double*** [ null, %8 ], [ %117, %116 ]
ret double*** %119
}