#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*/ cambio(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ system(char *);
int main() {
  char aux[50];
  FILE *f;
  f = fopen("Bloque8.3.txt", "w");
  if (f == NULL) {
    printf("Nose ha podido abrir.\n");
    exit(1);
  }
  printf("introduce una frase: ");
  fgets(aux, 50, stdin);
  cambio(aux);
  fprintf(f, "El string intruducido ha sido: %s", aux);
  fclose(f);
  system("pause");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe6a(%rip),%rdi
lea    0xe71(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    11c7 <main+0x47>
lea    0xe58(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
lea    0xe59(%rip),%rdi
call   1050 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    0x2e0a(%rip),%rax
mov    (%rax),%edx
mov    $0x32,%esi
call   1060 <fgets@plt>
lea    -0x40(%rbp),%rdi
call   1080 <cambio@plt>
mov    -0x48(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    0xe3b(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x48(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe48(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
lea    0xe62(%rip),%rdi
lea    0xe69(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     120f <main+0x7f>
mov    %rax,%rbx
lea    0xe57(%rip),%rdi
call   1060 <printf@plt>
mov    0x2e23(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x32,%esi
call   1070 <fgets@plt>
mov    %r14,%rdi
call   1090 <cambio@plt>
lea    0xe40(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1080 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xe48(%rip),%rdi
call   1050 <system@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe38(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"Bloque8.3.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [23 x i8] c"Nose ha podido abrir.\0A\00"
@.str.3 = [22 x i8] c"introduce una frase: \00"
@stdin = global i32 0
@.str.4 = [34 x i8] c"El string intruducido ha sido: %s\00"
@.str.5 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8]
%3 = alloca i32*
store i32 0, i32* %1
%4 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %3
%5 = load i32*, i32** %3
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @exit(i32 1)
unreachable
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%13 = load i32, i32* @stdin
%14 = call i32 @fgets(i8* %12, i32 50, i32 %13)
%15 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%16 = call i32 @cambio(i8* %15)
%17 = load i32*, i32** %3
%18 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%19 = call i32 @fprintf(i32* %17, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* %18)
%20 = load i32*, i32** %3
%21 = call i32 @fclose(i32* %20)
%22 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"Bloque8.3.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.3 = [22 x i8] c"introduce una frase: \00"
@stdin = global i32 0
@.str.4 = [34 x i8] c"El string intruducido ha sido: %s\00"
@.str.5 = [6 x i8] c"pause\00"
@str = [22 x i8] c"Nose ha podido abrir.\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %0
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%10 = load i32, i32* @stdin
%11 = call i32 @fgets(i8* %2, i32 50, i32 %10)
%12 = call i32 @cambio(i8* %2)
%13 = call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%14 = call i32 @fclose(i32* %3)
%15 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}