#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*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ printf(char *);
int main() {
  printf("\n Bienvenidos al Escritor\n");
  FILE *miarchivo = NULL;
  char *nombrearchivo = "Data2.txt";
  miarchivo = fopen(nombrearchivo, "w");
  if (miarchivo == NULL)
    return -1;
  fprintf(miarchivo, "Hola soy un archivo! \n");
  fprintf(miarchivo, "Sudirribe, Like & Click en mis vids >D \n");
  fclose(miarchivo);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
movq   $0x0,-0x10(%rbp)
lea    0xeb1(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xeac(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1199 <main+0x59>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c9 <main+0x89>
mov    -0x10(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xf04(%rip),%rdi
call   1030 <puts@plt>
lea    0xeac(%rip),%rdi
lea    0xeaf(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11a6 <main+0x66>
mov    %rax,%rbx
lea    0xe9d(%rip),%rdi
mov    $0x16,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1060 <fwrite@plt>
lea    0xe9b(%rip),%rdi
mov    $0x28,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"\0A Bienvenidos al Escritor\0A\00"
@.str.1 = [10 x i8] c"Data2.txt\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [23 x i8] c"Hola soy un archivo! \0A\00"
@.str.4 = [41 x i8] c"Sudirribe, Like & Click en mis vids >D \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i8*
store i32 0, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32* null, i32** %2
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %3
%5 = load i8*, i8** %3
%6 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %6, i32** %2
%7 = load i32*, i32** %2
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %10
9: ; preds = %0
store i32 -1, i32* %1
br label %17
10: ; preds = %0
%11 = load i32*, i32** %2
%12 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%13 = load i32*, i32** %2
%14 = call i32 @fprintf(i32* %13, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
%15 = load i32*, i32** %2
%16 = call i32 @fclose(i32* %15)
store i32 0, i32* %1
br label %17
17: ; preds = %10, %9
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
@.str.1 = [10 x i8] c"Data2.txt\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [23 x i8] c"Hola soy un archivo! \0A\00"
@.str.4 = [41 x i8] c"Sudirribe, Like & Click en mis vids >D \0A\00"
@str = [26 x i8] c"\0A Bienvenidos al Escritor\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %8, label %4
4: ; preds = %0
%5 = tail call i64 @fwrite(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i64 22, i64 1, i32* %2)
%6 = tail call i64 @fwrite(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i64 40, i64 1, i32* %2)
%7 = tail call i32 @fclose(i32* %2)
br label %8
8: ; preds = %0, %4
%9 = phi i32 [ 0, %4 ], [ -1, %0 ]
ret i32 %9
}