#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
char get_only_char() {
  char n;
  char ch = '&';
  printf("%s", "");
  scanf("%c", &n);
  char f;
  f = getchar();
  while ((n != 'n' && n != 'y') || f != '\n') {
    if (f == '\n') {
      printf("Invalid [y/n]:");
      scanf("%c", &n);
      f = getchar();
    } else {
      printf("Invalid [y/n]:");
      while ((ch = getchar()) != '\n')
        ;
      scanf("%c", &n);
      f = getchar();
    }
  }
  return n;
}


x86 assembly (clang, -O0):
<get_only_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movb   $0x26,-0x2(%rbp)
lea    0xebd(%rip),%rdi
lea    0xeca(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeab(%rip),%rdi
lea    -0x1(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x3(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0x6e,%eax
je     118a <get_only_char+0x5a>
movsbl -0x1(%rbp),%ecx
mov    $0x1,%al
cmp    $0x79,%ecx
mov    %al,-0x4(%rbp)
jne    1197 <get_only_char+0x67>
movsbl -0x3(%rbp),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x4(%rbp)
mov    -0x4(%rbp),%al
test   $0x1,%al
jne    11a7 <get_only_char+0x77>
jmp    1229 <get_only_char+0xf9>
movsbl -0x3(%rbp),%eax
cmp    $0xa,%eax
jne    11e1 <get_only_char+0xb1>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe3a(%rip),%rdi
lea    -0x1(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x3(%rbp)
jmp    1224 <get_only_char+0xf4>
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x2(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     120a <get_only_char+0xda>
jmp    11ef <get_only_char+0xbf>
lea    0xdf2(%rip),%rdi
lea    -0x1(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x3(%rbp)
jmp    116b <get_only_char+0x3b>
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_only_char>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xec1(%rip),%rdi
lea    0x7(%rsp),%rsi
call   1050 <scanf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%ebx
mov    0x7(%rsp),%al
cmp    $0x6e,%al
setne  %cl
cmp    $0x79,%al
setne  %dl
cmp    $0xa,%bl
jne    1169 <get_only_char+0x39>
and    %dl,%cl
je     11c8 <get_only_char+0x98>
lea    0xe93(%rip),%r14
lea    0xe89(%rip),%r15
lea    0x7(%rsp),%r12
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0xa,%bl
je     119b <get_only_char+0x6b>
nop
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
jne    1190 <get_only_char+0x60>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%ebx
mov    0x7(%rsp),%al
cmp    $0x6e,%al
setne  %dl
cmp    $0x79,%al
setne  %cl
and    %dl,%cl
cmp    $0xa,%bl
jne    1180 <get_only_char+0x50>
test   %cl,%cl
jne    1180 <get_only_char+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [15 x i8] c"Invalid [y/n]:\00"
define signext i8 @get_only_char() {
%1 = alloca i8
%2 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%3 = call signext i8 (...) @getchar()
%4 = load i8, i8* %1
%5 = icmp ne i8 %4, 110
%6 = icmp ne i8 %4, 121
%7 = and i1 %5, %6
%8 = icmp ne i8 %3, 10
%9 = or i1 %8, %7
br i1 %9, label %10, label %26
10: ; preds = %0, %17
%11 = phi i8 [ %19, %17 ], [ %3, %0 ]
%12 = icmp eq i8 %11, 10
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br i1 %12, label %17, label %14
14: ; preds = %10, %14
%15 = call signext i8 (...) @getchar()
%16 = icmp eq i8 %15, 10
br i1 %16, label %17, label %14
17: ; preds = %14, %10
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%19 = call signext i8 (...) @getchar()
%20 = load i8, i8* %1
%21 = icmp ne i8 %20, 110
%22 = icmp ne i8 %20, 121
%23 = and i1 %21, %22
%24 = icmp ne i8 %19, 10
%25 = or i1 %24, %23
br i1 %25, label %10, label %26
26: ; preds = %17, %0
%27 = phi i8 [ %4, %0 ], [ %20, %17 ]
ret i8 %27
}