#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 */
scalar_t__ EOF;
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int leerArchivo(char nombre[], char contenido[]) {
  FILE *f;
  char aux_cadena[100];
  contenido[0] = '\0';
  f = fopen(nombre, "r");
  if (f == NULL) {
    return -1;
  }
  while (fscanf(f, "%c", aux_cadena) != EOF) {
    strcat(contenido, aux_cadena);
  }
  fscanf(f, "%s", contenido);
  return 1;
}


x86 assembly (clang, -O0):
<leerArchivo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    0xeab(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1175 <leerArchivo+0x45>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d1 <leerArchivo+0xa1>
jmp    117a <leerArchivo+0x4a>
mov    -0x20(%rbp),%rdi
lea    -0x90(%rbp),%rdx
lea    0xe76(%rip),%rsi
call   1030 <fscanf@plt>
mov    0x2e50(%rip),%rcx
cmp    (%rcx),%rax
je     11b6 <leerArchivo+0x86>
mov    -0x18(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1050 <strcat@plt>
jmp    117a <leerArchivo+0x4a>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe40(%rip),%rsi
call   1030 <fscanf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<leerArchivo>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x70,%rsp
mov    %rsi,%r14
movb   $0x0,(%rsi)
lea    0xeb6(%rip),%rsi
call   1040 <fopen@plt>
test   %rax,%rax
je     11b8 <leerArchivo+0x88>
mov    %rax,%r15
lea    0xea4(%rip),%rsi
mov    %rsp,%rdx
mov    %rax,%rdi
call   1030 <fscanf@plt>
mov    0x2e78(%rip),%r13
cmp    0x0(%r13),%rax
je     119f <leerArchivo+0x6f>
mov    %rsp,%rbx
lea    0xe82(%rip),%r12
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strcat@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1030 <fscanf@plt>
cmp    0x0(%r13),%rax
jne    1180 <leerArchivo+0x50>
lea    0xe5f(%rip),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
call   1030 <fscanf@plt>
mov    $0x1,%eax
jmp    11bd <leerArchivo+0x8d>
mov    $0xffffffff,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%c\00"
@EOF = global i64 0
@.str.2 = [3 x i8] c"%s\00"
define i32 @leerArchivo(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca [100 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %5
%9 = getelementptr inbounds i8, i8* %8, i64 0
store i8 0, i8* %9
%10 = load i8*, i8** %4
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %6
%12 = load i32*, i32** %6
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 -1, i32* %3
br label %30
15: ; preds = %2
br label %16
16: ; preds = %22, %15
%17 = load i32*, i32** %6
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%19 = call i64 @fscanf(i32* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = load i64, i64* @EOF
%21 = icmp ne i64 %19, %20
br i1 %21, label %22, label %26
22: ; preds = %16
%23 = load i8*, i8** %5
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%25 = call i32 @strcat(i8* %23, i8* %24)
br label %16
26: ; preds = %16
%27 = load i32*, i32** %6
%28 = load i8*, i8** %5
%29 = call i64 @fscanf(i32* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %28)
store i32 1, i32* %3
br label %30
30: ; preds = %26, %14
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%c\00"
@EOF = global i64 0
@.str.2 = [3 x i8] c"%s\00"
define i32 @leerArchivo(i8* nocapture %0, i8* %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
store i8 0, i8* %1
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %18, label %7
7: ; preds = %2
%8 = call i64 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%9 = load i64, i64* @EOF
%10 = icmp eq i64 %8, %9
br i1 %10, label %16, label %11
11: ; preds = %7, %11
%12 = call i32 @strcat(i8* %1, i8* %4)
%13 = call i64 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%14 = load i64, i64* @EOF
%15 = icmp eq i64 %13, %14
br i1 %15, label %16, label %11
16: ; preds = %11, %7
%17 = call i64 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %1)
br label %18
18: ; preds = %2, %16
%19 = phi i32 [ 1, %16 ], [ -1, %2 ]
ret i32 %19
}