#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 get_first();
int /*<<< orphan*/ printf(char *);
char get_choice(void) {
  int ch;
  printf("Enter the letter of your choice:\n");
  printf("a. advice\tb. bell\n");
  printf("c. count\tq. quit\n");
  ch = get_first();
  while ((ch < 'a' || ch > 'c') && ch != 'q') {
    printf("Please respond with a, b , c or q.\n");
    ch = get_first();
  }
  return ch;
}


x86 assembly (clang, -O0):
<get_choice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
lea    0xee7(%rip),%rdi
call   1030 <printf@plt>
lea    0xeee(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <get_first@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x61,-0x4(%rbp)
jl     116f <get_choice+0x4f>
xor    %eax,%eax
cmpl   $0x63,-0x4(%rbp)
mov    %al,-0x5(%rbp)
jle    1179 <get_choice+0x59>
cmpl   $0x71,-0x4(%rbp)
setne  %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
test   $0x1,%al
jne    1189 <get_choice+0x69>
jmp    11a4 <get_choice+0x84>
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <get_first@plt>
mov    %eax,-0x4(%rbp)
jmp    1156 <get_choice+0x36>
mov    -0x4(%rbp),%eax
movsbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_choice>:
push   %rbp
push   %rbx
push   %rax
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
lea    0xeeb(%rip),%rdi
call   1030 <puts@plt>
lea    0xef1(%rip),%rdi
lea    0xefb(%rip),%rbx
mov    $0x10007,%ebp
xchg   %ax,%ax
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <get_first@plt>
lea    -0x61(%rax),%ecx
mov    %rbx,%rdi
cmp    $0x10,%ecx
ja     1150 <get_choice+0x30>
bt     %ecx,%ebp
mov    %rbx,%rdi
jae    1150 <get_choice+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Enter the letter of your choice:\0A\00"
@.str.1 = [19 x i8] c"a. advice\09b. bell\0A\00"
@.str.2 = [18 x i8] c"c. count\09q. quit\0A\00"
@.str.3 = [36 x i8] c"Please respond with a, b , c or q.\0A\00"
define signext i8 @get_choice() {
%1 = alloca i32
%2 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 (...) @get_first()
store i32 %5, i32* %1
br label %6
6: ; preds = %17, %0
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 97
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = load i32, i32* %1
%11 = icmp sgt i32 %10, 99
br i1 %11, label %12, label %15
12: ; preds = %9, %6
%13 = load i32, i32* %1
%14 = icmp ne i32 %13, 113
br label %15
15: ; preds = %12, %9
%16 = phi i1 [ false, %9 ], [ %14, %12 ]
br i1 %16, label %17, label %20
17: ; preds = %15
%18 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 (...) @get_first()
store i32 %19, i32* %1
br label %6
20: ; preds = %15
%21 = load i32, i32* %1
%22 = trunc i32 %21 to i8
ret i8 %22
}

LLVM IR (-O2):
@str = [33 x i8] c"Enter the letter of your choice:\00"
@str.4 = [18 x i8] c"a. advice\09b. bell\00"
@str.5 = [17 x i8] c"c. count\09q. quit\00"
@str.6 = [35 x i8] c"Please respond with a, b , c or q.\00"
define signext i8 @get_choice() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.4, i64 0, i64 0))
br label %3
3: ; preds = %3, %0
%4 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @str.5, i64 0, i64 0), %0 ], [ getelementptr inbounds ([35 x i8], [35 x i8]* @str.6, i64 0, i64 0), %3 ]
%5 = tail call i32 @puts(i8* dereferenceable(1) %4)
%6 = tail call i32 (...) @get_first()
switch i32 %6, label %3 [
i32 113, label %7
i32 99, label %7
i32 98, label %7
i32 97, label %7
]
7: ; preds = %3, %3, %3, %3
%8 = trunc i32 %6 to i8
ret i8 %8
}