#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*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(int *, int, int, int /*<<< orphan*/ *);
void readInputData(char *file, int rows, int cols, int **image) {
  int row, col;
  FILE *fp;
  fp = fopen(file, "rb");
  if (fp == NULL) {
    return;
  }
  for (row = 0; row < rows; row++)
    fread(&image[row][0], sizeof(int) * cols, 1, fp);
  fclose(fp);
}


x86 assembly (clang, -O0):
<readInputData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeaf(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    116a <readInputData+0x3a>
jmp    11b8 <readInputData+0x88>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11af <readInputData+0x7f>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%esi
mov    -0x28(%rbp),%rcx
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1171 <readInputData+0x41>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readInputData>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %edx,%r12d
mov    %esi,%r15d
lea    0xeb5(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11a3 <readInputData+0x73>
mov    %rax,%r13
test   %r15d,%r15d
jle    118d <readInputData+0x5d>
shl    $0x2,%r12d
mov    %r15d,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rdi
mov    %r12d,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   1030 <fread@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1170 <readInputData+0x40>
mov    %r13,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fclose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
define void @readInputData(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*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32** %3, i32*** %8
%12 = load i8*, i8** %5
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %11
%14 = load i32*, i32** %11
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %17
16: ; preds = %4
br label %41
17: ; preds = %4
store i32 0, i32* %9
br label %18
18: ; preds = %35, %17
%19 = load i32, i32* %9
%20 = load i32, i32* %6
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %38
22: ; preds = %18
%23 = load i32**, i32*** %8
%24 = load i32, i32* %9
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32*, i32** %23, i64 %25
%27 = load i32*, i32** %26
%28 = getelementptr inbounds i32, i32* %27, i64 0
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = mul i64 4, %30
%32 = trunc i64 %31 to i32
%33 = load i32*, i32** %11
%34 = call i32 @fread(i32* %28, i32 %32, i32 1, i32* %33)
br label %35
35: ; preds = %22
%36 = load i32, i32* %9
%37 = add nsw i32 %36, 1
store i32 %37, i32* %9
br label %18
38: ; preds = %18
%39 = load i32*, i32** %11
%40 = call i32 @fclose(i32* %39)
br label %41
41: ; preds = %38, %16
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
define void @readInputData(i8* nocapture %0, i32 %1, i32 %2, i32** nocapture %3) {
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %21, label %7
7: ; preds = %4
%8 = icmp sgt i32 %1, 0
br i1 %8, label %9, label %19
9: ; preds = %7
%10 = shl i32 %2, 2
%11 = zext i32 %1 to i64
br label %12
12: ; preds = %9, %12
%13 = phi i64 [ 0, %9 ], [ %17, %12 ]
%14 = getelementptr inbounds i32*, i32** %3, i64 %13
%15 = load i32*, i32** %14
%16 = tail call i32 @fread(i32* %15, i32 %10, i32 1, i32* %5)
%17 = add nuw nsw i64 %13, 1
%18 = icmp eq i64 %17, %11
br i1 %18, label %19, label %12
19: ; preds = %12, %7
%20 = tail call i32 @fclose(i32* %5)
br label %21
21: ; preds = %4, %19
ret void
}