#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 */
scalar_t__ atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *);
char *strtok(char *, char *);
void loadAdjacencyMatrix(char *inputFile, double **matrix) {
  char row[15000];
  FILE *stream;
  int i = 0, j = 0;
  char *element;
  stream = fopen(inputFile, "r");
  if (stream == NULL) {
    printf("File open error\n");
    exit(1);
  }
  while (!feof(stream)) {
    if (fgets(row, 15000, stream) == NULL)
      break;
    j = 0;
    element = strtok(row, " ");
    matrix[i][j++] = (double)atoi(element);
    while (element = strtok(NULL, " ")) {
      matrix[i][j++] = (double)atoi(element);
    }
    i++;
  }
  fclose(stream);
}


x86 assembly (clang, -O0):
<loadAdjacencyMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3ad0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x3abc(%rbp)
movl   $0x0,-0x3ac0(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x3ab8(%rbp)
cmpq   $0x0,-0x3ab8(%rbp)
jne    11e2 <loadAdjacencyMatrix+0x62>
lea    0xe2f(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
jmp    11e7 <loadAdjacencyMatrix+0x67>
mov    -0x3ab8(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1208 <loadAdjacencyMatrix+0x88>
jmp    12ff <loadAdjacencyMatrix+0x17f>
lea    -0x3ab0(%rbp),%rdi
mov    -0x3ab8(%rbp),%rdx
mov    $0x3a98,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
jne    122f <loadAdjacencyMatrix+0xaf>
jmp    12ff <loadAdjacencyMatrix+0x17f>
movl   $0x0,-0x3ac0(%rbp)
lea    -0x3ab0(%rbp),%rdi
lea    0xdcc(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x3ac8(%rbp)
mov    -0x3ac8(%rbp),%rdi
call   1090 <atoi@plt>
cvtsi2sd %rax,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x3abc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x3ac0(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x3ac0(%rbp)
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd7c(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x3ac8(%rbp)
cmp    $0x0,%rax
je     12eb <loadAdjacencyMatrix+0x16b>
mov    -0x3ac8(%rbp),%rdi
call   1090 <atoi@plt>
cvtsi2sd %rax,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x3abc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x3ac0(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x3ac0(%rbp)
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    128c <loadAdjacencyMatrix+0x10c>
mov    -0x3abc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3abc(%rbp)
jmp    11e7 <loadAdjacencyMatrix+0x67>
mov    -0x3ab8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x3ad0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loadAdjacencyMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3a98,%rsp
mov    %rsi,%r13
lea    0xe75(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1272 <loadAdjacencyMatrix+0xf2>
mov    %rax,%r14
mov    %rax,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     11d2 <loadAdjacencyMatrix+0x52>
mov    %r14,%rdi
call   1040 <fclose@plt>
add    $0x3a98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
mov    %rsp,%r15
lea    0xe22(%rip),%r12
jmp    11f0 <loadAdjacencyMatrix+0x70>
add    $0x1,%rbx
mov    %r14,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    11b8 <loadAdjacencyMatrix+0x38>
mov    %r15,%rdi
mov    $0x3a98,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11b8 <loadAdjacencyMatrix+0x38>
mov    %r15,%rdi
mov    %r12,%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
call   1090 <atoi@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mov    0x0(%r13,%rbx,8),%rax
movsd  %xmm0,(%rax)
xor    %edi,%edi
mov    %r12,%rsi
call   1080 <strtok@plt>
test   %rax,%rax
je     11e0 <loadAdjacencyMatrix+0x60>
mov    $0x8,%ebp
nopl   (%rax)
mov    %rax,%rdi
call   1090 <atoi@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mov    0x0(%r13,%rbx,8),%rax
movsd  %xmm0,(%rax,%rbp,1)
xor    %edi,%edi
mov    %r12,%rsi
call   1080 <strtok@plt>
add    $0x8,%rbp
test   %rax,%rax
jne    1240 <loadAdjacencyMatrix+0xc0>
jmp    11e0 <loadAdjacencyMatrix+0x60>
lea    0xd89(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [17 x i8] c"File open error\0A\00"
@.str.2 = [2 x i8] c" \00"
define void @loadAdjacencyMatrix(i8* %0, double** %1) {
%3 = alloca i8*
%4 = alloca double**
%5 = alloca [15000 x i8]
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i8* %0, i8** %3
store double** %1, double*** %4
store i32 0, i32* %7
store i32 0, i32* %8
%10 = load i8*, i8** %3
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %6
%12 = load i32*, i32** %6
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
br label %18
18: ; preds = %60, %17
%19 = load i32*, i32** %6
%20 = call i32 @feof(i32* %19)
%21 = icmp ne i32 %20, 0
%22 = xor i1 %21, true
br i1 %22, label %23, label %63
23: ; preds = %18
%24 = getelementptr inbounds [15000 x i8], [15000 x i8]* %5, i64 0, i64 0
%25 = load i32*, i32** %6
%26 = call i32* @fgets(i8* %24, i32 15000, i32* %25)
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %29
28: ; preds = %23
br label %63
29: ; preds = %23
store i32 0, i32* %8
%30 = getelementptr inbounds [15000 x i8], [15000 x i8]* %5, i64 0, i64 0
%31 = call i8* @strtok(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %31, i8** %9
%32 = load i8*, i8** %9
%33 = call i64 @atoi(i8* %32)
%34 = sitofp i64 %33 to double
%35 = load double**, double*** %4
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double*, double** %35, i64 %37
%39 = load double*, double** %38
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
%42 = sext i32 %40 to i64
%43 = getelementptr inbounds double, double* %39, i64 %42
store double %34, double* %43
br label %44
44: ; preds = %47, %29
%45 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %45, i8** %9
%46 = icmp ne i8* %45, null
br i1 %46, label %47, label %60
47: ; preds = %44
%48 = load i8*, i8** %9
%49 = call i64 @atoi(i8* %48)
%50 = sitofp i64 %49 to double
%51 = load double**, double*** %4
%52 = load i32, i32* %7
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double*, double** %51, i64 %53
%55 = load double*, double** %54
%56 = load i32, i32* %8
%57 = add nsw i32 %56, 1
store i32 %57, i32* %8
%58 = sext i32 %56 to i64
%59 = getelementptr inbounds double, double* %55, i64 %58
store double %50, double* %59
br label %44
60: ; preds = %44
%61 = load i32, i32* %7
%62 = add nsw i32 %61, 1
store i32 %62, i32* %7
br label %18
63: ; preds = %28, %18
%64 = load i32*, i32** %6
%65 = call i32 @fclose(i32* %64)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c" \00"
@str = [16 x i8] c"File open error\00"
define void @loadAdjacencyMatrix(i8* nocapture %0, double** nocapture %1) {
%3 = alloca [15000 x i8]
%4 = getelementptr inbounds [15000 x i8], [15000 x i8]* %3, i64 0, i64 0
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = call i32 @feof(i32* %5)
%9 = icmp eq i32 %8, 0
br i1 %9, label %13, label %39
10: ; preds = %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %7, %35
%14 = phi i64 [ %36, %35 ], [ 0, %7 ]
%15 = call i32* @fgets(i8* %4, i32 15000, i32* %5)
%16 = icmp eq i32* %15, null
br i1 %16, label %39, label %17
17: ; preds = %13
%18 = call i8* @strtok(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = call i64 @atoi(i8* %18)
%20 = sitofp i64 %19 to double
%21 = getelementptr inbounds double*, double** %1, i64 %14
%22 = load double*, double** %21
store double %20, double* %22
%23 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp eq i8* %23, null
br i1 %24, label %35, label %25
25: ; preds = %17, %25
%26 = phi i64 [ %31, %25 ], [ 1, %17 ]
%27 = phi i8* [ %33, %25 ], [ %23, %17 ]
%28 = call i64 @atoi(i8* %27)
%29 = sitofp i64 %28 to double
%30 = load double*, double** %21
%31 = add nuw i64 %26, 1
%32 = getelementptr inbounds double, double* %30, i64 %26
store double %29, double* %32
%33 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp eq i8* %33, null
br i1 %34, label %35, label %25
35: ; preds = %25, %17
%36 = add nuw i64 %14, 1
%37 = call i32 @feof(i32* %5)
%38 = icmp eq i32 %37, 0
br i1 %38, label %13, label %39
39: ; preds = %35, %13, %7
%40 = call i32 @fclose(i32* %5)
ret void
}