#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_choice();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
int main(void) {
  int choice;
  void count(void);
  while ((choice = get_choice()) != 'q') {
    switch (choice) {
    case 'a':
      printf("Buy low, sell high.\n");
      break;
    case 'b':
      putchar('\a');
      break;
    case 'c':
      count();
      break;
    default:
      printf("Program error!\n");
      break;
    }
  }
  printf("Bye.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <get_choice@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x71,%eax
je     11d3 <main+0x93>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x61,%eax
je     1198 <main+0x58>
jmp    1176 <main+0x36>
mov    -0xc(%rbp),%eax
sub    $0x62,%eax
je     11a9 <main+0x69>
jmp    1187 <main+0x47>
mov    -0xc(%rbp),%eax
sub    $0x63,%eax
je     11b8 <main+0x78>
jmp    11c2 <main+0x82>
lea    0xe61(%rip),%rdi
call   1050 <printf@plt>
jmp    11ce <main+0x8e>
mov    $0x7,%edi
call   1040 <putchar@plt>
jmp    11ce <main+0x8e>
call   1030 <count@plt>
jmp    11ce <main+0x8e>
lea    0xe4c(%rip),%rdi
call   1050 <printf@plt>
jmp    114f <main+0xf>
lea    0xe4b(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xf11(%rip),%r14
lea    0xead(%rip),%rbx
lea    0xeef(%rip),%r15
jmp    1165 <main+0x25>
nopl   0x0(%rax)
call   1030 <count@plt>
xor    %eax,%eax
call   1060 <get_choice@plt>
add    $0xffffff9f,%eax
cmp    $0x10,%eax
ja     11a0 <main+0x60>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
mov    %r15,%rdi
call   1050 <puts@plt>
jmp    1165 <main+0x25>
nopw   0x0(%rax,%rax,1)
mov    $0x7,%edi
call   1040 <putchar@plt>
jmp    1165 <main+0x25>
nopl   0x0(%rax)
mov    %r14,%rdi
call   1050 <puts@plt>
jmp    1165 <main+0x25>
lea    0xe93(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Buy low, sell high.\0A\00"
@.str.1 = [16 x i8] c"Program error!\0A\00"
@.str.2 = [6 x i8] c"Bye.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %15, %0
%4 = call i32 (...) @get_choice()
store i32 %4, i32* %2
%5 = icmp ne i32 %4, 113
br i1 %5, label %6, label %16
6: ; preds = %3
%7 = load i32, i32* %2
switch i32 %7, label %13 [
i32 97, label %8
i32 98, label %10
i32 99, label %12
]
8: ; preds = %6
%9 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %15
10: ; preds = %6
%11 = call i32 @putchar(i8 signext 7)
br label %15
12: ; preds = %6
br label %15
13: ; preds = %6
%14 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %12, %10, %8
br label %3
16: ; preds = %3
%17 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@str = [5 x i8] c"Bye.\00"
@str.3 = [20 x i8] c"Buy low, sell high.\00"
@str.4 = [15 x i8] c"Program error!\00"
define i32 @main() {
br label %1
1: ; preds = %10, %0
%2 = tail call i32 (...) @get_choice()
switch i32 %2, label %8 [
i32 113, label %11
i32 97, label %3
i32 98, label %5
i32 99, label %7
]
3: ; preds = %1
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.3, i64 0, i64 0))
br label %10
5: ; preds = %1
%6 = tail call i32 @putchar(i8 signext 7)
br label %10
7: ; preds = %1
tail call void @count()
br label %10
8: ; preds = %1
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.4, i64 0, i64 0))
br label %10
10: ; preds = %8, %7, %5, %3
br label %1
11: ; preds = %1
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
ret i32 0
}