#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*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *, char *, char *,
                          int *);
int /*<<< orphan*/ printf(char *, char *, char *, char *, int);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int main() {
  char str1[7], str2[2], str3[2];
  int a;
  FILE *arc_impr;
  arc_impr = fopen("file.txt", "w+");
  fputs("Estamos en el 2017", arc_impr);
  rewind(arc_impr);
  fscanf(arc_impr, "%s %s %s %d", str1, str2, str3, &a);
  printf("Imprime cadena: |%s| |%s| |%s| |%d| \n", str1, str2, str3, a);
  fclose(arc_impr);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
lea    0xe8c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe7b(%rip),%rdi
call   1060 <fputs@plt>
mov    -0x20(%rbp),%rdi
call   1050 <rewind@plt>
mov    -0x20(%rbp),%rdi
lea    -0xb(%rbp),%rdx
lea    -0xd(%rbp),%rcx
lea    -0xf(%rbp),%r8
lea    0xe69(%rip),%rsi
lea    -0x14(%rbp),%r9
call   1070 <fscanf@plt>
lea    -0xb(%rbp),%rsi
lea    -0xd(%rbp),%rdx
lea    -0xf(%rbp),%rcx
mov    -0x14(%rbp),%r8d
lea    0xe55(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe8e(%rip),%rdi
lea    0xe90(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xe84(%rip),%rdi
mov    $0x12,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1080 <fwrite@plt>
mov    %rbx,%rdi
call   1050 <rewind@plt>
lea    0xe76(%rip),%rsi
lea    0x11(%rsp),%r14
lea    0xf(%rsp),%r15
lea    0xd(%rsp),%r12
lea    0x8(%rsp),%r9
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %r12,%r8
call   1060 <fscanf@plt>
mov    0x8(%rsp),%r8d
lea    0xe51(%rip),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"file.txt\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [19 x i8] c"Estamos en el 2017\00"
@.str.3 = [12 x i8] c"%s %s %s %d\00"
@.str.4 = [38 x i8] c"Imprime cadena: |%s| |%s| |%s| |%d| \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [7 x i8]
%3 = alloca [2 x i8]
%4 = alloca [2 x i8]
%5 = alloca i32
%6 = alloca i32*
store i32 0, i32* %1
%7 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %6
%8 = load i32*, i32** %6
%9 = call i32 @fputs(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32* %8)
%10 = load i32*, i32** %6
%11 = call i32 @rewind(i32* %10)
%12 = load i32*, i32** %6
%13 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%14 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%15 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%16 = call i32 @fscanf(i32* %12, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %13, i8* %14, i8* %15, i32* %5)
%17 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%18 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%19 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%20 = load i32, i32* %5
%21 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i8* %17, i8* %18, i8* %19, i32 %20)
%22 = load i32*, i32** %6
%23 = call i32 @fclose(i32* %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"file.txt\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [19 x i8] c"Estamos en el 2017\00"
@.str.3 = [12 x i8] c"%s %s %s %d\00"
@.str.4 = [38 x i8] c"Imprime cadena: |%s| |%s| |%s| |%d| \0A\00"
define i32 @main() {
%1 = alloca [7 x i8]
%2 = alloca [2 x i8]
%3 = alloca [2 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%8 = bitcast i32* %4 to i8*
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i64 18, i64 1, i32* %9)
%11 = tail call i32 @rewind(i32* %9)
%12 = call i32 @fscanf(i32* %9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %5, i8* %6, i8* %7, i32* %4)
%13 = load i32, i32* %4
%14 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i8* %5, i8* %6, i8* %7, i32 %13)
%15 = call i32 @fclose(i32* %9)
ret i32 0
}