#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*/ fprintf(int /*<<< orphan*/, char *, char const *);
scalar_t__ isspace(int);
int /*<<< orphan*/ readline(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int strlen(char *);
int userFileOverwrite(const char *filename) {
  int status = 0, len;
  char line[1024], *pline;
  fprintf(stderr, "File %s already exists, overwrite? (yes/no): ", filename);
  readline(stdin, line, 1024);
  pline = line;
  while (isspace((int)*pline))
    pline++;
  len = strlen(pline);
  if (len == 3) {
    if (pline[0] == 'y' && pline[1] == 'e' && pline[2] == 's')
      status = 1;
    else if (pline[0] == 'Y' && pline[1] == 'E' && pline[2] == 'S')
      status = 1;
  } else if (len == 1) {
    if (pline[0] == 'y')
      status = 1;
  }
  return (status);
}


x86 assembly (clang, -O0):
<userFileOverwrite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    0x2e7b(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe96(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1040 <readline@plt>
lea    -0x410(%rbp),%rax
mov    %rax,-0x418(%rbp)
mov    -0x418(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
je     11c7 <userFileOverwrite+0x87>
mov    -0x418(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x418(%rbp)
jmp    1197 <userFileOverwrite+0x57>
mov    -0x418(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x3,-0x10(%rbp)
jne    1273 <userFileOverwrite+0x133>
mov    -0x418(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x79,%eax
jne    1227 <userFileOverwrite+0xe7>
mov    -0x418(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x65,%eax
jne    1227 <userFileOverwrite+0xe7>
mov    -0x418(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x73,%eax
jne    1227 <userFileOverwrite+0xe7>
movl   $0x1,-0xc(%rbp)
jmp    126e <userFileOverwrite+0x12e>
mov    -0x418(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x59,%eax
jne    1269 <userFileOverwrite+0x129>
mov    -0x418(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x45,%eax
jne    1269 <userFileOverwrite+0x129>
mov    -0x418(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x53,%eax
jne    1269 <userFileOverwrite+0x129>
movl   $0x1,-0xc(%rbp)
jmp    126e <userFileOverwrite+0x12e>
jmp    12a1 <userFileOverwrite+0x161>
cmpl   $0x1,-0x10(%rbp)
jne    129c <userFileOverwrite+0x15c>
mov    -0x418(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x79,%eax
jne    1297 <userFileOverwrite+0x157>
movl   $0x1,-0xc(%rbp)
jmp    129c <userFileOverwrite+0x15c>
jmp    12a1 <userFileOverwrite+0x161>
mov    -0xc(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<userFileOverwrite>:
push   %rbx
sub    $0x400,%rsp
mov    %rdi,%rdx
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
lea    0xea5(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
mov    $0x400,%edx
call   1040 <readline@plt>
lea    -0x1(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1050 <isspace@plt>
test   %rax,%rax
jne    1180 <userFileOverwrite+0x40>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
je     11be <userFileOverwrite+0x7e>
cmp    $0x3,%eax
jne    11d2 <userFileOverwrite+0x92>
mov    (%rbx),%al
cmp    $0x59,%al
je     11c6 <userFileOverwrite+0x86>
cmp    $0x79,%al
jne    11d2 <userFileOverwrite+0x92>
cmpb   $0x65,0x1(%rbx)
jne    11d2 <userFileOverwrite+0x92>
mov    $0x1,%al
cmpb   $0x73,0x2(%rbx)
je     11d4 <userFileOverwrite+0x94>
jmp    11d2 <userFileOverwrite+0x92>
cmpb   $0x79,(%rbx)
sete   %al
jmp    11d4 <userFileOverwrite+0x94>
cmpb   $0x45,0x1(%rbx)
jne    11d2 <userFileOverwrite+0x92>
cmpb   $0x53,0x2(%rbx)
jmp    11c1 <userFileOverwrite+0x81>
xor    %eax,%eax
movzbl %al,%eax
add    $0x400,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [46 x i8] c"File %s already exists, overwrite? (yes/no): \00"
@stdin = global i32 0
define i32 @userFileOverwrite(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [1024 x i8]
%6 = alloca i8*
store i8* %0, i8** %2
store i32 0, i32* %3
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %2
%9 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @stdin
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%12 = call i32 @readline(i32 %10, i8* %11, i32 1024)
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
store i8* %13, i8** %6
br label %14
14: ; preds = %20, %1
%15 = load i8*, i8** %6
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = call i64 @isspace(i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = load i8*, i8** %6
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %6
br label %14
23: ; preds = %14
%24 = load i8*, i8** %6
%25 = call i32 @strlen(i8* %24)
store i32 %25, i32* %4
%26 = load i32, i32* %4
%27 = icmp eq i32 %26, 3
br i1 %27, label %28, label %68
28: ; preds = %23
%29 = load i8*, i8** %6
%30 = getelementptr inbounds i8, i8* %29, i64 0
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 121
br i1 %33, label %34, label %47
34: ; preds = %28
%35 = load i8*, i8** %6
%36 = getelementptr inbounds i8, i8* %35, i64 1
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 101
br i1 %39, label %40, label %47
40: ; preds = %34
%41 = load i8*, i8** %6
%42 = getelementptr inbounds i8, i8* %41, i64 2
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 115
br i1 %45, label %46, label %47
46: ; preds = %40
store i32 1, i32* %3
br label %67
47: ; preds = %40, %34, %28
%48 = load i8*, i8** %6
%49 = getelementptr inbounds i8, i8* %48, i64 0
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 89
br i1 %52, label %53, label %66
53: ; preds = %47
%54 = load i8*, i8** %6
%55 = getelementptr inbounds i8, i8* %54, i64 1
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 69
br i1 %58, label %59, label %66
59: ; preds = %53
%60 = load i8*, i8** %6
%61 = getelementptr inbounds i8, i8* %60, i64 2
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %63, 83
br i1 %64, label %65, label %66
65: ; preds = %59
store i32 1, i32* %3
br label %66
66: ; preds = %65, %59, %53, %47
br label %67
67: ; preds = %66, %46
br label %80
68: ; preds = %23
%69 = load i32, i32* %4
%70 = icmp eq i32 %69, 1
br i1 %70, label %71, label %79
71: ; preds = %68
%72 = load i8*, i8** %6
%73 = getelementptr inbounds i8, i8* %72, i64 0
%74 = load i8, i8* %73
%75 = sext i8 %74 to i32
%76 = icmp eq i32 %75, 121
br i1 %76, label %77, label %78
77: ; preds = %71
store i32 1, i32* %3
br label %78
78: ; preds = %77, %71
br label %79
79: ; preds = %78, %68
br label %80
80: ; preds = %79, %67
%81 = load i32, i32* %3
ret i32 %81
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [46 x i8] c"File %s already exists, overwrite? (yes/no): \00"
@stdin = global i32 0
define i32 @userFileOverwrite(i8* %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = load i32, i32* @stdin
%7 = call i32 @readline(i32 %6, i8* %3, i32 1024)
br label %8
8: ; preds = %8, %1
%9 = phi i8* [ %3, %1 ], [ %14, %8 ]
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = call i64 @isspace(i32 %11)
%13 = icmp eq i64 %12, 0
%14 = getelementptr inbounds i8, i8* %9, i64 1
br i1 %13, label %15, label %8
15: ; preds = %8
%16 = call i32 @strlen(i8* %9)
switch i32 %16, label %37 [
i32 3, label %17
i32 1, label %34
]
17: ; preds = %15
%18 = load i8, i8* %9
switch i8 %18, label %37 [
i8 121, label %19
i8 89, label %27
]
19: ; preds = %17
%20 = load i8, i8* %14
%21 = icmp eq i8 %20, 101
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = getelementptr inbounds i8, i8* %9, i64 2
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 115
br i1 %25, label %37, label %26
26: ; preds = %22, %19
br label %37
27: ; preds = %17
%28 = load i8, i8* %14
%29 = icmp eq i8 %28, 69
br i1 %29, label %30, label %37
30: ; preds = %27
%31 = getelementptr inbounds i8, i8* %9, i64 2
%32 = load i8, i8* %31
%33 = icmp eq i8 %32, 83
br label %37
34: ; preds = %15
%35 = load i8, i8* %9
%36 = icmp eq i8 %35, 121
br label %37
37: ; preds = %17, %26, %34, %30, %15, %22, %27
%38 = phi i1 [ false, %27 ], [ true, %22 ], [ %33, %30 ], [ false, %15 ], [ %36, %34 ], [ false, %26 ], [ false, %17 ]
%39 = zext i1 %38 to i32
ret i32 %39
}