#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 *, char *);
int /*<<< orphan*/ putchar(char);
extern int get_response(char *question) {
  printf("%s (y/n)?", question);
  while (true) {
    char c = getchar();
    switch (c) {
    case 'y':
    case 'Y':
      putchar('y');
      return 0;
    case 'n':
    case 'N':
    case EOF:
      putchar('n');
      return 1;
    }
  }
}


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
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
mov    %eax,-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    $0x79,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e2 <get_response+0xb2>
mov    $0x6e,%edi
call   1030 <putchar@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e2 <get_response+0xb2>
jmp    114c <get_response+0x1c>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_response>:
push   %rbx
mov    %rdi,%rsi
lea    0xec5(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
movsbl %al,%eax
cmp    $0x6d,%eax
jg     1160 <get_response+0x30>
cmp    $0x4e,%eax
je     116a <get_response+0x3a>
cmp    $0x59,%eax
jne    1140 <get_response+0x10>
jmp    1173 <get_response+0x43>
nopl   0x0(%rax,%rax,1)
cmp    $0x79,%eax
je     1173 <get_response+0x43>
cmp    $0x6e,%eax
jne    1140 <get_response+0x10>
mov    $0x1,%ebx
mov    $0x6e,%al
jmp    1177 <get_response+0x47>
xor    %ebx,%ebx
mov    $0x79,%al
movzbl %al,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%s (y/n)?\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 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %7
7: ; preds = %1, %15
%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 %15 [
i32 121, label %11
i32 89, label %11
i32 110, label %13
i32 78, label %13
i32 128, label %13
]
11: ; preds = %7, %7
%12 = call i32 @putchar(i8 signext 121)
store i32 0, i32* %2
br label %16
13: ; preds = %7, %7, %7
%14 = call i32 @putchar(i8 signext 110)
store i32 1, i32* %2
br label %16
15: ; preds = %7
br label %7
16: ; preds = %13, %11
%17 = load i32, i32* %2
ret i32 %17
}

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