#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 *, char *);
char getchar();
int /*<<< orphan*/ printf(char *, char const *, char *);
int /*<<< orphan*/ stderr;
bool confirm(const char *question, int def, bool noconfirm) {
  (void)(0);
  char c = ' ';
  if (noconfirm) {
    printf("%s [%s] .\n", question, def ? "Y/n" : "y/N");
  } else {
    fprintf(stderr, "%s [%s] ", question, def ? "Y/n" : "y/N");
    c = getchar();
  }
  if (def)
    switch (c) {
    case 'n':
    case 'N':
    case 'q':
    case 'Q':
      return false;
    default:
      return true;
    }
  else
    switch (c) {
    case 'y':
    case 'Y':
      return true;
    default:
      return false;
    }
}


x86 assembly (clang, -O0):
<confirm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
movb   $0x20,-0x19(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     117d <confirm+0x4d>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%ecx
lea    0xeb1(%rip),%rdx
lea    0xea6(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
jmp    11b8 <confirm+0x88>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%esi
lea    0xe7b(%rip),%rcx
lea    0xe70(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%rcx
lea    0xe6a(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x19(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1222 <confirm+0xf2>
movsbl -0x19(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x4e,%eax
je     120a <confirm+0xda>
jmp    11d7 <confirm+0xa7>
mov    -0x20(%rbp),%eax
sub    $0x51,%eax
je     120a <confirm+0xda>
jmp    11e8 <confirm+0xb8>
mov    -0x20(%rbp),%eax
sub    $0x6e,%eax
je     120a <confirm+0xda>
jmp    11f9 <confirm+0xc9>
mov    -0x20(%rbp),%eax
sub    $0x71,%eax
jne    1216 <confirm+0xe6>
jmp    120a <confirm+0xda>
movl   $0x0,-0x4(%rbp)
jmp    124a <confirm+0x11a>
movl   $0x1,-0x4(%rbp)
jmp    124a <confirm+0x11a>
movsbl -0x19(%rbp),%eax
or     $0x20,%eax
sub    $0x79,%eax
je     1237 <confirm+0x107>
jmp    1243 <confirm+0x113>
movl   $0x1,-0x4(%rbp)
jmp    124a <confirm+0x11a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<confirm>:
push   %rbx
mov    %esi,%ebx
mov    %rdi,%rax
test   %edx,%edx
je     1182 <confirm+0x52>
test   %ebx,%ebx
lea    0xecc(%rip),%rcx
lea    0xec1(%rip),%rdx
cmove  %rcx,%rdx
lea    0xeab(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    $0x20,%ecx
test   %ebx,%ebx
je     11bc <confirm+0x8c>
add    $0xffffffb2,%ecx
cmp    $0x23,%ecx
ja     11c9 <confirm+0x99>
xor    %eax,%eax
movabs $0x900000009,%rdx
bt     %rcx,%rdx
jae    11c9 <confirm+0x99>
pop    %rbx
ret
mov    0x2e57(%rip),%rcx
mov    (%rcx),%edi
test   %ebx,%ebx
lea    0xe7b(%rip),%rdx
lea    0xe70(%rip),%rcx
cmove  %rdx,%rcx
lea    0xe6d(%rip),%rsi
mov    %rax,%rdx
call   1050 <fprintf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
movsbl %al,%ecx
test   %ebx,%ebx
jne    1166 <confirm+0x36>
and    $0xffffffdf,%ecx
xor    %eax,%eax
cmp    $0x59,%ecx
sete   %al
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%s [%s] .\0A\00"
@.str.1 = [4 x i8] c"Y/n\00"
@.str.2 = [4 x i8] c"y/N\00"
@stderr = global i32 0
@.str.3 = [9 x i8] c"%s [%s] \00"
define i32 @confirm(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8 32, i8* %8
%9 = load i32, i32* %7
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %3
%12 = load i8*, i8** %5
%13 = load i32, i32* %6
%14 = icmp ne i32 %13, 0
%15 = zext i1 %14 to i64
%16 = select i1 %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%17 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %12, i8* %16)
br label %27
18: ; preds = %3
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %5
%21 = load i32, i32* %6
%22 = icmp ne i32 %21, 0
%23 = zext i1 %22 to i64
%24 = select i1 %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%25 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %20, i8* %24)
%26 = call signext i8 (...) @getchar()
store i8 %26, i8* %8
br label %27
27: ; preds = %18, %11
%28 = load i32, i32* %6
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = load i8, i8* %8
%32 = sext i8 %31 to i32
switch i32 %32, label %34 [
i32 110, label %33
i32 78, label %33
i32 113, label %33
i32 81, label %33
]
33: ; preds = %30, %30, %30, %30
store i32 0, i32* %4
br label %40
34: ; preds = %30
store i32 1, i32* %4
br label %40
35: ; preds = %27
%36 = load i8, i8* %8
%37 = sext i8 %36 to i32
switch i32 %37, label %39 [
i32 121, label %38
i32 89, label %38
]
38: ; preds = %35, %35
store i32 1, i32* %4
br label %40
39: ; preds = %35
store i32 0, i32* %4
br label %40
40: ; preds = %39, %38, %34, %33
%41 = load i32, i32* %4
ret i32 %41
}

LLVM IR (-O2):
@.str = [11 x i8] c"%s [%s] .\0A\00"
@.str.1 = [4 x i8] c"Y/n\00"
@.str.2 = [4 x i8] c"y/N\00"
@stderr = global i32 0
@.str.3 = [9 x i8] c"%s [%s] \00"
define i32 @confirm(i8* %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %9, label %5
5: ; preds = %3
%6 = icmp eq i32 %1, 0
%7 = select i1 %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %7)
br label %16
9: ; preds = %3
%10 = load i32, i32* @stderr
%11 = icmp eq i32 %1, 0
%12 = select i1 %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0)
%13 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %0, i8* %12)
%14 = tail call signext i8 (...) @getchar()
%15 = sext i8 %14 to i32
br label %16
16: ; preds = %9, %5
%17 = phi i32 [ 32, %5 ], [ %15, %9 ]
%18 = icmp eq i32 %1, 0
br i1 %18, label %21, label %19
19: ; preds = %16
switch i32 %17, label %20 [
i32 110, label %25
i32 78, label %25
i32 113, label %25
i32 81, label %25
]
20: ; preds = %19
br label %25
21: ; preds = %16
%22 = and i32 %17, -33
%23 = icmp eq i32 %22, 89
%24 = zext i1 %23 to i32
br label %25
25: ; preds = %21, %19, %19, %19, %19, %20
%26 = phi i32 [ 1, %20 ], [ 0, %19 ], [ 0, %19 ], [ 0, %19 ], [ 0, %19 ], [ %24, %21 ]
ret i32 %26
}