#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 */
#define EOF 128
int getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int get_response(char *question) {
  int input;
  printf("%s (y/n)? ", question);
  while (1) {
    switch (input = getchar()) {
    case 'y':
    case 'Y':
      putchar('\n');
      return 0;
    case 'n':
    case 'N':
    case EOF:
      putchar('\n');
      return 1;
    default:
      printf("\nCannot understand %c, ", input);
      printf("please type y or n\n");
    }
  }
}


x86 assembly (clang, -O0):
<get_response>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    %eax,%ecx
mov    %ecx,-0x18(%rbp)
sub    $0x4e,%eax
je     11c7 <get_response+0x97>
jmp    116b <get_response+0x3b>
mov    -0x18(%rbp),%eax
sub    $0x59,%eax
je     11b1 <get_response+0x81>
jmp    117c <get_response+0x4c>
mov    -0x18(%rbp),%eax
sub    $0x6e,%eax
je     11c7 <get_response+0x97>
jmp    118d <get_response+0x5d>
mov    -0x18(%rbp),%eax
sub    $0x79,%eax
je     11b1 <get_response+0x81>
jmp    119e <get_response+0x6e>
mov    -0x18(%rbp),%eax
sub    $0x80,%eax
je     11c7 <get_response+0x97>
jmp    11dd <get_response+0xad>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x4(%rbp)
jmp    1201 <get_response+0xd1>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x1,-0x4(%rbp)
jmp    1201 <get_response+0xd1>
mov    -0x14(%rbp),%esi
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    114e <get_response+0x1e>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_response>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rsi
lea    0xf51(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf4e(%rip),%r14
lea    0xf5f(%rip),%r15
lea    0xe95(%rip),%rbx
jmp    1189 <get_response+0x49>
nopl   (%rax)
cmp    $0x4e,%eax
je     11a5 <get_response+0x65>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
lea    -0x59(%rax),%ecx
cmp    $0x27,%ecx
ja     1170 <get_response+0x30>
movslq (%rbx,%rcx,4),%rcx
add    %rbx,%rcx
jmp    *%rcx
xor    %ebx,%ebx
jmp    11aa <get_response+0x6a>
mov    $0x1,%ebx
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%s (y/n)? \00"
@.str.1 = [24 x i8] c"\0ACannot understand %c, \00"
@.str.2 = [20 x i8] c"please type y or n\0A\00"
define i32 @get_response(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %7
7: ; preds = %1, %17
%8 = call i32 (...) @getchar()
store i32 %8, i32* %4
switch i32 %8, label %13 [
i32 121, label %9
i32 89, label %9
i32 110, label %11
i32 78, label %11
i32 128, label %11
]
9: ; preds = %7, %7
%10 = call i32 @putchar(i8 signext 10)
store i32 0, i32* %2
br label %18
11: ; preds = %7, %7, %7
%12 = call i32 @putchar(i8 signext 10)
store i32 1, i32* %2
br label %18
13: ; preds = %7
%14 = load i32, i32* %4
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %17
17: ; preds = %13
br label %7
18: ; preds = %11, %9
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
@.str = [11 x i8] c"%s (y/n)? \00"
@.str.1 = [24 x i8] c"\0ACannot understand %c, \00"
@str = [19 x i8] c"please type y or n\00"
define i32 @get_response(i8* %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %3
3: ; preds = %5, %1
%4 = tail call i32 (...) @getchar()
switch i32 %4, label %5 [
i32 121, label %9
i32 89, label %9
i32 110, label %8
i32 78, label %8
i32 128, label %8
]
5: ; preds = %3
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %3
8: ; preds = %3, %3, %3
br label %9
9: ; preds = %3, %3, %8
%10 = phi i32 [ 1, %8 ], [ 0, %3 ], [ 0, %3 ]
%11 = tail call i32 @putchar(i8 signext 10)
ret i32 %10
}