#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 */
double **CreateMat(int, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *);
int Lab3LoadInput(double ***A, int *size) {
  FILE *ip;
  int i, j;
  if ((ip = fopen("data_input", "r")) == NULL) {
    printf("error opening the input data.\n");
    return 1;
  }
  fscanf(ip, "%d\n\n", size);
  (*A) = CreateMat(*size, (*size) + 1);
  for (i = 0; i < *size; ++i) {
    for (j = 0; j < *size; ++j)
      fscanf(ip, "%lf\t", &(*A)[i][j]);
    fscanf(ip, "\n");
  }
  fscanf(ip, "\n");
  for (i = 0; i < *size; ++i)
    fscanf(ip, "%lf\n", &(*A)[i][(*size - 1) + 1]);
  fclose(ip);
  return 0;
}


x86 assembly (clang, -O0):
<Lab3LoadInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    0xe99(%rip),%rdi
lea    0xe9d(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1199 <Lab3LoadInput+0x49>
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12cf <Lab3LoadInput+0x17f>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe84(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
add    $0x1,%esi
call   1070 <CreateMat@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jge    1253 <Lab3LoadInput+0x103>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jge    1233 <Lab3LoadInput+0xe3>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
movslq -0x28(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
lea    0xe13(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11ea <Lab3LoadInput+0x9a>
mov    -0x20(%rbp),%rdi
lea    0xdf1(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11d4 <Lab3LoadInput+0x84>
mov    -0x20(%rbp),%rdi
lea    0xdd1(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jge    12bf <Lab3LoadInput+0x16f>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
sub    $0x1,%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
lea    0xd8c(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    126c <Lab3LoadInput+0x11c>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Lab3LoadInput>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%rbp
lea    0xe95(%rip),%rdi
lea    0xe99(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     12a1 <Lab3LoadInput+0x151>
lea    0xe86(%rip),%rsi
mov    %rax,(%rsp)
mov    %rax,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    (%rbx),%edi
lea    0x1(%rdi),%esi
call   1070 <CreateMat@plt>
mov    %rbp,0x8(%rsp)
mov    %rax,0x0(%rbp)
mov    (%rbx),%eax
test   %eax,%eax
jle    123e <Lab3LoadInput+0xee>
xor    %ebp,%ebp
mov    %rbx,0x10(%rsp)
mov    0x8(%rsp),%r15
mov    (%rsp),%r14
jmp    11f2 <Lab3LoadInput+0xa2>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
lea    0xe36(%rip),%rsi
xor    %eax,%eax
call   1050 <fscanf@plt>
add    $0x1,%rbp
mov    0x10(%rsp),%rbx
movslq (%rbx),%rax
cmp    %rax,%rbp
jge    123e <Lab3LoadInput+0xee>
test   %eax,%eax
lea    0xe17(%rip),%rbx
jle    11d0 <Lab3LoadInput+0x80>
xor    %r13d,%r13d
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r15),%rax
mov    (%rax,%rbp,8),%rdx
add    %r13,%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <fscanf@plt>
add    $0x1,%r12
mov    0x10(%rsp),%rax
movslq (%rax),%rax
add    $0x8,%r13
cmp    %rax,%r12
jl     1210 <Lab3LoadInput+0xc0>
jmp    11d0 <Lab3LoadInput+0x80>
lea    0xdcb(%rip),%rsi
xor    %r12d,%r12d
mov    (%rsp),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    (%rbx),%eax
test   %eax,%eax
mov    0x8(%rsp),%r14
jle    1297 <Lab3LoadInput+0x147>
lea    0xdaf(%rip),%r13
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    (%r14),%rcx
movslq %eax,%rdx
shl    $0x3,%rdx
add    (%rcx,%rbp,8),%rdx
mov    %r15,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <fscanf@plt>
add    $0x1,%rbp
movslq (%rbx),%rax
cmp    %rax,%rbp
jl     1270 <Lab3LoadInput+0x120>
mov    %r15,%rdi
call   1040 <fclose@plt>
jmp    12b3 <Lab3LoadInput+0x163>
lea    0xd74(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r12d
mov    %r12d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"data_input\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [31 x i8] c"error opening the input data.\0A\00"
@.str.3 = [5 x i8] c"%d\0A\0A\00"
@.str.4 = [5 x i8] c"%lf\09\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [5 x i8] c"%lf\0A\00"
define i32 @Lab3LoadInput(double*** %0, i32* %1) {
%3 = alloca i32
%4 = alloca double***
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store double*** %0, double**** %4
store i32* %1, i32** %5
%9 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %6
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %85
13: ; preds = %2
%14 = load i32*, i32** %6
%15 = load i32*, i32** %5
%16 = call i32 (i32*, i8*, ...) @fscanf(i32* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32* %15)
%17 = load i32*, i32** %5
%18 = load i32, i32* %17
%19 = load i32*, i32** %5
%20 = load i32, i32* %19
%21 = add nsw i32 %20, 1
%22 = call double** @CreateMat(i32 %18, i32 %21)
%23 = load double***, double**** %4
store double** %22, double*** %23
store i32 0, i32* %7
br label %24
24: ; preds = %53, %13
%25 = load i32, i32* %7
%26 = load i32*, i32** %5
%27 = load i32, i32* %26
%28 = icmp slt i32 %25, %27
br i1 %28, label %29, label %56
29: ; preds = %24
store i32 0, i32* %8
br label %30
30: ; preds = %47, %29
%31 = load i32, i32* %8
%32 = load i32*, i32** %5
%33 = load i32, i32* %32
%34 = icmp slt i32 %31, %33
br i1 %34, label %35, label %50
35: ; preds = %30
%36 = load i32*, i32** %6
%37 = load double***, double**** %4
%38 = load double**, double*** %37
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double*, double** %38, i64 %40
%42 = load double*, double** %41
%43 = load i32, i32* %8
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %42, i64 %44
%46 = call i32 (i32*, i8*, ...) @fscanf(i32* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), double* %45)
br label %47
47: ; preds = %35
%48 = load i32, i32* %8
%49 = add nsw i32 %48, 1
store i32 %49, i32* %8
br label %30
50: ; preds = %30
%51 = load i32*, i32** %6
%52 = call i32 (i32*, i8*, ...) @fscanf(i32* %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %53
53: ; preds = %50
%54 = load i32, i32* %7
%55 = add nsw i32 %54, 1
store i32 %55, i32* %7
br label %24
56: ; preds = %24
%57 = load i32*, i32** %6
%58 = call i32 (i32*, i8*, ...) @fscanf(i32* %57, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %7
br label %59
59: ; preds = %79, %56
%60 = load i32, i32* %7
%61 = load i32*, i32** %5
%62 = load i32, i32* %61
%63 = icmp slt i32 %60, %62
br i1 %63, label %64, label %82
64: ; preds = %59
%65 = load i32*, i32** %6
%66 = load double***, double**** %4
%67 = load double**, double*** %66
%68 = load i32, i32* %7
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds double*, double** %67, i64 %69
%71 = load double*, double** %70
%72 = load i32*, i32** %5
%73 = load i32, i32* %72
%74 = sub nsw i32 %73, 1
%75 = add nsw i32 %74, 1
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds double, double* %71, i64 %76
%78 = call i32 (i32*, i8*, ...) @fscanf(i32* %65, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), double* %77)
br label %79
79: ; preds = %64
%80 = load i32, i32* %7
%81 = add nsw i32 %80, 1
store i32 %81, i32* %7
br label %59
82: ; preds = %59
%83 = load i32*, i32** %6
%84 = call i32 @fclose(i32* %83)
store i32 0, i32* %3
br label %85
85: ; preds = %82, %11
%86 = load i32, i32* %3
ret i32 %86
}

LLVM IR (-O2):
@.str = [11 x i8] c"data_input\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [5 x i8] c"%d\0A\0A\00"
@.str.4 = [5 x i8] c"%lf\09\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [5 x i8] c"%lf\0A\00"
@str = [30 x i8] c"error opening the input data.\00"
define i32 @Lab3LoadInput(double*** nocapture %0, i32* %1) {
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %54
7: ; preds = %2
%8 = tail call i32 (i32*, i8*, ...) @fscanf(i32* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = add nsw i32 %9, 1
%11 = tail call double** @CreateMat(i32 %9, i32 %10)
store double** %11, double*** %0
%12 = load i32, i32* %1
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %35
14: ; preds = %7, %29
%15 = phi i32 [ %32, %29 ], [ %12, %7 ]
%16 = phi i64 [ %31, %29 ], [ 0, %7 ]
%17 = icmp sgt i32 %15, 0
br i1 %17, label %18, label %29
18: ; preds = %14, %18
%19 = phi i64 [ %25, %18 ], [ 0, %14 ]
%20 = load double**, double*** %0
%21 = getelementptr inbounds double*, double** %20, i64 %16
%22 = load double*, double** %21
%23 = getelementptr inbounds double, double* %22, i64 %19
%24 = tail call i32 (i32*, i8*, ...) @fscanf(i32* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), double* %23)
%25 = add nuw nsw i64 %19, 1
%26 = load i32, i32* %1
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %25, %27
br i1 %28, label %18, label %29
29: ; preds = %18, %14
%30 = tail call i32 (i32*, i8*, ...) @fscanf(i32* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%31 = add nuw nsw i64 %16, 1
%32 = load i32, i32* %1
%33 = sext i32 %32 to i64
%34 = icmp slt i64 %31, %33
br i1 %34, label %14, label %35
35: ; preds = %29, %7
%36 = tail call i32 (i32*, i8*, ...) @fscanf(i32* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%37 = load i32, i32* %1
%38 = icmp sgt i32 %37, 0
br i1 %38, label %39, label %52
39: ; preds = %35, %39
%40 = phi i64 [ %48, %39 ], [ 0, %35 ]
%41 = phi i32 [ %49, %39 ], [ %37, %35 ]
%42 = load double**, double*** %0
%43 = getelementptr inbounds double*, double** %42, i64 %40
%44 = load double*, double** %43
%45 = sext i32 %41 to i64
%46 = getelementptr inbounds double, double* %44, i64 %45
%47 = tail call i32 (i32*, i8*, ...) @fscanf(i32* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), double* %46)
%48 = add nuw nsw i64 %40, 1
%49 = load i32, i32* %1
%50 = sext i32 %49 to i64
%51 = icmp slt i64 %48, %50
br i1 %51, label %39, label %52
52: ; preds = %39, %35
%53 = tail call i32 @fclose(i32* %3)
br label %54
54: ; preds = %52, %5
%55 = phi i32 [ 1, %5 ], [ 0, %52 ]
ret i32 %55
}