#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 *);
bool ask_user_cancel() {
  char c = -1;
  do {
    printf("Really cancel? y/n\n> ");
    c = getchar();
    getchar();
    if (c == 'y' || c == 'Y') {
      return true;
    }
    if (c == 'n' || c == 'N') {
      continue;
    }
  } while (c != 'n' && c != 'N');
  return false;
}


x86 assembly (clang, -O0):
<ask_user_cancel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movb   $0xff,-0x5(%rbp)
lea    0xecd(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x79,%eax
je     1163 <ask_user_cancel+0x43>
movsbl -0x5(%rbp),%eax
cmp    $0x59,%eax
jne    116f <ask_user_cancel+0x4f>
movl   $0x1,-0x4(%rbp)
jmp    11c4 <ask_user_cancel+0xa4>
movsbl -0x5(%rbp),%eax
cmp    $0x6e,%eax
je     1189 <ask_user_cancel+0x69>
movsbl -0x5(%rbp),%eax
cmp    $0x4e,%eax
jne    118e <ask_user_cancel+0x6e>
jmp    1193 <ask_user_cancel+0x73>
jmp    1193 <ask_user_cancel+0x73>
movsbl -0x5(%rbp),%ecx
xor    %eax,%eax
cmp    $0x6e,%ecx
mov    %al,-0x6(%rbp)
je     11b2 <ask_user_cancel+0x92>
movsbl -0x5(%rbp),%eax
cmp    $0x4e,%eax
setne  %al
mov    %al,-0x6(%rbp)
mov    -0x6(%rbp),%al
test   $0x1,%al
jne    112c <ask_user_cancel+0xc>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ask_user_cancel>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
and    $0xdf,%bl
cmp    $0x4e,%bl
je     115c <ask_user_cancel+0x3c>
cmp    $0x59,%bl
jne    1130 <ask_user_cancel+0x10>
mov    $0x1,%eax
jmp    115e <ask_user_cancel+0x3e>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Really cancel? y/n\0A> \00"
define i32 @ask_user_cancel() {
%1 = alloca i32
%2 = alloca i8
store i8 -1, i8* %2
br label %3
3: ; preds = %33, %0
%4 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%5 = call signext i8 (...) @getchar()
store i8 %5, i8* %2
%6 = call signext i8 (...) @getchar()
%7 = load i8, i8* %2
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 121
br i1 %9, label %14, label %10
10: ; preds = %3
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 89
br i1 %13, label %14, label %15
14: ; preds = %10, %3
store i32 1, i32* %1
br label %36
15: ; preds = %10
%16 = load i8, i8* %2
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 110
br i1 %18, label %23, label %19
19: ; preds = %15
%20 = load i8, i8* %2
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 78
br i1 %22, label %23, label %24
23: ; preds = %19, %15
br label %25
24: ; preds = %19
br label %25
25: ; preds = %24, %23
%26 = load i8, i8* %2
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 110
br i1 %28, label %29, label %33
29: ; preds = %25
%30 = load i8, i8* %2
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 78
br label %33
33: ; preds = %29, %25
%34 = phi i1 [ false, %25 ], [ %32, %29 ]
br i1 %34, label %3, label %35
35: ; preds = %33
store i32 0, i32* %1
br label %36
36: ; preds = %35, %14
%37 = load i32, i32* %1
ret i32 %37
}

LLVM IR (-O2):
@.str = [22 x i8] c"Really cancel? y/n\0A> \00"
define i32 @ask_user_cancel() {
br label %1
1: ; preds = %1, %0
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%3 = tail call signext i8 (...) @getchar()
%4 = tail call signext i8 (...) @getchar()
%5 = and i8 %3, -33
switch i8 %5, label %1 [
i8 89, label %6
i8 78, label %7
]
6: ; preds = %1
br label %7
7: ; preds = %1, %6
%8 = phi i32 [ 1, %6 ], [ 0, %1 ]
ret i32 %8
}