#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, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *, char *);
scalar_t__ malloc(int);
double **getData(char *path, int rowNum, int colNum) {
  FILE *dataFile = fopen(path, "r");
  char head[10000];
  fgets(head, 10000, dataFile);
  double **data = (double **)malloc(sizeof(double *) * rowNum);
  int rowIndex, colIndex;
  char deliminator;
  int temp;
  for (rowIndex = 0; rowIndex < rowNum; rowIndex++) {
    data[rowIndex] = (double *)malloc(sizeof(double) * colNum);
    for (colIndex = 0; colIndex < colNum; colIndex++) {
      fscanf(dataFile, "%d%c", &temp, &deliminator);
      data[rowIndex][colIndex] = temp;
    }
  }
  fclose(dataFile);
  return data;
}


x86 assembly (clang, -O0):
<getData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2750,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    -0x2730(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x2710,%esi
call   1050 <fgets@plt>
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x2738(%rbp)
movl   $0x0,-0x273c(%rbp)
mov    -0x273c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    126b <getData+0x11b>
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%rdx
mov    -0x2738(%rbp),%rax
movslq -0x273c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x2740(%rbp)
mov    -0x2740(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1252 <getData+0x102>
mov    -0x18(%rbp),%rdi
lea    0xdfd(%rip),%rsi
lea    -0x2748(%rbp),%rdx
lea    -0x2741(%rbp),%rcx
call   1040 <fscanf@plt>
cvtsi2sdl -0x2748(%rbp),%xmm0
ff
mov    -0x2738(%rbp),%rax
movslq -0x273c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x2740(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2740(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2740(%rbp)
jmp    11eb <getData+0x9b>
jmp    1257 <getData+0x107>
mov    -0x273c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x273c(%rbp)
jmp    11ae <getData+0x5e>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x2738(%rbp),%rax
add    $0x2750,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getData>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2758,%rsp
mov    %rdx,0x18(%rsp)
mov    %esi,%ebp
lea    0xe91(%rip),%rsi
call   1070 <fopen@plt>
lea    0x40(%rsp),%rdi
mov    $0x2710,%esi
mov    %rax,0x20(%rsp)
mov    %rax,%rdx
call   1050 <fgets@plt>
lea    0x0(,%rbp,8),%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
test   %ebp,%ebp
jle    125e <getData+0x10e>
mov    0x18(%rsp),%rax
lea    0x0(,%rax,8),%ecx
mov    %ecx,0x10(%rsp)
mov    %ebp,%ecx
mov    %rcx,0x38(%rsp)
mov    %eax,%eax
mov    %rax,0x30(%rsp)
xor    %edx,%edx
mov    0x30(%rsp),%r12
jmp    11e2 <getData+0x92>
nopl   0x0(%rax)
add    $0x1,%rdx
cmp    0x38(%rsp),%rdx
mov    %r14,%rbx
je     125e <getData+0x10e>
mov    %rdx,0x28(%rsp)
mov    0x10(%rsp),%edi
call   1060 <malloc@plt>
mov    0x28(%rsp),%rdx
mov    %rax,(%rbx,%rdx,8)
cmpl   $0x0,0x18(%rsp)
lea    0xdfd(%rip),%rsi
lea    0x14(%rsp),%r15
mov    %rbx,%r14
mov    0x20(%rsp),%rdi
lea    0xf(%rsp),%rcx
jle    11d0 <getData+0x80>
mov    %r15,%rbx
xor    %ebp,%ebp
xchg   %ax,%ax
mov    %rsi,%r15
mov    %rbx,%rdx
mov    %rdi,%r13
call   1040 <fscanf@plt>
mov    0x28(%rsp),%rdx
mov    %r15,%rsi
xorps  %xmm0,%xmm0
cvtsi2sdl 0x14(%rsp),%xmm0
mov    (%r14,%rdx,8),%rax
movsd  %xmm0,(%rax,%rbp,8)
mov    %r13,%rdi
lea    0xf(%rsp),%rcx
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1220 <getData+0xd0>
jmp    11d0 <getData+0x80>
mov    0x20(%rsp),%rdi
call   1030 <fclose@plt>
mov    %rbx,%rax
add    $0x2758,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [5 x i8] c"%d%c\00"
define double** @getData(i8* nocapture %0, i32 %1, i32 %2) {
%4 = alloca [10000 x i8]
%5 = alloca i8
%6 = alloca i32
%7 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 0
%9 = call i32 @fgets(i8* %8, i32 10000, i32* %7)
%10 = shl i32 %1, 3
%11 = call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to double**
%13 = bitcast i32* %6 to i8*
%14 = icmp sgt i32 %1, 0
br i1 %14, label %15, label %37
15: ; preds = %3
%16 = shl i32 %2, 3
%17 = icmp sgt i32 %2, 0
%18 = zext i32 %1 to i64
%19 = zext i32 %2 to i64
br label %20
20: ; preds = %15, %34
%21 = phi i64 [ 0, %15 ], [ %35, %34 ]
%22 = call i64 @malloc(i32 %16)
%23 = inttoptr i64 %22 to double*
%24 = getelementptr inbounds double*, double** %12, i64 %21
store double* %23, double** %24
br i1 %17, label %25, label %34
25: ; preds = %20, %25
%26 = phi i64 [ %32, %25 ], [ 0, %20 ]
%27 = call i32 @fscanf(i32* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %6, i8* %5)
%28 = load i32, i32* %6
%29 = sitofp i32 %28 to double
%30 = load double*, double** %24
%31 = getelementptr inbounds double, double* %30, i64 %26
store double %29, double* %31
%32 = add nuw nsw i64 %26, 1
%33 = icmp eq i64 %32, %19
br i1 %33, label %34, label %25
34: ; preds = %25, %20
%35 = add nuw nsw i64 %21, 1
%36 = icmp eq i64 %35, %18
br i1 %36, label %37, label %20
37: ; preds = %34, %3
%38 = call i32 @fclose(i32* %7)
ret double** %12
}