#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*/ buf;

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
char toupper(char);
int console_prompt_abort(const char *message) {
  char buf[32];
  for (;;) {
    printf("%s ", message);
    fflush(stdout);
    if (!fgets(buf, sizeof(buf), stdin)) {
      printf("\n");
      return 1;
    }
    if (toupper(buf[0]) == 'Y')
      return 0;
    if (toupper(buf[0]) == 'N')
      return 1;
    printf("Please answer \"y\" or \"n\".\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<console_prompt_abort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
lea    -0x30(%rbp),%rdi
mov    0x2e71(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   1050 <fgets@plt>
cmp    $0x0,%eax
jne    11a6 <console_prompt_abort+0x66>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11fb <console_prompt_abort+0xbb>
movsbl -0x30(%rbp),%edi
call   1030 <toupper@plt>
movsbl %al,%eax
cmp    $0x59,%eax
jne    11c7 <console_prompt_abort+0x87>
movl   $0x0,-0x4(%rbp)
jmp    11fb <console_prompt_abort+0xbb>
movsbl -0x30(%rbp),%edi
call   1030 <toupper@plt>
movsbl %al,%eax
cmp    $0x4e,%eax
jne    11e8 <console_prompt_abort+0xa8>
movl   $0x1,-0x4(%rbp)
jmp    11fb <console_prompt_abort+0xbb>
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    114c <console_prompt_abort+0xc>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<console_prompt_abort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%rbx
lea    0xe88(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e4f(%rip),%r13
mov    0x0(%r13),%edi
call   1080 <fflush@plt>
mov    0x2e4f(%rip),%r14
mov    (%r14),%edx
mov    %rsp,%rdi
mov    $0x20,%esi
call   1070 <fgets@plt>
test   %eax,%eax
je     120c <console_prompt_abort+0xac>
lea    0xe50(%rip),%r15
lea    0xe45(%rip),%r12
mov    %rsp,%rbp
xchg   %ax,%ax
movsbl (%rsp),%edi
call   1040 <toupper@plt>
cmp    $0x59,%al
je     121d <console_prompt_abort+0xbd>
movsbl (%rsp),%edi
call   1040 <toupper@plt>
cmp    $0x4e,%al
je     1216 <console_prompt_abort+0xb6>
mov    %r15,%rdi
call   1050 <puts@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x0(%r13),%edi
call   1080 <fflush@plt>
mov    (%r14),%edx
mov    %rbp,%rdi
mov    $0x20,%esi
call   1070 <fgets@plt>
test   %eax,%eax
jne    11c0 <console_prompt_abort+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%eax
jmp    121f <console_prompt_abort+0xbf>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s \00"
@stdout = global i32 0
@stdin = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [27 x i8] c"Please answer \22y\22 or \22n\22.\0A\00"
define i32 @console_prompt_abort(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [32 x i8]
store i8* %0, i8** %3
br label %5
5: ; preds = %30, %1
%6 = load i8*, i8** %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @stdout
%9 = call i32 @fflush(i32 %8)
%10 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %10, i32 32, i32 %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %5
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %2
br label %32
16: ; preds = %5
%17 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%18 = load i8, i8* %17
%19 = call signext i8 @toupper(i8 signext %18)
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 89
br i1 %21, label %22, label %23
22: ; preds = %16
store i32 0, i32* %2
br label %32
23: ; preds = %16
%24 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%25 = load i8, i8* %24
%26 = call signext i8 @toupper(i8 signext %25)
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 78
br i1 %28, label %29, label %30
29: ; preds = %23
store i32 1, i32* %2
br label %32
30: ; preds = %23
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %5
32: ; preds = %29, %22, %14
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s \00"
@stdout = global i32 0
@stdin = global i32 0
@str = [26 x i8] c"Please answer \22y\22 or \22n\22.\00"
define i32 @console_prompt_abort(i8* %0) {
%2 = alloca [32 x i8]
%3 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = load i32, i32* @stdout
%6 = call i32 @fflush(i32 %5)
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %3, i32 32, i32 %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %20, %1
%11 = call i32 @putchar(i32 10)
br label %28
12: ; preds = %1, %20
%13 = load i8, i8* %3
%14 = call signext i8 @toupper(i8 signext %13)
%15 = icmp eq i8 %14, 89
br i1 %15, label %28, label %16
16: ; preds = %12
%17 = load i8, i8* %3
%18 = call signext i8 @toupper(i8 signext %17)
%19 = icmp eq i8 %18, 78
br i1 %19, label %28, label %20
20: ; preds = %16
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
%23 = load i32, i32* @stdout
%24 = call i32 @fflush(i32 %23)
%25 = load i32, i32* @stdin
%26 = call i32 @fgets(i8* %3, i32 32, i32 %25)
%27 = icmp eq i32 %26, 0
br i1 %27, label %10, label %12
28: ; preds = %16, %12, %10
%29 = phi i32 [ 1, %10 ], [ 1, %16 ], [ 0, %12 ]
ret i32 %29
}