#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 fileSize(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
char *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, char *);
char *leerChromosnet(char *ruta) {
  char *red;
  char path[200];
  sprintf(path, "%s/ChromosfericNetwork.dat", ruta);
  FILE *file;
  file = fopen(path, "rw");
  red = malloc(sizeof(char) * fileSize(file));
  int n = 0;
  char c;
  while (fscanf(file, "%c", &c) > 0) {
    if (c == '0' || c == '1') {
      red[n] = c;
      n++;
    }
  }
  n--;
  return red;
}


x86 assembly (clang, -O0):
<leerChromosnet>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0xe0(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe8f(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0xe0(%rbp),%rdi
lea    0xe97(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0xe8(%rbp)
mov    -0xe8(%rbp),%rdi
call   1030 <fileSize@plt>
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0xec(%rbp)
mov    -0xe8(%rbp),%rdi
lea    0xe59(%rip),%rsi
lea    -0xed(%rbp),%rdx
call   1040 <fscanf@plt>
cmp    $0x0,%rax
jle    1223 <leerChromosnet+0xd3>
movsbl -0xed(%rbp),%eax
cmp    $0x30,%eax
je     11fb <leerChromosnet+0xab>
movsbl -0xed(%rbp),%eax
cmp    $0x31,%eax
jne    121e <leerChromosnet+0xce>
mov    -0xed(%rbp),%dl
mov    -0x10(%rbp),%rax
movslq -0xec(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xec(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xec(%rbp)
jmp    11b7 <leerChromosnet+0x67>
mov    -0xec(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xec(%rbp)
mov    -0x10(%rbp),%rax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<leerChromosnet>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe0,%rsp
mov    %rdi,%rdx
lea    0xe96(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <sprintf@plt>
lea    0xe9d(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
mov    %rax,%r13
mov    %rax,%rdi
call   1030 <fileSize@plt>
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
lea    0xe7c(%rip),%rsi
lea    0xf(%rsp),%rdx
mov    %r13,%rdi
call   1040 <fscanf@plt>
test   %rax,%rax
jle    11fe <leerChromosnet+0xae>
xor    %ebx,%ebx
lea    0xe61(%rip),%r15
lea    0xf(%rsp),%r12
jmp    11e3 <leerChromosnet+0x93>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1040 <fscanf@plt>
test   %rax,%rax
jle    11fe <leerChromosnet+0xae>
movzbl 0xf(%rsp),%eax
mov    %eax,%ecx
and    $0xfe,%cl
cmp    $0x30,%cl
jne    11d0 <leerChromosnet+0x80>
movslq %ebx,%rbx
mov    %al,(%r14,%rbx,1)
add    $0x1,%ebx
jmp    11d0 <leerChromosnet+0x80>
mov    %r14,%rax
add    $0xe0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [27 x i8] c"%s/ChromosfericNetwork.dat\00"
@.str.1 = [3 x i8] c"rw\00"
@.str.2 = [3 x i8] c"%c\00"
define i8* @leerChromosnet(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [200 x i8]
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i8
store i8* %0, i8** %2
%8 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%9 = load i8*, i8** %2
%10 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %5
%13 = load i32*, i32** %5
%14 = call i32 @fileSize(i32* %13)
%15 = sext i32 %14 to i64
%16 = mul i64 1, %15
%17 = trunc i64 %16 to i32
%18 = call i8* @malloc(i32 %17)
store i8* %18, i8** %3
store i32 0, i32* %6
br label %19
19: ; preds = %39, %1
%20 = load i32*, i32** %5
%21 = call i64 @fscanf(i32* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%22 = icmp sgt i64 %21, 0
br i1 %22, label %23, label %40
23: ; preds = %19
%24 = load i8, i8* %7
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 48
br i1 %26, label %31, label %27
27: ; preds = %23
%28 = load i8, i8* %7
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 49
br i1 %30, label %31, label %39
31: ; preds = %27, %23
%32 = load i8, i8* %7
%33 = load i8*, i8** %3
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
store i8 %32, i8* %36
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %39
39: ; preds = %31, %27
br label %19
40: ; preds = %19
%41 = load i32, i32* %6
%42 = add nsw i32 %41, -1
store i32 %42, i32* %6
%43 = load i8*, i8** %3
ret i8* %43
}

LLVM IR (-O2):
@.str = [27 x i8] c"%s/ChromosfericNetwork.dat\00"
@.str.1 = [3 x i8] c"rw\00"
@.str.2 = [3 x i8] c"%c\00"
define noalias i8* @leerChromosnet(i8* %0) {
%2 = alloca [200 x i8]
%3 = alloca i8
%4 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%5 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @fileSize(i32* %6)
%8 = tail call i8* @malloc(i32 %7)
%9 = call i64 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%10 = icmp sgt i64 %9, 0
br i1 %10, label %11, label %24
11: ; preds = %1, %20
%12 = phi i32 [ %21, %20 ], [ 0, %1 ]
%13 = load i8, i8* %3
%14 = and i8 %13, -2
%15 = icmp eq i8 %14, 48
br i1 %15, label %16, label %20
16: ; preds = %11
%17 = sext i32 %12 to i64
%18 = getelementptr inbounds i8, i8* %8, i64 %17
store i8 %13, i8* %18
%19 = add nsw i32 %12, 1
br label %20
20: ; preds = %11, %16
%21 = phi i32 [ %19, %16 ], [ %12, %11 ]
%22 = call i64 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%23 = icmp sgt i64 %22, 0
br i1 %23, label %11, label %24
24: ; preds = %20, %1
ret i8* %8
}