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

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, ...);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, int *, int *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
double **zero_dmat(int, int);
double **load_dmat(char fnam[], int *nrow, int *ncol, int *ntot) {
  FILE *fmat = fopen(fnam, "r");
  if (fmat == NULL) {
    {
      fprintf(stderr,
              "Error in file: %s, line: %d!\n"
              "File %s not exist!"
              "\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/hou-dao/cluster/refs/heads/master/src/"
              "io.c",
              12, fnam);
      exit(1);
    };
  } else {
    int irow = 0, icol = 0, itot = 0;
    double temp = 0;
    char title[256];
    fgets(title, sizeof(title), fmat);
    fgets(title, sizeof(title), fmat);
    fscanf(fmat, "%d%d%d", nrow, ncol, ntot);
    double **mat = zero_dmat(*nrow, *ncol);
    while (fscanf(fmat, "%d%d%lf", &irow, &icol, &temp) != EOF) {
      if (irow >= *nrow || icol >= *ncol) {
        fprintf(stderr,
                "Error in file: %s, line: %d!\n"
                "File %s overflow!"
                "\n",
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/hou-dao/cluster/refs/heads/"
                "master/src/io.c",
                23, fnam);
        exit(1);
      };
      mat[irow - 1][icol - 1] = temp;
      ++itot;
    }
    if (itot != *ntot) {
      fprintf(stdout,
              "Alert in file: %s, line: %d!\n"
              "Number of nonzero elements not consistent!\n"
              "\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/hou-dao/cluster/refs/heads/master/src/"
              "io.c",
              28);
    };
    return mat;
  }
  fclose(fmat);
  return NULL;
}


x86 assembly (clang, -O0):
<load_dmat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe7a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11cb <load_dmat+0x6b>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%r8
lea    0xe54(%rip),%rsi
lea    0xe7e(%rip),%rdx
mov    $0xc,%ecx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
lea    -0x140(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x100,%esi
call   1050 <fgets@plt>
lea    -0x140(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x100,%esi
call   1050 <fgets@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    0xe8f(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
call   1030 <zero_dmat@plt>
mov    %rax,-0x148(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe6c(%rip),%rsi
lea    -0x2c(%rbp),%rdx
lea    -0x30(%rbp),%rcx
lea    -0x40(%rbp),%r8
mov    $0x0,%al
call   1040 <fscanf@plt>
mov    0x2d7b(%rip),%rcx
cmp    (%rcx),%rax
je     12fa <load_dmat+0x19a>
mov    -0x2c(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    1294 <load_dmat+0x134>
mov    -0x30(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jl     12c5 <load_dmat+0x165>
mov    0x2d3d(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%r8
lea    0xe1f(%rip),%rsi
lea    0xd84(%rip),%rdx
mov    $0x17,%ecx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
movsd  -0x40(%rbp),%xmm0
mov    -0x148(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x30(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1248 <load_dmat+0xe8>
mov    -0x34(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
je     132c <load_dmat+0x1cc>
mov    0x2cc0(%rip),%rax
mov    (%rax),%edi
lea    0xdde(%rip),%rsi
lea    0xd13(%rip),%rdx
mov    $0x1c,%ecx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x148(%rbp),%rax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_dmat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    %rcx,%rbp
mov    %rdx,%r12
mov    %rsi,%r13
lea    0xe7f(%rip),%rsi
mov    %rdi,0x10(%rsp)
call   1070 <fopen@plt>
test   %rax,%rax
je     130a <load_dmat+0x1aa>
mov    %rax,%rbx
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
lea    0x20(%rsp),%r14
mov    %r14,%rdi
mov    $0x100,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
mov    %r14,%rdi
mov    $0x100,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
lea    0xedd(%rip),%rsi
xor    %r14d,%r14d
mov    %rbx,%rdi
mov    %r13,%rdx
mov    %r12,%rcx
mov    %rbp,0x18(%rsp)
mov    %rbp,%r8
xor    %eax,%eax
call   1040 <fscanf@plt>
mov    0x0(%r13),%edi
mov    (%r12),%esi
call   1030 <zero_dmat@plt>
mov    %rax,%rbp
lea    0xeb2(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
lea    0x8(%rsp),%r8
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <fscanf@plt>
mov    0x2dbd(%rip),%rcx
cmp    (%rcx),%rax
je     1296 <load_dmat+0x136>
lea    0x8(%rsp),%r15
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
movslq 0x4(%rsp),%rax
cmp    0x0(%r13),%eax
jge    12d8 <load_dmat+0x178>
movslq (%rsp),%rcx
cmp    (%r12),%ecx
jge    12d8 <load_dmat+0x178>
movsd  0x8(%rsp),%xmm0
mov    -0x8(%rbp,%rax,8),%rax
movsd  %xmm0,-0x8(%rax,%rcx,8)
add    $0x1,%r14d
mov    %rbx,%rdi
lea    0xe47(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
mov    %r15,%r8
xor    %eax,%eax
call   1040 <fscanf@plt>
mov    0x2d57(%rip),%rcx
cmp    (%rcx),%rax
jne    1240 <load_dmat+0xe0>
mov    0x18(%rsp),%rax
cmp    (%rax),%r14d
je     12c3 <load_dmat+0x163>
mov    0x2d29(%rip),%rax
mov    (%rax),%edi
lea    0xe47(%rip),%rsi
lea    0xd7c(%rip),%rdx
mov    $0x1c,%ecx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rbp,%rax
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cf9(%rip),%rax
mov    (%rax),%edi
lea    0xddf(%rip),%rsi
lea    0xd44(%rip),%rdx
mov    $0x17,%ecx
mov    0x10(%rsp),%r8
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    0x2cc7(%rip),%rax
mov    (%rax),%edi
lea    0xce8(%rip),%rsi
lea    0xd12(%rip),%rdx
mov    $0xc,%ecx
jmp    12f4 <load_dmat+0x194>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [49 x i8] c"Error in file: %s, line: %d!\0AFile %s not exist!\0A\00"
@.str.2 = [133 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/hou-dao/cluster/refs/heads/master/src/io.c\00"
@.str.3 = [7 x i8] c"%d%d%d\00"
@.str.4 = [8 x i8] c"%d%d%lf\00"
@EOF = global i64 0
@.str.5 = [48 x i8] c"Error in file: %s, line: %d!\0AFile %s overflow!\0A\00"
@stdout = global i32 0
@.str.6 = [74 x i8] c"Alert in file: %s, line: %d!\0ANumber of nonzero elements not consistent!\0A\0A\00"
define double** @load_dmat(i8* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
%14 = alloca [256 x i8]
%15 = alloca double**
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%16 = load i8*, i8** %5
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %17, i32** %9
%18 = load i32*, i32** %9
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %25
20: ; preds = %4
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %5
%23 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([133 x i8], [133 x i8]* @.str.2, i64 0, i64 0), i32 12, i8* %22)
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %4
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
store double 0.000000e+00, double* %13
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
%27 = load i32*, i32** %9
%28 = call i32 @fgets(i8* %26, i32 256, i32* %27)
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
%30 = load i32*, i32** %9
%31 = call i32 @fgets(i8* %29, i32 256, i32* %30)
%32 = load i32*, i32** %9
%33 = load i32*, i32** %6
%34 = load i32*, i32** %7
%35 = load i32*, i32** %8
%36 = call i64 (i32*, i8*, i32*, i32*, ...) @fscanf(i32* %32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32* %33, i32* %34, i32* %35)
%37 = load i32*, i32** %6
%38 = load i32, i32* %37
%39 = load i32*, i32** %7
%40 = load i32, i32* %39
%41 = call double** @zero_dmat(i32 %38, i32 %40)
store double** %41, double*** %15
br label %42
42: ; preds = %62, %25
%43 = load i32*, i32** %9
%44 = call i64 (i32*, i8*, i32*, i32*, ...) @fscanf(i32* %43, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32* %10, i32* %11, double* %13)
%45 = load i64, i64* @EOF
%46 = icmp ne i64 %44, %45
br i1 %46, label %47, label %76
47: ; preds = %42
%48 = load i32, i32* %10
%49 = load i32*, i32** %6
%50 = load i32, i32* %49
%51 = icmp sge i32 %48, %50
br i1 %51, label %57, label %52
52: ; preds = %47
%53 = load i32, i32* %11
%54 = load i32*, i32** %7
%55 = load i32, i32* %54
%56 = icmp sge i32 %53, %55
br i1 %56, label %57, label %62
57: ; preds = %52, %47
%58 = load i32, i32* @stderr
%59 = load i8*, i8** %5
%60 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([133 x i8], [133 x i8]* @.str.2, i64 0, i64 0), i32 23, i8* %59)
%61 = call i32 @exit(i32 1)
unreachable
62: ; preds = %52
%63 = load double, double* %13
%64 = load double**, double*** %15
%65 = load i32, i32* %10
%66 = sub nsw i32 %65, 1
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds double*, double** %64, i64 %67
%69 = load double*, double** %68
%70 = load i32, i32* %11
%71 = sub nsw i32 %70, 1
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds double, double* %69, i64 %72
store double %63, double* %73
%74 = load i32, i32* %12
%75 = add nsw i32 %74, 1
store i32 %75, i32* %12
br label %42
76: ; preds = %42
%77 = load i32, i32* %12
%78 = load i32*, i32** %8
%79 = load i32, i32* %78
%80 = icmp ne i32 %77, %79
br i1 %80, label %81, label %84
81: ; preds = %76
%82 = load i32, i32* @stdout
%83 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %82, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([133 x i8], [133 x i8]* @.str.2, i64 0, i64 0), i32 28)
br label %84
84: ; preds = %81, %76
%85 = load double**, double*** %15
ret double** %85
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [49 x i8] c"Error in file: %s, line: %d!\0AFile %s not exist!\0A\00"
@.str.2 = [133 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/hou-dao/cluster/refs/heads/master/src/io.c\00"
@.str.3 = [7 x i8] c"%d%d%d\00"
@.str.4 = [8 x i8] c"%d%d%lf\00"
@EOF = global i64 0
@.str.5 = [48 x i8] c"Error in file: %s, line: %d!\0AFile %s overflow!\0A\00"
@stdout = global i32 0
@.str.6 = [74 x i8] c"Alert in file: %s, line: %d!\0ANumber of nonzero elements not consistent!\0A\0A\00"
define double** @load_dmat(i8* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca [256 x i8]
%9 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %15
11: ; preds = %4
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([133 x i8], [133 x i8]* @.str.2, i64 0, i64 0), i32 12, i8* %0)
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %4
%16 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%17 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%18 = bitcast double* %7 to i8*
store double 0.000000e+00, double* %7
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%20 = call i32 @fgets(i8* %19, i32 256, i32* %9)
%21 = call i32 @fgets(i8* %19, i32 256, i32* %9)
%22 = call i64 (i32*, i8*, i32*, i32*, ...) @fscanf(i32* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%23 = load i32, i32* %1
%24 = load i32, i32* %2
%25 = call double** @zero_dmat(i32 %23, i32 %24)
%26 = call i64 (i32*, i8*, i32*, i32*, ...) @fscanf(i32* %9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32* %5, i32* %6, double* %7)
%27 = load i64, i64* @EOF
%28 = icmp eq i64 %26, %27
br i1 %28, label %55, label %29
29: ; preds = %15, %42
%30 = phi i32 [ %51, %42 ], [ 0, %15 ]
%31 = load i32, i32* %5
%32 = load i32, i32* %1
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %38
34: ; preds = %29
%35 = load i32, i32* %6
%36 = load i32, i32* %2
%37 = icmp slt i32 %35, %36
br i1 %37, label %42, label %38
38: ; preds = %34, %29
%39 = load i32, i32* @stderr
%40 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([133 x i8], [133 x i8]* @.str.2, i64 0, i64 0), i32 23, i8* %0)
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %34
%43 = load double, double* %7
%44 = add nsw i32 %31, -1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double*, double** %25, i64 %45
%47 = load double*, double** %46
%48 = add nsw i32 %35, -1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %47, i64 %49
store double %43, double* %50
%51 = add nuw nsw i32 %30, 1
%52 = call i64 (i32*, i8*, i32*, i32*, ...) @fscanf(i32* %9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32* %5, i32* %6, double* %7)
%53 = load i64, i64* @EOF
%54 = icmp eq i64 %52, %53
br i1 %54, label %55, label %29
55: ; preds = %42, %15
%56 = phi i32 [ 0, %15 ], [ %51, %42 ]
%57 = load i32, i32* %3
%58 = icmp eq i32 %56, %57
br i1 %58, label %62, label %59
59: ; preds = %55
%60 = load i32, i32* @stdout
%61 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([133 x i8], [133 x i8]* @.str.2, i64 0, i64 0), i32 28)
br label %62
62: ; preds = %59, %55
ret double** %25
}