#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
bool overwrite_file_message(char *file_name) {
  char answer;
  printf("Do you want to overwrite file %s ? [Y/N] ", file_name);
scan_for_answer:
  scanf("%c", &answer);
  if (answer == 'Y' || answer == 'y') {
    return true;
  } else if (answer == 'N' || answer == 'n') {
    return false;
  } else {
    printf("You can only answer with Y or N. Try again: ");
    goto scan_for_answer;
  }
}


x86 assembly (clang, -O0):
<overwrite_file_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
lea    -0x11(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x11(%rbp),%eax
cmp    $0x59,%eax
je     1168 <overwrite_file_message+0x48>
movsbl -0x11(%rbp),%eax
cmp    $0x79,%eax
jne    1174 <overwrite_file_message+0x54>
movl   $0x1,-0x4(%rbp)
jmp    11ad <overwrite_file_message+0x8d>
movsbl -0x11(%rbp),%eax
cmp    $0x4e,%eax
je     118e <overwrite_file_message+0x6e>
movsbl -0x11(%rbp),%eax
cmp    $0x6e,%eax
jne    119a <overwrite_file_message+0x7a>
movl   $0x0,-0x4(%rbp)
jmp    11ad <overwrite_file_message+0x8d>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    113e <overwrite_file_message+0x1e>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<overwrite_file_message>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rsi
lea    0xecd(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee9(%rip),%r14
lea    0xf(%rsp),%rbx
lea    0xee0(%rip),%r15
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movzbl 0xf(%rsp),%eax
and    $0xdf,%al
cmp    $0x4e,%al
je     1176 <overwrite_file_message+0x56>
cmp    $0x59,%al
je     117a <overwrite_file_message+0x5a>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1150 <overwrite_file_message+0x30>
xor    %eax,%eax
jmp    117f <overwrite_file_message+0x5f>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Do you want to overwrite file %s ? [Y/N] \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [45 x i8] c"You can only answer with Y or N. Try again: \00"
define i32 @overwrite_file_message(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %7
7: ; preds = %26, %1
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%9 = load i8, i8* %4
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 89
br i1 %11, label %16, label %12
12: ; preds = %7
%13 = load i8, i8* %4
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 121
br i1 %15, label %16, label %17
16: ; preds = %12, %7
store i32 1, i32* %2
br label %28
17: ; preds = %12
%18 = load i8, i8* %4
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 78
br i1 %20, label %25, label %21
21: ; preds = %17
%22 = load i8, i8* %4
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 110
br i1 %24, label %25, label %26
25: ; preds = %21, %17
store i32 0, i32* %2
br label %28
26: ; preds = %21
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
br label %7
28: ; preds = %25, %16
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@.str = [42 x i8] c"Do you want to overwrite file %s ? [Y/N] \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [45 x i8] c"You can only answer with Y or N. Try again: \00"
define i32 @overwrite_file_message(i8* %0) {
%2 = alloca i8
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %4
4: ; preds = %8, %1
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%6 = load i8, i8* %2
%7 = and i8 %6, -33
switch i8 %7, label %8 [
i8 89, label %10
i8 78, label %11
]
8: ; preds = %4
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
br label %4
10: ; preds = %4
br label %11
11: ; preds = %4, %10
%12 = phi i32 [ 1, %10 ], [ 0, %4 ]
ret i32 %12
}