#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(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, float *);
float *malloc(int);
int /*<<< orphan*/ printf(char *);
float *lee_datos(int a) {
  FILE *entrada;
  if (a == 0) {
    entrada = fopen("datos_f.dat", "r");
  }
  if (a == 1) {
    entrada = fopen("datos_t.dat", "r");
  }
  float *x = malloc(4141 * sizeof(float));
  int i;
  if (entrada == NULL) {
    printf("\nERROR AL LEER ARCHIVO\n");
    exit(0);
  }
  for (i = 0; i < 4141; i++) {
    fscanf(entrada, "%f ", &x[i]);
  }
  return x;
}


x86 assembly (clang, -O0):
<lee_datos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    117c <lee_datos+0x2c>
lea    0xe94(%rip),%rdi
lea    0xe99(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    119d <lee_datos+0x4d>
lea    0xe81(%rip),%rdi
lea    0xe78(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    $0x40b4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11c9 <lee_datos+0x79>
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x102d,-0x1c(%rbp)
jge    120a <lee_datos+0xba>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe3b(%rip),%rsi
call   1040 <fscanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11d0 <lee_datos+0x80>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lee_datos>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
je     116a <lee_datos+0x1a>
cmp    $0x1,%edi
jne    11cb <lee_datos+0x7b>
lea    0xea6(%rip),%rdi
jmp    1171 <lee_datos+0x21>
lea    0xe8f(%rip),%rdi
lea    0xe94(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
mov    $0x40b4,%edi
call   1050 <malloc@plt>
test   %r14,%r14
je     11d5 <lee_datos+0x85>
mov    %rax,%r12
xor    %ebx,%ebx
lea    0xe7f(%rip),%r15
nopl   0x0(%rax,%rax,1)
lea    (%r12,%rbx,1),%rdx
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <fscanf@plt>
add    $0x4,%rbx
cmp    $0x40b4,%rbx
jne    11a0 <lee_datos+0x50>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    $0x40b4,%edi
call   1050 <malloc@plt>
lea    0xe42(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"datos_f.dat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [12 x i8] c"datos_t.dat\00"
@.str.3 = [24 x i8] c"\0AERROR AL LEER ARCHIVO\0A\00"
@.str.4 = [4 x i8] c"%f \00"
define float* @lee_datos(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca float*
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %3
br label %10
10: ; preds = %8, %1
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %14, i32** %3
br label %15
15: ; preds = %13, %10
%16 = call float* @malloc(i32 16564)
store float* %16, float** %4
%17 = load i32*, i32** %3
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 @exit(i32 0)
unreachable
22: ; preds = %15
store i32 0, i32* %5
br label %23
23: ; preds = %33, %22
%24 = load i32, i32* %5
%25 = icmp slt i32 %24, 4141
br i1 %25, label %26, label %36
26: ; preds = %23
%27 = load i32*, i32** %3
%28 = load float*, float** %4
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds float, float* %28, i64 %30
%32 = call i32 @fscanf(i32* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), float* %31)
br label %33
33: ; preds = %26
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5
br label %23
36: ; preds = %23
%37 = load float*, float** %4
ret float* %37
}

LLVM IR (-O2):
@.str = [12 x i8] c"datos_f.dat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [12 x i8] c"datos_t.dat\00"
@.str.4 = [4 x i8] c"%f \00"
@str = [23 x i8] c"\0AERROR AL LEER ARCHIVO\00"
define float* @lee_datos(i32 %0) {
switch i32 %0, label %2 [
i32 0, label %5
i32 1, label %4
]
2: ; preds = %1
%3 = tail call float* @malloc(i32 16564)
br label %10
4: ; preds = %1
br label %5
5: ; preds = %1, %4
%6 = phi i8* [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %1 ]
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call float* @malloc(i32 16564)
%9 = icmp eq i32* %7, null
br i1 %9, label %10, label %13
10: ; preds = %2, %5
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @exit(i32 0)
unreachable
13: ; preds = %5, %13
%14 = phi i64 [ %17, %13 ], [ 0, %5 ]
%15 = getelementptr inbounds float, float* %8, i64 %14
%16 = tail call i32 @fscanf(i32* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), float* %15)
%17 = add nuw nsw i64 %14, 1
%18 = icmp eq i64 %17, 4141
br i1 %18, label %19, label %13
19: ; preds = %13
ret float* %8
}