#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*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char **);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  printf("\n Bienvenidos al Lector\n");
  FILE *miarchivo = NULL;
  char *nombrearchivo = "texto1.txt";
  char lectura[80];
  miarchivo = fopen(nombrearchivo, "r");
  if (miarchivo == NULL)
    return -1;
  fscanf(miarchivo, " %[^\n]", &lectura);
  printf("Lectura: %s\n", lectura);
  fscanf(miarchivo, " %[^\n]", &lectura);
  printf("Lectura: %s\n", lectura);
  fscanf(miarchivo, " %[^\n]", &lectura);
  printf("Lectura: %s\n", lectura);
  fclose(miarchivo);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x0,-0x10(%rbp)
lea    0xead(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    119b <main+0x5b>
movl   $0xffffffff,-0x4(%rbp)
jmp    121d <main+0xdd>
mov    -0x10(%rbp),%rdi
lea    -0x70(%rbp),%rdx
lea    0xe7c(%rip),%rsi
call   1050 <fscanf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x70(%rbp),%rdx
lea    0xe56(%rip),%rsi
call   1050 <fscanf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x70(%rbp),%rdx
lea    0xe30(%rip),%rsi
call   1050 <fscanf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x50,%rsp
lea    0xebc(%rip),%rdi
call   1030 <puts@plt>
lea    0xe91(%rip),%rdi
lea    0xebf(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11f2 <main+0xa2>
mov    %rax,%rbx
lea    0xe81(%rip),%r15
mov    %rsp,%rbp
mov    %rax,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1060 <fscanf@plt>
lea    0xe70(%rip),%r12
xor    %r14d,%r14d
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1060 <fscanf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1060 <fscanf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    11f8 <main+0xa8>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"\0A Bienvenidos al Lector\0A\00"
@.str.1 = [11 x i8] c"texto1.txt\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [7 x i8] c" %[^\0A]\00"
@.str.4 = [13 x i8] c"Lectura: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca [80 x i8]
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
store i32* null, i32** %2
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %3
%6 = load i8*, i8** %3
%7 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %7, i32** %2
%8 = load i32*, i32** %2
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %11
10: ; preds = %0
store i32 -1, i32* %1
br label %29
11: ; preds = %0
%12 = load i32*, i32** %2
%13 = bitcast [80 x i8]* %4 to i8**
%14 = call i32 @fscanf(i32* %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8** %13)
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %15)
%17 = load i32*, i32** %2
%18 = bitcast [80 x i8]* %4 to i8**
%19 = call i32 @fscanf(i32* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8** %18)
%20 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %20)
%22 = load i32*, i32** %2
%23 = bitcast [80 x i8]* %4 to i8**
%24 = call i32 @fscanf(i32* %22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8** %23)
%25 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %25)
%27 = load i32*, i32** %2
%28 = call i32 @fclose(i32* %27)
store i32 0, i32* %1
br label %29
29: ; preds = %11, %10
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str.1 = [11 x i8] c"texto1.txt\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [7 x i8] c" %[^\0A]\00"
@.str.4 = [13 x i8] c"Lectura: %s\0A\00"
@str = [24 x i8] c"\0A Bienvenidos al Lector\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %15, label %6
6: ; preds = %0
%7 = bitcast [80 x i8]* %1 to i8**
%8 = call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8** %7)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%10 = call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8** %7)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%12 = call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8** %7)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%14 = call i32 @fclose(i32* %4)
br label %15
15: ; preds = %0, %6
%16 = phi i32 [ 0, %6 ], [ -1, %0 ]
ret i32 %16
}