#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 getch();
char getchar();
int /*<<< orphan*/ printf(char *);
char get_answer() {
  int i = 0;
  char exit = 0;
  char symb = 0;
  while ((symb = getch()) == '\t' && symb == ' ' && symb == '\n')
    ;
  while (exit == 0) {
    if ((symb >= '0' && symb <= '9') || symb == -1) {
      exit = 1;
    } else {
      printf("Wrong input (for exit press Ctrl+D). Try again.\n");
      symb = getchar();
    }
  };
  if (symb == -1) {
    return 'e';
  } else {
    return symb;
  };
}


x86 assembly (clang, -O0):
<get_answer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
movb   $0x0,-0x9(%rbp)
movb   $0x0,-0xa(%rbp)
mov    $0x0,%al
call   1050 <getch@plt>
mov    %al,-0xa(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0x9,%ecx
mov    %al,-0xb(%rbp)
jne    1181 <get_answer+0x51>
movsbl -0xa(%rbp),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0xb(%rbp)
jne    1181 <get_answer+0x51>
movsbl -0xa(%rbp),%eax
cmp    $0xa,%eax
sete   %al
mov    %al,-0xb(%rbp)
mov    -0xb(%rbp),%al
test   $0x1,%al
jne    1191 <get_answer+0x61>
jmp    1196 <get_answer+0x66>
jmp    1147 <get_answer+0x17>
jmp    119b <get_answer+0x6b>
movsbl -0x9(%rbp),%eax
cmp    $0x0,%eax
jne    11f3 <get_answer+0xc3>
movsbl -0xa(%rbp),%eax
cmp    $0x30,%eax
jl     11c2 <get_answer+0x92>
movsbl -0xa(%rbp),%eax
cmp    $0x39,%eax
jle    11cf <get_answer+0x9f>
movsbl -0xa(%rbp),%eax
cmp    $0xffffffff,%eax
jne    11d8 <get_answer+0xa8>
movb   $0x1,-0x9(%rbp)
jmp    11ee <get_answer+0xbe>
lea    0xe21(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0xa(%rbp)
jmp    119b <get_answer+0x6b>
movsbl -0xa(%rbp),%eax
cmp    $0xffffffff,%eax
jne    1209 <get_answer+0xd9>
movb   $0x65,-0x1(%rbp)
jmp    120f <get_answer+0xdf>
mov    -0xa(%rbp),%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_answer>:
push   %rbx
xor    %eax,%eax
call   1050 <getch@plt>
cmp    $0xff,%al
je     116d <get_answer+0x3d>
mov    %eax,%ecx
add    $0xd0,%cl
cmp    $0xa,%cl
jb     116d <get_answer+0x3d>
lea    0xeb3(%rip),%rbx
nopl   (%rax)
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xff,%al
je     116d <get_answer+0x3d>
mov    %eax,%ecx
add    $0xd0,%cl
cmp    $0x9,%cl
ja     1150 <get_answer+0x20>
cmp    $0xff,%al
movzbl %al,%ecx
mov    $0x65,%eax
cmovne %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [49 x i8] c"Wrong input (for exit press Ctrl+D). Try again.\0A\00"
define signext i8 @get_answer() {
%1 = alloca i8
%2 = alloca i32
%3 = alloca i8
%4 = alloca i8
store i32 0, i32* %2
store i8 0, i8* %3
store i8 0, i8* %4
br label %5
5: ; preds = %19, %0
%6 = call signext i8 (...) @getch()
store i8 %6, i8* %4
%7 = sext i8 %6 to i32
%8 = icmp eq i32 %7, 9
br i1 %8, label %9, label %17
9: ; preds = %5
%10 = load i8, i8* %4
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 32
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = load i8, i8* %4
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 10
br label %17
17: ; preds = %13, %9, %5
%18 = phi i1 [ false, %9 ], [ false, %5 ], [ %16, %13 ]
br i1 %18, label %19, label %20
19: ; preds = %17
br label %5
20: ; preds = %17
br label %21
21: ; preds = %41, %20
%22 = load i8, i8* %3
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %42
25: ; preds = %21
%26 = load i8, i8* %4
%27 = sext i8 %26 to i32
%28 = icmp sge i32 %27, 48
br i1 %28, label %29, label %33
29: ; preds = %25
%30 = load i8, i8* %4
%31 = sext i8 %30 to i32
%32 = icmp sle i32 %31, 57
br i1 %32, label %37, label %33
33: ; preds = %29, %25
%34 = load i8, i8* %4
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %38
37: ; preds = %33, %29
store i8 1, i8* %3
br label %41
38: ; preds = %33
%39 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%40 = call signext i8 (...) @getchar()
store i8 %40, i8* %4
br label %41
41: ; preds = %38, %37
br label %21
42: ; preds = %21
%43 = load i8, i8* %4
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %47
46: ; preds = %42
store i8 101, i8* %1
br label %49
47: ; preds = %42
%48 = load i8, i8* %4
store i8 %48, i8* %1
br label %49
49: ; preds = %47, %46
%50 = load i8, i8* %1
ret i8 %50
}

LLVM IR (-O2):
@str = [48 x i8] c"Wrong input (for exit press Ctrl+D). Try again.\00"
define signext i8 @get_answer() {
%1 = tail call signext i8 (...) @getch()
%2 = add i8 %1, -48
%3 = icmp ult i8 %2, 10
%4 = icmp eq i8 %1, -1
%5 = or i1 %4, %3
br i1 %5, label %13, label %6
6: ; preds = %0, %6
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
%8 = tail call signext i8 (...) @getchar()
%9 = add i8 %8, -48
%10 = icmp ult i8 %9, 10
%11 = icmp eq i8 %8, -1
%12 = or i1 %11, %10
br i1 %12, label %13, label %6
13: ; preds = %6, %0
%14 = phi i8 [ %1, %0 ], [ %8, %6 ]
%15 = icmp eq i8 %14, -1
%16 = select i1 %15, i8 101, i8 %14
ret i8 %16
}