#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*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ stdout;
FILE *manage_file() {
  int flag = 0;
  char name[50], oper = ' ';
  FILE *fp = NULL;
  while (flag == 0) {
    fprintf(stdout, "\nEnter file name to save the wordlist: ");
    scanf("%49s", name);
    fp = fopen(name, "r");
    if (fp == NULL) {
      fprintf(stdout, "No such file with this name. Creating file %s.\n", name);
      fp = fopen(name, "w");
      flag = 1;
    } else {
      fprintf(stdout, "\nThere is a file with the same name.\n"
                      "Do you want to (1)overwrite or (2)create a new one? ");
      scanf("%1s", &oper);
      switch (oper) {
      case '1':
        fp = fopen(name, "w");
        flag = 1;
        break;
      case '2':
        break;
      default:
        fprintf(stdout, "Are you kidding me? Come on please serious.\n");
        break;
      }
    }
  }
  fprintf(stdout, "\n");
  return fp;
}


x86 assembly (clang, -O0):
<manage_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x20,-0x41(%rbp)
movq   $0x0,-0x50(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1269 <manage_file+0x139>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
lea    0xe9b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
lea    -0x40(%rbp),%rsi
lea    0xeb1(%rip),%rdi
call   1040 <scanf@plt>
lea    -0x40(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    11d6 <manage_file+0xa6>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
lea    -0x40(%rbp),%rdx
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
lea    -0x40(%rbp),%rdi
lea    0xe9e(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x50(%rbp)
movl   $0x1,-0x4(%rbp)
jmp    1264 <manage_file+0x134>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
lea    0xe7b(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xec7(%rip),%rdi
lea    -0x41(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x41(%rbp),%eax
mov    %eax,-0x54(%rbp)
sub    $0x31,%eax
je     1223 <manage_file+0xf3>
jmp    1212 <manage_file+0xe2>
mov    -0x54(%rbp),%eax
sub    $0x32,%eax
je     1243 <manage_file+0x113>
jmp    1248 <manage_file+0x118>
lea    -0x40(%rbp),%rdi
lea    0xe31(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x50(%rbp)
movl   $0x1,-0x4(%rbp)
jmp    125f <manage_file+0x12f>
jmp    125f <manage_file+0x12f>
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
lea    0xe67(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1264 <manage_file+0x134>
jmp    114b <manage_file+0x1b>
mov    0x2d70(%rip),%rax
mov    (%rax),%edi
lea    0xde4(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x50(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<manage_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
movb   $0x20,0xf(%rsp)
mov    0x2e96(%rip),%r15
mov    (%r15),%edi
lea    0xeac(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xec6(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1040 <scanf@plt>
lea    0xeb7(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fopen@plt>
mov    (%r15),%edi
test   %rax,%rax
je     121a <manage_file+0xea>
lea    0xf(%rsp),%r13
lea    0xe6a(%rip),%r12
lea    0xe8b(%rip),%rbx
lea    0x10(%rsp),%rbp
lea    0xe84(%rip),%r14
jmp    11db <manage_file+0xab>
nopl   0x0(%rax,%rax,1)
mov    (%r15),%edi
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <scanf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1050 <fopen@plt>
mov    (%r15),%edi
test   %rax,%rax
je     121a <manage_file+0xea>
lea    0xe7f(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xecb(%rip),%rdi
mov    %r13,%rsi
call   1040 <scanf@plt>
movsbl 0xf(%rsp),%eax
cmp    $0x32,%eax
je     11b0 <manage_file+0x80>
cmp    $0x31,%eax
je     122d <manage_file+0xfd>
mov    (%r15),%edi
lea    0xeae(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    11b0 <manage_file+0x80>
lea    0xe0e(%rip),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xe2b(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1050 <fopen@plt>
mov    %rax,%rbx
mov    (%r15),%edi
lea    0xe12(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %rbx,%rax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [40 x i8] c"\0AEnter file name to save the wordlist: \00"
@.str.1 = [5 x i8] c"%49s\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [48 x i8] c"No such file with this name. Creating file %s.\0A\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [90 x i8] c"\0AThere is a file with the same name.\0ADo you want to (1)overwrite or (2)create a new one? \00"
@.str.6 = [4 x i8] c"%1s\00"
@.str.7 = [45 x i8] c"Are you kidding me? Come on please serious.\0A\00"
@.str.8 = [2 x i8] c"\0A\00"
define i32* @manage_file() {
%1 = alloca i32
%2 = alloca [50 x i8]
%3 = alloca i8
%4 = alloca i32*
store i32 0, i32* %1
store i8 32, i8* %3
store i32* null, i32** %4
br label %5
5: ; preds = %37, %0
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %38
8: ; preds = %5
%9 = load i32, i32* @stdout
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%12 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %14, i32** %4
%15 = load i32*, i32** %4
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %23
17: ; preds = %8
%18 = load i32, i32* @stdout
%19 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %22, i32** %4
store i32 1, i32* %1
br label %37
23: ; preds = %8
%24 = load i32, i32* @stdout
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.5, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %3)
%27 = load i8, i8* %3
%28 = sext i8 %27 to i32
switch i32 %28, label %33 [
i32 49, label %29
i32 50, label %32
]
29: ; preds = %23
%30 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%31 = call i32* @fopen(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %31, i32** %4
store i32 1, i32* %1
br label %36
32: ; preds = %23
br label %36
33: ; preds = %23
%34 = load i32, i32* @stdout
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0))
br label %36
36: ; preds = %33, %32, %29
br label %37
37: ; preds = %36, %17
br label %5
38: ; preds = %5
%39 = load i32, i32* @stdout
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%41 = load i32*, i32** %4
ret i32* %41
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [40 x i8] c"\0AEnter file name to save the wordlist: \00"
@.str.1 = [5 x i8] c"%49s\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [48 x i8] c"No such file with this name. Creating file %s.\0A\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [90 x i8] c"\0AThere is a file with the same name.\0ADo you want to (1)overwrite or (2)create a new one? \00"
@.str.6 = [4 x i8] c"%1s\00"
@.str.7 = [45 x i8] c"Are you kidding me? Come on please serious.\0A\00"
@.str.8 = [2 x i8] c"\0A\00"
define noalias i32* @manage_file() {
%1 = alloca [50 x i8]
%2 = alloca i8
%3 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
store i8 32, i8* %2
%4 = load i32, i32* @stdout
%5 = call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i32* %7, null
%9 = load i32, i32* @stdout
br i1 %8, label %10, label %13
10: ; preds = %22, %0
%11 = phi i32 [ %9, %0 ], [ %28, %22 ]
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* %3)
br label %29
13: ; preds = %0, %22
%14 = phi i32 [ %28, %22 ], [ %9, %0 ]
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %2)
%17 = load i8, i8* %2
%18 = sext i8 %17 to i32
switch i32 %18, label %19 [
i32 49, label %29
i32 50, label %22
]
19: ; preds = %13
%20 = load i32, i32* @stdout
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0))
br label %22
22: ; preds = %13, %19
%23 = load i32, i32* @stdout
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%26 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i32* %26, null
%28 = load i32, i32* @stdout
br i1 %27, label %10, label %13
29: ; preds = %13, %10
%30 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%31 = load i32, i32* @stdout
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
ret i32* %30
}