#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*/ EXIT_FAILURE;
int **allocate_matrix(int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ read_file(int /*<<< orphan*/ *, int *, int *);
int main(int argc, char **argv) {
  int rowMaxIndexA, columnMaxIndexA;
  int rowMaxIndexB, columnMaxIndexB;
  int **matA;
  int **matB;
  int i, j, idx;
  char part[1024];
  char *token;
  FILE *fpA, *fpB;
  fpA = fopen("filename.csv", "r");
  if (fpA == NULL) {
    perror("Error while opening the file.\n");
    exit(EXIT_FAILURE);
  }
  read_file(fpA, &rowMaxIndexA, &columnMaxIndexA);
  matA = allocate_matrix(rowMaxIndexA, columnMaxIndexA, fpA);
  fpB = fopen("filename2.csv", "r");
  if (fpB == NULL) {
    perror("Error while opening the file.\n");
    exit(EXIT_FAILURE);
  }
  read_file(fpB, &rowMaxIndexB, &columnMaxIndexB);
  matB = allocate_matrix(rowMaxIndexB, columnMaxIndexB, fpB);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe97(%rip),%rdi
lea    0xe9d(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x450(%rbp)
cmpq   $0x0,-0x450(%rbp)
jne    11a4 <main+0x54>
lea    0xe7e(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x450(%rbp),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1030 <read_file@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x450(%rbp),%rdx
call   1040 <allocate_matrix@plt>
mov    %rax,-0x28(%rbp)
lea    0xe59(%rip),%rdi
lea    0xe31(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x458(%rbp)
cmpq   $0x0,-0x458(%rbp)
jne    1210 <main+0xc0>
lea    0xe12(%rip),%rdi
call   1060 <perror@plt>
mov    0x2dd7(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x458(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1030 <read_file@plt>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x458(%rbp),%rdx
call   1040 <allocate_matrix@plt>
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
add    $0x460,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xea4(%rip),%rdi
lea    0xeaa(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11d4 <main+0x84>
mov    %rax,%rbx
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
call   1030 <read_file@plt>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
mov    %rbx,%rdx
call   1040 <allocate_matrix@plt>
lea    0xe95(%rip),%rdi
lea    0xe6d(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11d4 <main+0x84>
mov    %rax,%rbx
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
mov    %rax,%rdi
call   1030 <read_file@plt>
mov    0x4(%rsp),%edi
mov    (%rsp),%esi
mov    %rbx,%rdx
call   1040 <allocate_matrix@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe34(%rip),%rdi
call   1060 <perror@plt>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"filename.csv\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [31 x i8] c"Error while opening the file.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [14 x i8] c"filename2.csv\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32**
%10 = alloca i32**
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca [1024 x i8]
%15 = alloca i8*
%16 = alloca i32*
%17 = alloca i32*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%18 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %16
%19 = load i32*, i32** %16
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %25
21: ; preds = %2
%22 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %2
%26 = load i32*, i32** %16
%27 = call i32 @read_file(i32* %26, i32* %5, i32* %6)
%28 = load i32, i32* %5
%29 = load i32, i32* %6
%30 = load i32*, i32** %16
%31 = call i32** @allocate_matrix(i32 %28, i32 %29, i32* %30)
store i32** %31, i32*** %9
%32 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %32, i32** %17
%33 = load i32*, i32** %17
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %39
35: ; preds = %25
%36 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%37 = load i32, i32* @EXIT_FAILURE
%38 = call i32 @exit(i32 %37)
unreachable
39: ; preds = %25
%40 = load i32*, i32** %17
%41 = call i32 @read_file(i32* %40, i32* %7, i32* %8)
%42 = load i32, i32* %7
%43 = load i32, i32* %8
%44 = load i32*, i32** %17
%45 = call i32** @allocate_matrix(i32 %42, i32 %43, i32* %44)
store i32** %45, i32*** %10
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"filename.csv\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [31 x i8] c"Error while opening the file.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [14 x i8] c"filename2.csv\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = tail call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = tail call i32 @exit(i32 %15)
unreachable
17: ; preds = %2
%18 = call i32 @read_file(i32* %11, i32* %3, i32* %4)
%19 = load i32, i32* %3
%20 = load i32, i32* %4
%21 = call i32** @allocate_matrix(i32 %19, i32 %20, i32* %11)
%22 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %28
24: ; preds = %17
%25 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %17
%29 = call i32 @read_file(i32* %22, i32* %5, i32* %6)
%30 = load i32, i32* %5
%31 = load i32, i32* %6
%32 = call i32** @allocate_matrix(i32 %30, i32 %31, i32* %22)
ret i32 0
}