#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 get_input();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ show_options();
int /*<<< orphan*/ show_selection(char);
int main(int argc, char **argv) {
  char ch;
  printf("Welcome to c coding\n");
  do {
    printf("Please select a menu item:\n");
    show_options();
    show_selection(ch = get_input());
  } while (ch != 'Q');
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
lea    0xeac(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <show_options@plt>
mov    $0x0,%al
call   1060 <get_input@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%edi
call   1050 <show_selection@plt>
movsbl -0x11(%rbp),%eax
cmp    $0x51,%eax
jne    1162 <main+0x22>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xeb6(%rip),%rdi
call   1030 <puts@plt>
lea    0xebe(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <show_options@plt>
xor    %eax,%eax
call   1060 <get_input@plt>
movsbl %al,%ebp
mov    %ebp,%edi
call   1050 <show_selection@plt>
cmp    $0x51,%bpl
jne    1160 <main+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Welcome to c coding\0A\00"
@.str.1 = [28 x i8] c"Please select a menu item:\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %13, %2
%9 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (...) @show_options()
%11 = call signext i8 (...) @get_input()
store i8 %11, i8* %6
%12 = call i32 @show_selection(i8 signext %11)
br label %13
13: ; preds = %8
%14 = load i8, i8* %6
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 81
br i1 %16, label %8, label %17
17: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@str = [20 x i8] c"Welcome to c coding\00"
@str.2 = [27 x i8] c"Please select a menu item:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %4, %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.2, i64 0, i64 0))
%6 = tail call i32 (...) @show_options()
%7 = tail call signext i8 (...) @get_input()
%8 = tail call i32 @show_selection(i8 signext %7)
%9 = icmp eq i8 %7, 81
br i1 %9, label %10, label %4
10: ; preds = %4
ret i32 0
}