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

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcpy(char *, char *);
int askyn(char *def) {
  char in[8];
  do {
    printf("Type y or n [%s]: ", def);
    fflush(stdout);
    fgets(in, sizeof(in), stdin);
    if (*in == '\n')
      strcpy(in, def);
  } while (*in != 'y' && *in != 'n');
  return *in == 'y';
}


x86 assembly (clang, -O0):
<askyn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xea9(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
lea    -0x10(%rbp),%rdi
mov    0x2e73(%rip),%rax
mov    (%rax),%edx
mov    $0x8,%esi
call   1050 <fgets@plt>
movsbl -0x10(%rbp),%eax
cmp    $0xa,%eax
jne    119b <askyn+0x5b>
lea    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11a0 <askyn+0x60>
movsbl -0x10(%rbp),%ecx
xor    %eax,%eax
cmp    $0x79,%ecx
mov    %al,-0x11(%rbp)
je     11bf <askyn+0x7f>
movsbl -0x10(%rbp),%eax
cmp    $0x6e,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    114c <askyn+0xc>
movsbl -0x10(%rbp),%eax
cmp    $0x79,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<askyn>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xea9(%rip),%r14
mov    0x2e7a(%rip),%r12
mov    0x2e83(%rip),%r13
lea    0x8(%rsp),%r15
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    (%r12),%edi
call   1060 <fflush@plt>
mov    0x0(%r13),%edx
mov    %r15,%rdi
mov    $0x8,%esi
call   1050 <fgets@plt>
movzbl 0x8(%rsp),%ecx
cmp    $0xa,%cl
jne    11af <askyn+0x6f>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
movzbl 0x8(%rsp),%ecx
cmp    $0x79,%cl
je     11b9 <askyn+0x79>
cmp    $0x6e,%cl
jne    1170 <askyn+0x30>
xor    %eax,%eax
cmp    $0x79,%cl
sete   %al
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [19 x i8] c"Type y or n [%s]: \00"
@stdout = global i32 0
@stdin = global i32 0
define i32 @askyn(i8* %0) {
%2 = alloca [8 x i8]
%3 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %15, %1
%5 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = load i32, i32* @stdout
%7 = call i32 @fflush(i32 %6)
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %3, i32 8, i32 %8)
%10 = load i8, i8* %3
%11 = icmp eq i8 %10, 10
br i1 %11, label %12, label %15
12: ; preds = %4
%13 = call i32 @strcpy(i8* %3, i8* %0)
%14 = load i8, i8* %3
br label %15
15: ; preds = %4, %12
%16 = phi i8 [ %10, %4 ], [ %14, %12 ]
switch i8 %16, label %4 [
i8 121, label %17
i8 110, label %17
]
17: ; preds = %15, %15
%18 = icmp eq i8 %16, 121
%19 = zext i1 %18 to i32
ret i32 %19
}