#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*/ cursors();
int /*<<< orphan*/ lprcat(char *);
int /*<<< orphan*/ lprintf(char *, char const *);
int ttgetch();
int whatitem(const char *str) {
  int i;
  cursors();
  lprintf("\nWhat do you want to %s [* for all] ? ", str);
  i = 0;
  while (i > 'z' || (i < 'a' && i != '*' && i != '\33' && i != '.'))
    i = ttgetch();
  if (i == '\33')
    lprcat(" aborted");
  return (i);
}


x86 assembly (clang, -O0):
<whatitem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <cursors@plt>
mov    -0x8(%rbp),%rsi
lea    0xea2(%rip),%rdi
call   1060 <lprintf@plt>
movl   $0x0,-0xc(%rbp)
mov    $0x1,%al
cmpl   $0x7a,-0xc(%rbp)
mov    %al,-0xd(%rbp)
jg     11b6 <whatitem+0x76>
xor    %eax,%eax
cmpl   $0x61,-0xc(%rbp)
mov    %al,-0xe(%rbp)
jge    11b0 <whatitem+0x70>
xor    %eax,%eax
cmpl   $0x2a,-0xc(%rbp)
mov    %al,-0xe(%rbp)
je     11b0 <whatitem+0x70>
xor    %eax,%eax
cmpl   $0x1b,-0xc(%rbp)
mov    %al,-0xe(%rbp)
je     11b0 <whatitem+0x70>
cmpl   $0x2e,-0xc(%rbp)
setne  %al
mov    %al,-0xe(%rbp)
mov    -0xe(%rbp),%al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    11c6 <whatitem+0x86>
jmp    11d5 <whatitem+0x95>
mov    $0x0,%al
call   1050 <ttgetch@plt>
mov    %eax,-0xc(%rbp)
jmp    116a <whatitem+0x2a>
cmpl   $0x1b,-0xc(%rbp)
jne    11eb <whatitem+0xab>
lea    0xe41(%rip),%rdi
call   1040 <lprcat@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<whatitem>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <cursors@plt>
lea    0xeae(%rip),%rdi
mov    %rbx,%rsi
call   1060 <lprintf@plt>
xor    %ebx,%ebx
jmp    1169 <whatitem+0x29>
xchg   %ax,%ax
xor    %eax,%eax
call   1050 <ttgetch@plt>
mov    %eax,%ebx
cmp    $0x7a,%ebx
jg     1160 <whatitem+0x20>
cmp    $0x60,%ebx
jg     1190 <whatitem+0x50>
cmp    $0x1b,%ebx
je     1184 <whatitem+0x44>
cmp    $0x2a,%ebx
je     1190 <whatitem+0x50>
cmp    $0x2e,%ebx
jne    1160 <whatitem+0x20>
jmp    1190 <whatitem+0x50>
lea    0xe9c(%rip),%rdi
call   1040 <lprcat@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [39 x i8] c"\0AWhat do you want to %s [* for all] ? \00"
@.str.1 = [9 x i8] c" aborted\00"
define i32 @whatitem(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = call i32 (...) @cursors()
%5 = load i8*, i8** %2
%6 = call i32 @lprintf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %5)
store i32 0, i32* %3
br label %7
7: ; preds = %26, %1
%8 = load i32, i32* %3
%9 = icmp sgt i32 %8, 122
br i1 %9, label %24, label %10
10: ; preds = %7
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 97
br i1 %12, label %13, label %22
13: ; preds = %10
%14 = load i32, i32* %3
%15 = icmp ne i32 %14, 42
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = load i32, i32* %3
%18 = icmp ne i32 %17, 27
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i32, i32* %3
%21 = icmp ne i32 %20, 46
br label %22
22: ; preds = %19, %16, %13, %10
%23 = phi i1 [ false, %16 ], [ false, %13 ], [ false, %10 ], [ %21, %19 ]
br label %24
24: ; preds = %22, %7
%25 = phi i1 [ true, %7 ], [ %23, %22 ]
br i1 %25, label %26, label %28
26: ; preds = %24
%27 = call i32 (...) @ttgetch()
store i32 %27, i32* %3
br label %7
28: ; preds = %24
%29 = load i32, i32* %3
%30 = icmp eq i32 %29, 27
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 @lprcat(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %33
33: ; preds = %31, %28
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@.str = [39 x i8] c"\0AWhat do you want to %s [* for all] ? \00"
@.str.1 = [9 x i8] c" aborted\00"
define i32 @whatitem(i8* %0) {
%2 = tail call i32 (...) @cursors()
%3 = tail call i32 @lprintf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %4
4: ; preds = %11, %1
%5 = phi i32 [ 0, %1 ], [ %12, %11 ]
%6 = icmp sgt i32 %5, 122
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = freeze i32 %5
%9 = icmp slt i32 %8, 97
br i1 %9, label %10, label %16
10: ; preds = %7
switch i32 %8, label %11 [
i32 27, label %13
i32 42, label %16
i32 46, label %16
]
11: ; preds = %10, %4
%12 = tail call i32 (...) @ttgetch()
br label %4
13: ; preds = %10
%14 = freeze i32 %5
%15 = tail call i32 @lprcat(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %18
16: ; preds = %10, %10, %7
%17 = freeze i32 %5
br label %18
18: ; preds = %16, %13
%19 = phi i32 [ %17, %16 ], [ %14, %13 ]
ret i32 %19
}