#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 getchar();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ read_info();
int /*<<< orphan*/ replace_info();
char toupper(char);
int /*<<< orphan*/ write_info();
int main() {
  char c;
  int done = 0;
  while (!done) {
    puts("\n\t** Stock Portfolio Thing **\n\n");
    puts("A - Add new stock\n");
    puts("R - Replace stock\n");
    puts("L - List Stocks\n");
    puts("Q - Quit\n");
    printf("  Your choice %c ", 16);
    c = toupper(getchar());
    while (getchar() != '\n')
      continue;
    switch (c) {
    case 'A':
      puts("Add new stock\n");
      write_info();
      break;
    case 'R':
      puts("Replace stock");
      replace_info();
      break;
    case 'L':
      puts("List stocks\n");
      read_info();
      break;
    case 'Q':
      puts("Quit\n");
      done = !0;
      break;
    default:
      puts("?");
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    119c <main+0x2c>
jmp    12ae <main+0x13e>
lea    0xea5(%rip),%rdi
call   1050 <puts@plt>
lea    0xeb9(%rip),%rdi
call   1050 <puts@plt>
lea    0xec0(%rip),%rdi
call   1050 <puts@plt>
lea    0xec7(%rip),%rdi
call   1050 <puts@plt>
lea    0xecc(%rip),%rdi
call   1050 <puts@plt>
lea    0xeca(%rip),%rdi
mov    $0x10,%esi
call   1060 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
movsbl %al,%edi
call   1040 <toupper@plt>
mov    %al,-0x5(%rbp)
mov    $0x0,%al
call   1070 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     1213 <main+0xa3>
jmp    11fb <main+0x8b>
movsbl -0x5(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x11,%eax
ja     129d <main+0x12d>
mov    -0x18(%rbp),%rax
lea    0xdcc(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe28(%rip),%rdi
call   1050 <puts@plt>
mov    $0x0,%al
call   1030 <write_info@plt>
jmp    12a9 <main+0x139>
lea    0xe5f(%rip),%rdi
call   1050 <puts@plt>
mov    $0x0,%al
call   1080 <replace_info@plt>
jmp    12a9 <main+0x139>
lea    0xe55(%rip),%rdi
call   1050 <puts@plt>
mov    $0x0,%al
call   1090 <read_info@plt>
jmp    12a9 <main+0x139>
lea    0xe17(%rip),%rdi
call   1050 <puts@plt>
movl   $0x1,-0xc(%rbp)
jmp    12a9 <main+0x139>
lea    0xe32(%rip),%rdi
call   1050 <puts@plt>
jmp    1186 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xef9(%rip),%r12
lea    0xf05(%rip),%r13
lea    0xf0f(%rip),%rbx
lea    0xf12(%rip),%rbp
lea    0xe62(%rip),%r15
jmp    11b3 <main+0x43>
lea    0xf22(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1090 <read_info@plt>
lea    0xe8e(%rip),%rdi
call   1050 <puts@plt>
lea    0xea2(%rip),%rdi
call   1050 <puts@plt>
mov    %r12,%rdi
call   1050 <puts@plt>
mov    %r13,%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1050 <puts@plt>
mov    %rbp,%rdi
mov    $0x10,%esi
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
movsbl %al,%edi
call   1040 <toupper@plt>
mov    %eax,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    $0xa,%al
jne    1210 <main+0xa0>
movsbl %r14b,%eax
add    $0xffffffbf,%eax
cmp    $0x11,%eax
ja     1250 <main+0xe0>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
lea    0xe35(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1030 <write_info@plt>
jmp    11b3 <main+0x43>
nopl   0x0(%rax,%rax,1)
lea    0xe7f(%rip),%rdi
call   1050 <puts@plt>
jmp    11b3 <main+0x43>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xe44(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1080 <replace_info@plt>
jmp    11b3 <main+0x43>
lea    0xe14(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"\0A\09** Stock Portfolio Thing **\0A\0A\00"
@.str.1 = [19 x i8] c"A - Add new stock\0A\00"
@.str.2 = [19 x i8] c"R - Replace stock\0A\00"
@.str.3 = [17 x i8] c"L - List Stocks\0A\00"
@.str.4 = [10 x i8] c"Q - Quit\0A\00"
@.str.5 = [18 x i8] c" Your choice %c \00"
@.str.6 = [15 x i8] c"Add new stock\0A\00"
@.str.7 = [14 x i8] c"Replace stock\00"
@.str.8 = [13 x i8] c"List stocks\0A\00"
@.str.9 = [6 x i8] c"Quit\0A\00"
@.str.10 = [2 x i8] c"?\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %4
4: ; preds = %38, %0
%5 = load i32, i32* %3
%6 = icmp ne i32 %5, 0
%7 = xor i1 %6, true
br i1 %7, label %8, label %39
8: ; preds = %4
%9 = call i32 @puts(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @puts(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 16)
%15 = call signext i8 (...) @getchar()
%16 = call signext i8 @toupper(i8 signext %15)
store i8 %16, i8* %2
br label %17
17: ; preds = %21, %8
%18 = call signext i8 (...) @getchar()
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 10
br i1 %20, label %21, label %22
21: ; preds = %17
br label %17
22: ; preds = %17
%23 = load i8, i8* %2
%24 = sext i8 %23 to i32
switch i32 %24, label %36 [
i32 65, label %25
i32 82, label %28
i32 76, label %31
i32 81, label %34
]
25: ; preds = %22
%26 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%27 = call i32 (...) @write_info()
br label %38
28: ; preds = %22
%29 = call i32 @puts(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%30 = call i32 (...) @replace_info()
br label %38
31: ; preds = %22
%32 = call i32 @puts(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%33 = call i32 (...) @read_info()
br label %38
34: ; preds = %22
%35 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
store i32 1, i32* %3
br label %38
36: ; preds = %22
%37 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %38
38: ; preds = %36, %34, %31, %28, %25
br label %4
39: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c"\0A\09** Stock Portfolio Thing **\0A\0A\00"
@.str.1 = [19 x i8] c"A - Add new stock\0A\00"
@.str.2 = [19 x i8] c"R - Replace stock\0A\00"
@.str.3 = [17 x i8] c"L - List Stocks\0A\00"
@.str.4 = [10 x i8] c"Q - Quit\0A\00"
@.str.5 = [18 x i8] c" Your choice %c \00"
@.str.6 = [15 x i8] c"Add new stock\0A\00"
@.str.7 = [14 x i8] c"Replace stock\00"
@.str.8 = [13 x i8] c"List stocks\0A\00"
@.str.9 = [6 x i8] c"Quit\0A\00"
@.str.10 = [2 x i8] c"?\00"
define i32 @main() {
br label %1
1: ; preds = %26, %0
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%7 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 16)
%8 = tail call signext i8 (...) @getchar()
%9 = tail call signext i8 @toupper(i8 signext %8)
br label %10
10: ; preds = %10, %1
%11 = tail call signext i8 (...) @getchar()
%12 = icmp eq i8 %11, 10
br i1 %12, label %13, label %10
13: ; preds = %10
%14 = sext i8 %9 to i32
switch i32 %14, label %24 [
i32 65, label %15
i32 82, label %18
i32 76, label %21
i32 81, label %27
]
15: ; preds = %13
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%17 = tail call i32 (...) @write_info()
br label %26
18: ; preds = %13
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%20 = tail call i32 (...) @replace_info()
br label %26
21: ; preds = %13
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%23 = tail call i32 (...) @read_info()
br label %26
24: ; preds = %13
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %26
26: ; preds = %24, %21, %18, %15
br label %1
27: ; preds = %13
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
ret i32 0
}