#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
char getchar();
int /*<<< orphan*/ printf(char *, ...);
extern int get_response(char *question) {
  printf("%s (y/n)?", question);
  while (true) {
    char c = getchar();
    switch (c) {
    case 'y':
    case 'Y':
      return 0;
    case 'n':
    case 'N':
    case EOF:
      return 1;
    default:
      printf("\ncannot understand %c, ", c);
      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    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x4e,%eax
je     11af <get_response+0x8f>
jmp    115d <get_response+0x3d>
mov    -0x18(%rbp),%eax
sub    $0x59,%eax
je     11a3 <get_response+0x83>
jmp    116e <get_response+0x4e>
mov    -0x18(%rbp),%eax
sub    $0x6e,%eax
je     11af <get_response+0x8f>
jmp    117f <get_response+0x5f>
mov    -0x18(%rbp),%eax
sub    $0x79,%eax
je     11a3 <get_response+0x83>
jmp    1190 <get_response+0x70>
mov    -0x18(%rbp),%eax
sub    $0x80,%eax
je     11af <get_response+0x8f>
jmp    11bb <get_response+0x9b>
movl   $0x0,-0x4(%rbp)
jmp    11e0 <get_response+0xc0>
movl   $0x1,-0x4(%rbp)
jmp    11e0 <get_response+0xc0>
movsbl -0x11(%rbp),%esi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    113e <get_response+0x1e>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_response>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rsi
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebe(%rip),%r14
lea    0xecf(%rip),%rbx
jmp    1172 <get_response+0x42>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
movsbl %al,%esi
cmp    $0x6d,%esi
jg     1190 <get_response+0x60>
cmp    $0x4e,%esi
je     119e <get_response+0x6e>
cmp    $0x59,%esi
jne    1160 <get_response+0x30>
jmp    119a <get_response+0x6a>
nopl   (%rax)
cmp    $0x6e,%esi
je     119e <get_response+0x6e>
cmp    $0x79,%esi
jne    1160 <get_response+0x30>
xor    %eax,%eax
jmp    11a3 <get_response+0x73>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [10 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 i8
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %7
7: ; preds = %1, %18
%8 = call signext i8 (...) @getchar()
store i8 %8, i8* %4
%9 = load i8, i8* %4
%10 = sext i8 %9 to i32
switch i32 %10, label %13 [
i32 121, label %11
i32 89, label %11
i32 110, label %12
i32 78, label %12
i32 128, label %12
]
11: ; preds = %7, %7
store i32 0, i32* %2
br label %19
12: ; preds = %7, %7, %7
store i32 1, i32* %2
br label %19
13: ; preds = %7
%14 = load i8, i8* %4
%15 = sext i8 %14 to i32
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %13
br label %7
19: ; preds = %12, %11
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
@.str = [10 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 ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %3
3: ; preds = %6, %1
%4 = tail call signext i8 (...) @getchar()
%5 = sext i8 %4 to i32
switch i32 %5, label %6 [
i32 121, label %9
i32 89, label %9
i32 110, label %10
i32 78, label %10
]
6: ; preds = %3
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %3
9: ; preds = %3, %3
br label %10
10: ; preds = %3, %3, %9
%11 = phi i32 [ 0, %9 ], [ 1, %3 ], [ 1, %3 ]
ret i32 %11
}