#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 */
char getchar();
int /*<<< orphan*/ printf(char *, char *, char *);
int prompt(char *to) {
  printf("%s: %s exists. Overwrite ('y' or 'n')? ", "mv", to);
  char response;
  do {
    response = getchar();
  } while (response == '\n');
  if (response == 'y' || response == 'Y') {
    return 1;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<prompt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdx
lea    0xec9(%rip),%rdi
lea    0xeea(%rip),%rsi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0xa,%eax
je     1143 <prompt+0x23>
movsbl -0x11(%rbp),%eax
cmp    $0x79,%eax
je     1174 <prompt+0x54>
movsbl -0x11(%rbp),%eax
cmp    $0x59,%eax
jne    1180 <prompt+0x60>
movl   $0x1,-0x4(%rbp)
jmp    1187 <prompt+0x67>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prompt>:
push   %rax
mov    %rdi,%rdx
lea    0xed5(%rip),%rdi
lea    0xef6(%rip),%rsi
call   1030 <printf@plt>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
je     1140 <prompt+0x20>
and    $0xdf,%al
xor    %ecx,%ecx
cmp    $0x59,%al
sete   %cl
mov    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [40 x i8] c"%s: %s exists. Overwrite ('y' or 'n')? \00"
@.str.1 = [3 x i8] c"mv\00"
define i32 @prompt(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
br label %7
7: ; preds = %9, %1
%8 = call signext i8 (...) @getchar()
store i8 %8, i8* %4
br label %9
9: ; preds = %7
%10 = load i8, i8* %4
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 10
br i1 %12, label %7, label %13
13: ; preds = %9
%14 = load i8, i8* %4
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 121
br i1 %16, label %21, label %17
17: ; preds = %13
%18 = load i8, i8* %4
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 89
br i1 %20, label %21, label %22
21: ; preds = %17, %13
store i32 1, i32* %2
br label %23
22: ; preds = %17
store i32 0, i32* %2
br label %23
23: ; preds = %22, %21
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@.str = [40 x i8] c"%s: %s exists. Overwrite ('y' or 'n')? \00"
@.str.1 = [3 x i8] c"mv\00"
define i32 @prompt(i8* %0) {
%2 = tail call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %3
3: ; preds = %3, %1
%4 = tail call signext i8 (...) @getchar()
%5 = icmp eq i8 %4, 10
br i1 %5, label %3, label %6
6: ; preds = %3
%7 = and i8 %4, -33
%8 = icmp eq i8 %7, 89
%9 = zext i1 %8 to i32
ret i32 %9
}