#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ test();
int /*<<< orphan*/ testGetchar();
int /*<<< orphan*/ testScanfS();
int main(void) {
  char selection;
  printf("\n");
  printf("\n");
  printf("Welcome to ioStorm!\n");
  while (1) {
    printf("\n");
    printf("1: Test getchar()\n");
    printf("2: Test scanf(string)\n");
    printf("3: Stuff\n");
    printf("Q: Quit\n");
    scanf("%c", &selection);
    printf("\n");
    printf("\n");
    switch (selection) {
    case '1':
      testGetchar();
      break;
    case '2':
      testScanfS();
      break;
    case '3':
      test();
      break;
    case 'Q':
      exit(0);
    default:
      printf("Invalid selection\n");
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xf21(%rip),%rdi
call   1030 <printf@plt>
lea    0xf15(%rip),%rdi
call   1030 <printf@plt>
lea    0xef6(%rip),%rdi
call   1030 <printf@plt>
lea    0xefd(%rip),%rdi
mov    %rdi,-0x18(%rbp)
call   1030 <printf@plt>
lea    0xeef(%rip),%rdi
call   1030 <printf@plt>
lea    0xef6(%rip),%rdi
call   1030 <printf@plt>
lea    0xf01(%rip),%rdi
call   1030 <printf@plt>
lea    0xeff(%rip),%rdi
call   1030 <printf@plt>
lea    0xefc(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <printf@plt>
movsbl -0x5(%rbp),%eax
add    $0xffffffcf,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x20,%eax
ja     124a <main+0xea>
mov    -0x10(%rbp),%rax
lea    0xdea(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1040 <testGetchar@plt>
jmp    1256 <main+0xf6>
mov    $0x0,%al
call   1060 <testScanfS@plt>
jmp    1256 <main+0xf6>
mov    $0x0,%al
call   1080 <test@plt>
jmp    1256 <main+0xf6>
xor    %edi,%edi
call   1070 <exit@plt>
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
jmp    1193 <main+0x33>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xef1(%rip),%rdi
call   1040 <puts@plt>
lea    0xf0b(%rip),%r15
lea    0xf1a(%rip),%r12
lea    0xf1c(%rip),%r13
lea    0xecd(%rip),%rbx
lea    0x7(%rsp),%rbp
lea    0xe3d(%rip),%r14
jmp    11d7 <main+0x67>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1090 <test@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xeb3(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movsbl 0x7(%rsp),%eax
add    $0xffffffcf,%eax
cmp    $0x20,%eax
ja     1260 <main+0xf0>
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
xor    %eax,%eax
call   1050 <testGetchar@plt>
jmp    11d7 <main+0x67>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1070 <testScanfS@plt>
jmp    11d7 <main+0x67>
nopl   0x0(%rax)
lea    0xe6d(%rip),%rdi
call   1040 <puts@plt>
jmp    11d7 <main+0x67>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [21 x i8] c"Welcome to ioStorm!\0A\00"
@.str.2 = [19 x i8] c"1: Test getchar()\0A\00"
@.str.3 = [23 x i8] c"2: Test scanf(string)\0A\00"
@.str.4 = [10 x i8] c"3: Stuff\0A\00"
@.str.5 = [9 x i8] c"Q: Quit\0A\00"
@.str.6 = [3 x i8] c"%c\00"
@.str.7 = [19 x i8] c"Invalid selection\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %6
6: ; preds = %0, %27
%7 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %2)
%13 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = load i8, i8* %2
%16 = sext i8 %15 to i32
switch i32 %16, label %25 [
i32 49, label %17
i32 50, label %19
i32 51, label %21
i32 81, label %23
]
17: ; preds = %6
%18 = call i32 (...) @testGetchar()
br label %27
19: ; preds = %6
%20 = call i32 (...) @testScanfS()
br label %27
21: ; preds = %6
%22 = call i32 (...) @test()
br label %27
23: ; preds = %6
%24 = call i32 @exit(i32 0)
unreachable
25: ; preds = %6
%26 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
br label %27
27: ; preds = %25, %21, %19, %17
br label %6
}

LLVM IR (-O2):
@.str.6 = [3 x i8] c"%c\00"
@str = [20 x i8] c"Welcome to ioStorm!\00"
@str.8 = [18 x i8] c"1: Test getchar()\00"
@str.9 = [22 x i8] c"2: Test scanf(string)\00"
@str.10 = [9 x i8] c"3: Stuff\00"
@str.11 = [8 x i8] c"Q: Quit\00"
@str.12 = [18 x i8] c"Invalid selection\00"
define i32 @main() {
%1 = alloca i8
%2 = tail call i32 @putchar(i32 10)
%3 = tail call i32 @putchar(i32 10)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %5
5: ; preds = %26, %0
%6 = call i32 @putchar(i32 10)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.8, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.9, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.10, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.11, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %1)
%12 = call i32 @putchar(i32 10)
%13 = call i32 @putchar(i32 10)
%14 = load i8, i8* %1
%15 = sext i8 %14 to i32
switch i32 %15, label %24 [
i32 49, label %16
i32 50, label %18
i32 51, label %20
i32 81, label %22
]
16: ; preds = %5
%17 = call i32 (...) @testGetchar()
br label %26
18: ; preds = %5
%19 = call i32 (...) @testScanfS()
br label %26
20: ; preds = %5
%21 = call i32 (...) @test()
br label %26
22: ; preds = %5
%23 = call i32 @exit(i32 0)
unreachable
24: ; preds = %5
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.12, i64 0, i64 0))
br label %26
26: ; preds = %24, %20, %18, %16
br label %5
}