#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 */
int /*<<< orphan*/ flushinp();
int getch();
int /*<<< orphan*/ printw(char *, ...);
int /*<<< orphan*/ refresh();
int get_one(void) {
  int input, choice = 0, character = 0;
  while ((input = getch()) != '\n') {
    if (((input == 8) || (input == 127)) && (character == 0)) {
      refresh();
    } else if ((input == 8) || (input == 127)) {
      printw("%c", 8);
      printw(" ");
      printw("%c", 8);
      character--;
      refresh();
    } else if (character >= 1) {
      refresh();
    } else if (input == '\33') {
      flushinp();
      refresh();
    } else {
      printw("%c", input);
      choice = input;
      character++;
      refresh();
    }
  }
  return choice;
}


x86 assembly (clang, -O0):
<get_one>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1050 <getch@plt>
mov    %eax,-0x4(%rbp)
cmp    $0xa,%eax
je     125e <get_one+0x11e>
cmpl   $0x8,-0x4(%rbp)
je     117d <get_one+0x3d>
cmpl   $0x7f,-0x4(%rbp)
jne    1193 <get_one+0x53>
cmpl   $0x0,-0xc(%rbp)
jne    1193 <get_one+0x53>
mov    $0x0,%al
call   1040 <refresh@plt>
jmp    1259 <get_one+0x119>
cmpl   $0x8,-0x4(%rbp)
je     11a7 <get_one+0x67>
cmpl   $0x7f,-0x4(%rbp)
jne    11f0 <get_one+0xb0>
lea    0xe52(%rip),%rdi
mov    $0x8,%esi
mov    $0x0,%al
call   1030 <printw@plt>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printw@plt>
lea    0xe31(%rip),%rdi
mov    $0x8,%esi
mov    $0x0,%al
call   1030 <printw@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1040 <refresh@plt>
jmp    1254 <get_one+0x114>
cmpl   $0x1,-0xc(%rbp)
jl     1206 <get_one+0xc6>
mov    $0x0,%al
call   1040 <refresh@plt>
jmp    124f <get_one+0x10f>
cmpl   $0x1b,-0x4(%rbp)
jne    1223 <get_one+0xe3>
mov    $0x0,%al
call   1060 <flushinp@plt>
mov    $0x0,%al
call   1040 <refresh@plt>
jmp    124a <get_one+0x10a>
mov    -0x4(%rbp),%esi
lea    0xdd3(%rip),%rdi
mov    $0x0,%al
call   1030 <printw@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1040 <refresh@plt>
jmp    124f <get_one+0x10f>
jmp    1254 <get_one+0x114>
jmp    1259 <get_one+0x119>
jmp    1156 <get_one+0x16>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_one>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %r15d,%r15d
xor    %eax,%eax
call   1050 <getch@plt>
cmp    $0xa,%eax
jne    1163 <get_one+0x23>
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
lea    0xe94(%rip),%r12
lea    0xe90(%rip),%r14
xor    %ebx,%ebx
xor    %r15d,%r15d
jmp    11c0 <get_one+0x80>
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1030 <printw@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printw@plt>
mov    %r12,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1030 <printw@plt>
add    $0xffffffff,%ebx
xor    %eax,%eax
call   1040 <refresh@plt>
xor    %eax,%eax
call   1050 <getch@plt>
mov    %eax,%ebp
cmp    $0xa,%eax
je     1157 <get_one+0x17>
cmp    $0x8,%ebp
setne  %al
cmp    $0x7f,%ebp
setne  %cl
test   %cl,%al
jne    11e0 <get_one+0xa0>
test   %ebx,%ebx
jne    11e0 <get_one+0xa0>
xor    %ebx,%ebx
jmp    11ab <get_one+0x6b>
nopl   0x0(%rax,%rax,1)
cmp    $0x7f,%ebp
je     1180 <get_one+0x40>
cmp    $0x8,%ebp
je     1180 <get_one+0x40>
test   %ebx,%ebx
jg     11ab <get_one+0x6b>
cmp    $0x1b,%ebp
jne    11fc <get_one+0xbc>
xor    %eax,%eax
call   1060 <flushinp@plt>
jmp    11ab <get_one+0x6b>
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printw@plt>
add    $0x1,%ebx
mov    %ebp,%r15d
jmp    11ab <get_one+0x6b>

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [2 x i8] c" \00"
define i32 @get_one() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %52, %0
%5 = call i32 (...) @getch()
store i32 %5, i32* %1
%6 = icmp ne i32 %5, 10
br i1 %6, label %7, label %53
7: ; preds = %4
%8 = load i32, i32* %1
%9 = icmp eq i32 %8, 8
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, 127
br i1 %12, label %13, label %18
13: ; preds = %10, %7
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 (...) @refresh()
br label %52
18: ; preds = %13, %10
%19 = load i32, i32* %1
%20 = icmp eq i32 %19, 8
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = load i32, i32* %1
%23 = icmp eq i32 %22, 127
br i1 %23, label %24, label %31
24: ; preds = %21, %18
%25 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 8)
%26 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 8)
%28 = load i32, i32* %3
%29 = add nsw i32 %28, -1
store i32 %29, i32* %3
%30 = call i32 (...) @refresh()
br label %51
31: ; preds = %21
%32 = load i32, i32* %3
%33 = icmp sge i32 %32, 1
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = call i32 (...) @refresh()
br label %50
36: ; preds = %31
%37 = load i32, i32* %1
%38 = icmp eq i32 %37, 27
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = call i32 (...) @flushinp()
%41 = call i32 (...) @refresh()
br label %49
42: ; preds = %36
%43 = load i32, i32* %1
%44 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %43)
%45 = load i32, i32* %1
store i32 %45, i32* %2
%46 = load i32, i32* %3
%47 = add nsw i32 %46, 1
store i32 %47, i32* %3
%48 = call i32 (...) @refresh()
br label %49
49: ; preds = %42, %39
br label %50
50: ; preds = %49, %34
br label %51
51: ; preds = %50, %24
br label %52
52: ; preds = %51, %16
br label %4
53: ; preds = %4
%54 = load i32, i32* %2
ret i32 %54
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@.str.1 = [2 x i8] c" \00"
define i32 @get_one() {
%1 = tail call i32 (...) @getch()
%2 = icmp eq i32 %1, 10
br i1 %2, label %33, label %3
3: ; preds = %0, %27
%4 = phi i32 [ %31, %27 ], [ %1, %0 ]
%5 = phi i32 [ %29, %27 ], [ 0, %0 ]
%6 = phi i32 [ %28, %27 ], [ 0, %0 ]
%7 = icmp eq i32 %4, 8
%8 = icmp eq i32 %4, 127
%9 = or i1 %7, %8
%10 = icmp eq i32 %5, 0
%11 = select i1 %9, i1 %10, i1 false
br i1 %11, label %27, label %12
12: ; preds = %3
switch i32 %4, label %18 [
i32 127, label %13
i32 8, label %13
]
13: ; preds = %12, %12
%14 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 8)
%15 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 8)
%17 = add nsw i32 %5, -1
br label %27
18: ; preds = %12
%19 = icmp sgt i32 %5, 0
br i1 %19, label %27, label %20
20: ; preds = %18
%21 = icmp eq i32 %4, 27
br i1 %21, label %22, label %24
22: ; preds = %20
%23 = tail call i32 (...) @flushinp()
br label %27
24: ; preds = %20
%25 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %4)
%26 = add nsw i32 %5, 1
br label %27
27: ; preds = %18, %3, %13, %22, %24
%28 = phi i32 [ %6, %13 ], [ %6, %22 ], [ %4, %24 ], [ %6, %3 ], [ %6, %18 ]
%29 = phi i32 [ %17, %13 ], [ %5, %22 ], [ %26, %24 ], [ 0, %3 ], [ %5, %18 ]
%30 = tail call i32 (...) @refresh()
%31 = tail call i32 (...) @getch()
%32 = icmp eq i32 %31, 10
br i1 %32, label %33, label %3
33: ; preds = %27, %0
%34 = phi i32 [ 0, %0 ], [ %28, %27 ]
ret i32 %34
}