#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*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int strlen(char *);
int /*<<< orphan*/ terror(char *);
char **readWorkloadFile(char *nomfich, int *n) {
  FILE *fwork;
  char *cadena, tmp[3000];
  int i;
  char **table;
  *n = 0;
  fwork = fopen(nomfich, "rt");
  if (fwork == NULL)
    terror("opening Workload file");
  fgets(tmp, 3000, fwork);
  while (!feof(fwork)) {
    *n = *n + 1;
    fgets(tmp, 3000, fwork);
  }
  rewind(fwork);
  if ((table = (char **)malloc(*n * sizeof(char *))) == NULL)
    terror("Memory, ReadWorkloadfile");
  for (i = 0; i < *n; i++) {
    cadena = table[i] = (char *)malloc(3000 * sizeof(char));
    fgets(cadena, 3000, fwork);
    if (cadena[strlen(cadena) - 1] == '\n')
      cadena[strlen(cadena) - 1] = 0x00;
  }
  fclose(fwork);
  return table;
}


x86 assembly (clang, -O0):
<readWorkloadFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc00,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11c8 <readWorkloadFile+0x48>
lea    0xe40(%rip),%rdi
call   1090 <terror@plt>
lea    -0xbe0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0xbb8,%esi
call   1060 <fgets@plt>
mov    -0x18(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11fb <readWorkloadFile+0x7b>
jmp    1224 <readWorkloadFile+0xa4>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
lea    -0xbe0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0xbb8,%esi
call   1060 <fgets@plt>
jmp    11dd <readWorkloadFile+0x5d>
mov    -0x18(%rbp),%rdi
call   1050 <rewind@plt>
mov    -0x10(%rbp),%rax
movslq (%rax),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0xbf0(%rbp)
cmp    $0x0,%rax
jne    125c <readWorkloadFile+0xdc>
lea    0xdc2(%rip),%rdi
call   1090 <terror@plt>
movl   $0x0,-0xbe4(%rbp)
mov    -0xbe4(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    131a <readWorkloadFile+0x19a>
mov    $0xbb8,%edi
call   1080 <malloc@plt>
mov    -0xbf0(%rbp),%rcx
movslq -0xbe4(%rbp),%rdx
mov    %rax,(%rcx,%rdx,8)
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0xbb8,%esi
call   1060 <fgets@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0xbf8(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0xbf8(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    1301 <readWorkloadFile+0x181>
mov    -0x20(%rbp),%rax
mov    %rax,-0xc00(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0xc00(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1306 <readWorkloadFile+0x186>
mov    -0xbe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xbe4(%rbp)
jmp    1266 <readWorkloadFile+0xe6>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0xbf0(%rbp),%rax
add    $0xc00,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readWorkloadFile>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xbc0,%rsp
mov    %rsi,%r14
movl   $0x0,(%rsi)
lea    0xe60(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r12
test   %rax,%rax
jne    11b9 <readWorkloadFile+0x39>
lea    0xe4f(%rip),%rdi
call   1090 <terror@plt>
mov    %rsp,%rdi
mov    $0xbb8,%esi
mov    %r12,%rdx
call   1060 <fgets@plt>
mov    %r12,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    1200 <readWorkloadFile+0x80>
mov    %rsp,%rbx
nopl   0x0(%rax,%rax,1)
addl   $0x1,(%r14)
mov    %rbx,%rdi
mov    $0xbb8,%esi
mov    %r12,%rdx
call   1060 <fgets@plt>
mov    %r12,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     11e0 <readWorkloadFile+0x60>
mov    %r12,%rdi
call   1050 <rewind@plt>
mov    (%r14),%edi
shl    $0x3,%edi
call   1080 <malloc@plt>
mov    %rax,%r15
test   %rax,%rax
je     1223 <readWorkloadFile+0xa3>
cmpl   $0x0,(%r14)
jg     1235 <readWorkloadFile+0xb5>
jmp    128f <readWorkloadFile+0x10f>
lea    0xdef(%rip),%rdi
call   1090 <terror@plt>
cmpl   $0x0,(%r14)
jle    128f <readWorkloadFile+0x10f>
xor    %r13d,%r13d
jmp    124c <readWorkloadFile+0xcc>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r13
movslq (%r14),%rax
cmp    %rax,%r13
jge    128f <readWorkloadFile+0x10f>
mov    $0xbb8,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    %rax,(%r15,%r13,8)
mov    %rax,%rdi
mov    $0xbb8,%esi
mov    %r12,%rdx
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    1240 <readWorkloadFile+0xc0>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
jmp    1240 <readWorkloadFile+0xc0>
mov    %r12,%rdi
call   1030 <fclose@plt>
mov    %r15,%rax
add    $0xbc0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"rt\00"
@.str.1 = [22 x i8] c"opening Workload file\00"
@.str.2 = [25 x i8] c"Memory, ReadWorkloadfile\00"
define i8** @readWorkloadFile(i8* nocapture %0, i32* nocapture %1) {
%3 = alloca [3000 x i8]
%4 = getelementptr inbounds [3000 x i8], [3000 x i8]* %3, i64 0, i64 0
store i32 0, i32* %1
%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 %7, label %9
7: ; preds = %2
%8 = tail call i32 @terror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %7, %2
%10 = call i32 @fgets(i8* %4, i32 3000, i32* %5)
%11 = call i32 @feof(i32* %5)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %9, %13
%14 = load i32, i32* %1
%15 = add nsw i32 %14, 1
store i32 %15, i32* %1
%16 = call i32 @fgets(i8* %4, i32 3000, i32* %5)
%17 = call i32 @feof(i32* %5)
%18 = icmp eq i32 %17, 0
br i1 %18, label %13, label %19
19: ; preds = %13, %9
%20 = call i32 @rewind(i32* %5)
%21 = load i32, i32* %1
%22 = shl i32 %21, 3
%23 = call i64 @malloc(i32 %22)
%24 = inttoptr i64 %23 to i8**
%25 = icmp eq i64 %23, 0
br i1 %25, label %26, label %28
26: ; preds = %19
%27 = call i32 @terror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %28
28: ; preds = %26, %19
%29 = load i32, i32* %1
%30 = icmp sgt i32 %29, 0
br i1 %30, label %31, label %53
31: ; preds = %28, %48
%32 = phi i64 [ %49, %48 ], [ 0, %28 ]
%33 = call i64 @malloc(i32 3000)
%34 = inttoptr i64 %33 to i8*
%35 = getelementptr inbounds i8*, i8** %24, i64 %32
store i8* %34, i8** %35
%36 = call i32 @fgets(i8* %34, i32 3000, i32* %5)
%37 = call i32 @strlen(i8* %34)
%38 = add nsw i32 %37, -1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %34, i64 %39
%41 = load i8, i8* %40
%42 = icmp eq i8 %41, 10
br i1 %42, label %43, label %48
43: ; preds = %31
%44 = call i32 @strlen(i8* %34)
%45 = add nsw i32 %44, -1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %34, i64 %46
store i8 0, i8* %47
br label %48
48: ; preds = %31, %43
%49 = add nuw nsw i64 %32, 1
%50 = load i32, i32* %1
%51 = sext i32 %50 to i64
%52 = icmp slt i64 %49, %51
br i1 %52, label %31, label %53
53: ; preds = %48, %28
%54 = call i32 @fclose(i32* %5)
ret i8** %24
}