#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 */

/* Variables and functions */
int /*<<< orphan*/ crearFichero(char *);
scalar_t__ existe(char *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
char getchar();
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
main() {
  char nombreFichero[30];
  char resp = 's';
  printf("Nombre del fichero: ");
  gets(nombreFichero);
  if (existe(nombreFichero)) {
    printf("El fichero existe ¿desea sobrescribirlo? (s/n) ");
    resp = getchar();
    fflush(stdin);
  }
  if (resp == 's') {
    crearFichero(nombreFichero);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x73,-0x31(%rbp)
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1060 <gets@plt>
lea    -0x30(%rbp),%rdi
call   1080 <existe@plt>
cmp    $0x0,%rax
je     11bf <main+0x5f>
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x31(%rbp)
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
movsbl -0x31(%rbp),%eax
cmp    $0x73,%eax
jne    11d5 <main+0x75>
lea    -0x30(%rbp),%rdi
call   1050 <crearFichero@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <gets@plt>
mov    %rbx,%rdi
call   1080 <existe@plt>
test   %rax,%rax
je     11b1 <main+0x51>
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%ebx
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
cmp    $0x73,%bl
jne    11b9 <main+0x59>
mov    %rsp,%rdi
call   1050 <crearFichero@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Nombre del fichero: \00"
@.str.1 = [49 x i8] c"El fichero existe \C2\BFdesea sobrescribirlo? (s/n) \00"
@stdin = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [30 x i8]
%3 = alloca i8
store i32 0, i32* %1
store i8 115, i8* %3
%4 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%6 = call i32 @gets(i8* %5)
%7 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%8 = call i64 @existe(i8* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
%12 = call signext i8 (...) @getchar()
store i8 %12, i8* %3
%13 = load i32, i32* @stdin
%14 = call i32 @fflush(i32 %13)
br label %15
15: ; preds = %10, %0
%16 = load i8, i8* %3
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 115
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%21 = call i32 @crearFichero(i8* %20)
br label %22
22: ; preds = %19, %15
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str = [21 x i8] c"Nombre del fichero: \00"
@.str.1 = [49 x i8] c"El fichero existe \C2\BFdesea sobrescribirlo? (s/n) \00"
@stdin = global i32 0
define i32 @main() {
%1 = alloca [30 x i8]
%2 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @gets(i8* %2)
%5 = call i64 @existe(i8* %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %13, label %7
7: ; preds = %0
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
%9 = call signext i8 (...) @getchar()
%10 = load i32, i32* @stdin
%11 = call i32 @fflush(i32 %10)
%12 = icmp eq i8 %9, 115
br i1 %12, label %13, label %15
13: ; preds = %0, %7
%14 = call i32 @crearFichero(i8* %2)
br label %15
15: ; preds = %13, %7
ret i32 0
}