#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*/ get_connections();
int /*<<< orphan*/ get_services();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ register_service();
int /*<<< orphan*/ smpl_connect();
int /*<<< orphan*/ smpl_disconnect();
int /*<<< orphan*/ smpl_initialize();
int /*<<< orphan*/ smpl_invoke();
int /*<<< orphan*/ smpl_process();
int /*<<< orphan*/ smpl_shutdown();
int /*<<< orphan*/ unregister_service();
void processChoice(int choice) {
  switch (choice) {
  case 0:
    printf("You chose to initialize RVI.\n");
    smpl_initialize();
    break;
  case 1:
    printf("You chose to connect to a remote node.\n");
    smpl_connect();
    break;
  case 2:
    printf("Which RVI node would you like to disconnect from? ");
    smpl_disconnect();
    break;
  case 3:
    printf("You chose to get a list of connections.\n");
    get_connections();
    break;
  case 4:
    printf("You chose to register a service.\n");
    register_service();
    break;
  case 5:
    printf("You chose to unregister a service.\n");
    unregister_service();
    break;
  case 6:
    printf("You chose to get a list of services.\n");
    get_services();
    break;
  case 7:
    printf("What service would you like to invoke?\n");
    smpl_invoke();
    break;
  case 8:
    printf("You chose to process input.\n");
    smpl_process();
    break;
  case 9:
    printf("You chose to shutdown RVI.\n");
    smpl_shutdown();
    break;
  case 10:
    printf("Goodbye!\n");
    exit(0);
  default:
    printf("That's not a valid choice.\n");
    break;
  }
}


x86 assembly (clang, -O0):
<processChoice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0xa,%rax
ja     12f3 <processChoice+0x133>
mov    -0x10(%rbp),%rax
lea    0xe19(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe35(%rip),%rdi
call   1070 <printf@plt>
mov    $0x0,%al
call   1060 <smpl_initialize@plt>
jmp    12ff <processChoice+0x13f>
lea    0xe3b(%rip),%rdi
call   1070 <printf@plt>
mov    $0x0,%al
call   10a0 <smpl_connect@plt>
jmp    12ff <processChoice+0x13f>
lea    0xe4b(%rip),%rdi
call   1070 <printf@plt>
mov    $0x0,%al
call   1050 <smpl_disconnect@plt>
jmp    12ff <processChoice+0x13f>
lea    0xe66(%rip),%rdi
call   1070 <printf@plt>
mov    $0x0,%al
call   1080 <get_connections@plt>
jmp    12ff <processChoice+0x13f>
lea    0xe77(%rip),%rdi
call   1070 <printf@plt>
mov    $0x0,%al
call   1090 <register_service@plt>
jmp    12ff <processChoice+0x13f>
lea    0xe81(%rip),%rdi
call   1070 <printf@plt>
mov    $0x0,%al
call   1040 <unregister_service@plt>
jmp    12ff <processChoice+0x13f>
lea    0xe8d(%rip),%rdi
call   1070 <printf@plt>
mov    $0x0,%al
call   1030 <get_services@plt>
jmp    12ff <processChoice+0x13f>
lea    0xe9b(%rip),%rdi
call   1070 <printf@plt>
mov    $0x0,%al
call   10d0 <smpl_invoke@plt>
jmp    12ff <processChoice+0x13f>
lea    0xeab(%rip),%rdi
call   1070 <printf@plt>
mov    $0x0,%al
call   10b0 <smpl_process@plt>
jmp    12ff <processChoice+0x13f>
lea    0xeb0(%rip),%rdi
call   1070 <printf@plt>
mov    $0x0,%al
call   10c0 <smpl_shutdown@plt>
jmp    12ff <processChoice+0x13f>
lea    0xeb4(%rip),%rdi
call   1070 <printf@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
lea    0xeab(%rip),%rdi
call   1070 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<processChoice>:
push   %rax
cmp    $0xa,%edi
ja     11fc <processChoice+0x2c>
mov    %edi,%eax
lea    0xe21(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf8f(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rcx
jmp    1070 <smpl_initialize@plt>
lea    0xf98(%rip),%rdi
pop    %rax
jmp    1040 <puts@plt>
lea    0xf47(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rcx
jmp    10b0 <smpl_connect@plt>
lea    0xe08(%rip),%rdi
call   1080 <printf@plt>
xor    %eax,%eax
pop    %rcx
jmp    1060 <smpl_disconnect@plt>
lea    0xef7(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rcx
jmp    1090 <get_connections@plt>
lea    0xec2(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rcx
jmp    10a0 <register_service@plt>
lea    0xe8b(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rcx
jmp    1050 <unregister_service@plt>
lea    0xe52(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rcx
jmp    1030 <get_services@plt>
lea    0xe17(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rcx
jmp    10e0 <smpl_invoke@plt>
lea    0xde7(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rcx
jmp    10c0 <smpl_process@plt>
lea    0xdb8(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rcx
jmp    10d0 <smpl_shutdown@plt>
lea    0xd9b(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"You chose to initialize RVI.\0A\00"
@.str.1 = [40 x i8] c"You chose to connect to a remote node.\0A\00"
@.str.2 = [51 x i8] c"Which RVI node would you like to disconnect from? \00"
@.str.3 = [41 x i8] c"You chose to get a list of connections.\0A\00"
@.str.4 = [34 x i8] c"You chose to register a service.\0A\00"
@.str.5 = [36 x i8] c"You chose to unregister a service.\0A\00"
@.str.6 = [38 x i8] c"You chose to get a list of services.\0A\00"
@.str.7 = [40 x i8] c"What service would you like to invoke?\0A\00"
@.str.8 = [29 x i8] c"You chose to process input.\0A\00"
@.str.9 = [28 x i8] c"You chose to shutdown RVI.\0A\00"
@.str.10 = [10 x i8] c"Goodbye!\0A\00"
@.str.11 = [28 x i8] c"That's not a valid choice.\0A\00"
define void @processChoice(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
switch i32 %3, label %37 [
i32 0, label %4
i32 1, label %7
i32 2, label %10
i32 3, label %13
i32 4, label %16
i32 5, label %19
i32 6, label %22
i32 7, label %25
i32 8, label %28
i32 9, label %31
i32 10, label %34
]
4: ; preds = %1
%5 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (...) @smpl_initialize()
br label %39
7: ; preds = %1
%8 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (...) @smpl_connect()
br label %39
10: ; preds = %1
%11 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (...) @smpl_disconnect()
br label %39
13: ; preds = %1
%14 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 (...) @get_connections()
br label %39
16: ; preds = %1
%17 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%18 = call i32 (...) @register_service()
br label %39
19: ; preds = %1
%20 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
%21 = call i32 (...) @unregister_service()
br label %39
22: ; preds = %1
%23 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
%24 = call i32 (...) @get_services()
br label %39
25: ; preds = %1
%26 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0))
%27 = call i32 (...) @smpl_invoke()
br label %39
28: ; preds = %1
%29 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
%30 = call i32 (...) @smpl_process()
br label %39
31: ; preds = %1
%32 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
%33 = call i32 (...) @smpl_shutdown()
br label %39
34: ; preds = %1
%35 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%36 = call i32 @exit(i32 0)
unreachable
37: ; preds = %1
%38 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0))
br label %39
39: ; preds = %37, %31, %28, %25, %22, %19, %16, %13, %10, %7, %4
ret void
}

LLVM IR (-O2):
@.str.2 = [51 x i8] c"Which RVI node would you like to disconnect from? \00"
@str = [9 x i8] c"Goodbye!\00"
@str.12 = [27 x i8] c"You chose to shutdown RVI.\00"
@str.13 = [28 x i8] c"You chose to process input.\00"
@str.14 = [39 x i8] c"What service would you like to invoke?\00"
@str.15 = [37 x i8] c"You chose to get a list of services.\00"
@str.16 = [35 x i8] c"You chose to unregister a service.\00"
@str.17 = [33 x i8] c"You chose to register a service.\00"
@str.18 = [40 x i8] c"You chose to get a list of connections.\00"
@str.19 = [39 x i8] c"You chose to connect to a remote node.\00"
@str.20 = [29 x i8] c"You chose to initialize RVI.\00"
@str.21 = [27 x i8] c"That's not a valid choice.\00"
define void @processChoice(i32 %0) {
switch i32 %0, label %35 [
i32 0, label %2
i32 1, label %5
i32 2, label %8
i32 3, label %11
i32 4, label %14
i32 5, label %17
i32 6, label %20
i32 7, label %23
i32 8, label %26
i32 9, label %29
i32 10, label %32
]
2: ; preds = %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.20, i64 0, i64 0))
%4 = tail call i32 (...) @smpl_initialize()
br label %37
5: ; preds = %1
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.19, i64 0, i64 0))
%7 = tail call i32 (...) @smpl_connect()
br label %37
8: ; preds = %1
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 (...) @smpl_disconnect()
br label %37
11: ; preds = %1
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.18, i64 0, i64 0))
%13 = tail call i32 (...) @get_connections()
br label %37
14: ; preds = %1
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.17, i64 0, i64 0))
%16 = tail call i32 (...) @register_service()
br label %37
17: ; preds = %1
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.16, i64 0, i64 0))
%19 = tail call i32 (...) @unregister_service()
br label %37
20: ; preds = %1
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.15, i64 0, i64 0))
%22 = tail call i32 (...) @get_services()
br label %37
23: ; preds = %1
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.14, i64 0, i64 0))
%25 = tail call i32 (...) @smpl_invoke()
br label %37
26: ; preds = %1
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.13, i64 0, i64 0))
%28 = tail call i32 (...) @smpl_process()
br label %37
29: ; preds = %1
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.12, i64 0, i64 0))
%31 = tail call i32 (...) @smpl_shutdown()
br label %37
32: ; preds = %1
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%34 = tail call i32 @exit(i32 0)
unreachable
35: ; preds = %1
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.21, i64 0, i64 0))
br label %37
37: ; preds = %35, %29, %26, %23, %20, %17, %14, %11, %8, %5, %2
ret void
}