#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 */
double atof(char *);
scalar_t__ calloc(size_t, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ printf(char *);
double *readMicroarray(const char *nmicrf, size_t ngenes, int nexp) {
  printf("Alocating the microarray\n");
  double *X = (double *)calloc(ngenes * nexp, sizeof(double));
  FILE *mif;
  mif = fopen(nmicrf, "r");
  int i, j;
  for (i = 0; i < ngenes; i++) {
    for (j = 0; j < nexp; j++) {
      double t;
      char tt[80];
      fscanf(mif, "%s", tt);
      t = atof(tt);
      X[i * nexp + j] = t;
    }
  }
  fclose(mif);
  printf("Done alocating the microarray\n");
  return X;
}


x86 assembly (clang, -O0):
<readMicroarray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    0xe83(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
imul   %rax,%rdi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe73(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movslq -0x2c(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    123c <readMicroarray+0xdc>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1229 <readMicroarray+0xc9>
mov    -0x28(%rbp),%rdi
lea    -0x90(%rbp),%rdx
lea    0xe32(%rip),%rsi
call   1060 <fscanf@plt>
lea    -0x90(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
imul   -0x14(%rbp),%ecx
add    -0x30(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11cc <readMicroarray+0x6c>
jmp    122e <readMicroarray+0xce>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11b7 <readMicroarray+0x57>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xdd3(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readMicroarray>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xe85(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,0xc(%rsp)
movslq %ebp,%rdi
mov    %rdi,%r15
imul   %rbx,%rdi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,0x10(%rsp)
lea    0xe57(%rip),%rsi
mov    %r14,%rdi
call   1080 <fopen@plt>
mov    %rax,%rbp
mov    %rbx,0x20(%rsp)
test   %rbx,%rbx
je     1247 <readMicroarray+0xe7>
mov    %r15,%rax
mov    %eax,%r15d
shl    $0x3,%rax
mov    %rax,0x18(%rsp)
xor    %eax,%eax
lea    0xe28(%rip),%r13
lea    0x30(%rsp),%rbx
mov    0x10(%rsp),%r14
jmp    1205 <readMicroarray+0xa5>
cs nopw 0x0(%rax,%rax,1)
mov    0x28(%rsp),%rax
add    $0x1,%rax
add    0x18(%rsp),%r14
cmp    0x20(%rsp),%rax
je     1247 <readMicroarray+0xe7>
mov    %rax,0x28(%rsp)
cmpl   $0x0,0xc(%rsp)
jle    11f0 <readMicroarray+0x90>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1060 <fscanf@plt>
mov    %rbx,%rdi
call   1040 <atof@plt>
movsd  %xmm0,(%r14,%r12,8)
add    $0x1,%r12
cmp    %r12,%r15
jne    1220 <readMicroarray+0xc0>
jmp    11f0 <readMicroarray+0x90>
mov    %rbp,%rdi
call   1050 <fclose@plt>
lea    0xdc8(%rip),%rdi
call   1030 <puts@plt>
mov    0x10(%rsp),%rax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Alocating the microarray\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [31 x i8] c"Done alocating the microarray\0A\00"
define double* @readMicroarray(i8* %0, i64 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
%7 = alloca double*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca [80 x i8]
store i8* %0, i8** %4
store i64 %1, i64* %5
store i32 %2, i32* %6
%13 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%14 = load i64, i64* %5
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = mul i64 %14, %16
%18 = call i64 @calloc(i64 %17, i32 8)
%19 = inttoptr i64 %18 to double*
store double* %19, double** %7
%20 = load i8*, i8** %4
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %21, i32** %8
store i32 0, i32* %9
br label %22
22: ; preds = %51, %3
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = load i64, i64* %5
%26 = icmp ult i64 %24, %25
br i1 %26, label %27, label %54
27: ; preds = %22
store i32 0, i32* %10
br label %28
28: ; preds = %47, %27
%29 = load i32, i32* %10
%30 = load i32, i32* %6
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %50
32: ; preds = %28
%33 = load i32*, i32** %8
%34 = getelementptr inbounds [80 x i8], [80 x i8]* %12, i64 0, i64 0
%35 = call i32 @fscanf(i32* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %34)
%36 = getelementptr inbounds [80 x i8], [80 x i8]* %12, i64 0, i64 0
%37 = call double @atof(i8* %36)
store double %37, double* %11
%38 = load double, double* %11
%39 = load double*, double** %7
%40 = load i32, i32* %9
%41 = load i32, i32* %6
%42 = mul nsw i32 %40, %41
%43 = load i32, i32* %10
%44 = add nsw i32 %42, %43
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double, double* %39, i64 %45
store double %38, double* %46
br label %47
47: ; preds = %32
%48 = load i32, i32* %10
%49 = add nsw i32 %48, 1
store i32 %49, i32* %10
br label %28
50: ; preds = %28
br label %51
51: ; preds = %50
%52 = load i32, i32* %9
%53 = add nsw i32 %52, 1
store i32 %53, i32* %9
br label %22
54: ; preds = %22
%55 = load i32*, i32** %8
%56 = call i32 @fclose(i32* %55)
%57 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%58 = load double*, double** %7
ret double* %58
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
@str = [25 x i8] c"Alocating the microarray\00"
@str.4 = [30 x i8] c"Done alocating the microarray\00"
define double* @readMicroarray(i8* nocapture %0, i64 %1, i32 %2) {
%4 = alloca [80 x i8]
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%6 = sext i32 %2 to i64
%7 = mul i64 %6, %1
%8 = tail call i64 @calloc(i64 %7, i32 8)
%9 = inttoptr i64 %8 to double*
%10 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %1, 0
br i1 %11, label %31, label %12
12: ; preds = %3
%13 = icmp sgt i32 %2, 0
%14 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%15 = zext i32 %2 to i64
br label %16
16: ; preds = %12, %28
%17 = phi i64 [ 0, %12 ], [ %29, %28 ]
br i1 %13, label %18, label %28
18: ; preds = %16
%19 = mul nsw i64 %17, %6
br label %20
20: ; preds = %18, %20
%21 = phi i64 [ 0, %18 ], [ %26, %20 ]
%22 = call i32 @fscanf(i32* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%23 = call double @atof(i8* %14)
%24 = add nsw i64 %21, %19
%25 = getelementptr inbounds double, double* %9, i64 %24
store double %23, double* %25
%26 = add nuw nsw i64 %21, 1
%27 = icmp eq i64 %26, %15
br i1 %27, label %28, label %20
28: ; preds = %20, %16
%29 = add nuw i64 %17, 1
%30 = icmp eq i64 %29, %1
br i1 %30, label %31, label %16
31: ; preds = %28, %3
%32 = call i32 @fclose(i32* %10)
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.4, i64 0, i64 0))
ret double* %9
}