#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*/ clientExit();
int /*<<< orphan*/ connect();
int /*<<< orphan*/ disconnect();
int /*<<< orphan*/ getClientsID();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ sendMessage();
void menu() {
  int menuChoice;
  printf("Menu 1\n");
  printf("~~~~~~~~~~\n");
  printf("1. Connect to server.\n");
  printf("2. Get clients connected to server.\n");
  printf("3. Write to client/s.\n");
  printf("4. Disconnect from server.\n");
  printf("5. Exit.\n");
  scanf("%d", &menuChoice);
  printf("\n");
  switch (menuChoice) {
  case 1:
    connect();
    break;
  case 2:
    getClientsID();
    break;
  case 3:
    sendMessage();
    break;
  case 4:
    disconnect();
    break;
  case 5:
    disconnect();
    clientExit();
    break;
  default:
    printf("Please.. is not a joke. \n");
  }
  printf("\n");
  menu();
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe85(%rip),%rdi
call   1050 <printf@plt>
lea    0xe81(%rip),%rdi
call   1050 <printf@plt>
lea    0xe81(%rip),%rdi
call   1050 <printf@plt>
lea    0xe8c(%rip),%rdi
call   1050 <printf@plt>
lea    0xea5(%rip),%rdi
call   1050 <printf@plt>
lea    0xeb0(%rip),%rdi
call   1050 <printf@plt>
lea    0xec0(%rip),%rdi
call   1050 <printf@plt>
lea    0xebe(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1080 <scanf@plt>
lea    0xec9(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x4,%eax
ja     1264 <menu+0xe4>
mov    -0x10(%rbp),%rax
lea    0xde8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1090 <connect@plt>
jmp    1270 <menu+0xf0>
mov    $0x0,%al
call   1060 <getClientsID@plt>
jmp    1270 <menu+0xf0>
mov    $0x0,%al
call   1070 <sendMessage@plt>
jmp    1270 <menu+0xf0>
mov    $0x0,%al
call   10a0 <disconnect@plt>
jmp    1270 <menu+0xf0>
mov    $0x0,%al
call   10a0 <disconnect@plt>
mov    $0x0,%al
call   1030 <clientExit@plt>
jmp    1270 <menu+0xf0>
lea    0xe39(%rip),%rdi
call   1050 <printf@plt>
lea    0xe45(%rip),%rdi
call   1050 <printf@plt>
call   1040 <menu@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu>:
push   %rax
lea    0xe7f(%rip),%rdi
call   1050 <puts@plt>
lea    0xe7a(%rip),%rdi
call   1050 <puts@plt>
lea    0xe79(%rip),%rdi
call   1050 <puts@plt>
lea    0xe83(%rip),%rdi
call   1050 <puts@plt>
lea    0xe9b(%rip),%rdi
call   1050 <puts@plt>
lea    0xea5(%rip),%rdi
call   1050 <puts@plt>
lea    0xeb4(%rip),%rdi
call   1050 <puts@plt>
lea    0xe28(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1090 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     1225 <menu+0x95>
lea    0xded(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
call   10a0 <connect@plt>
jmp    125c <menu+0xcc>
lea    0xe71(%rip),%rdi
call   1050 <puts@plt>
jmp    125c <menu+0xcc>
xor    %eax,%eax
call   1070 <getClientsID@plt>
jmp    125c <menu+0xcc>
xor    %eax,%eax
call   1080 <sendMessage@plt>
jmp    125c <menu+0xcc>
xor    %eax,%eax
call   10b0 <disconnect@plt>
jmp    125c <menu+0xcc>
xor    %eax,%eax
call   10b0 <disconnect@plt>
xor    %eax,%eax
call   1040 <clientExit@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
call   1060 <menu@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [8 x i8] c"Menu 1\0A\00"
@.str.1 = [12 x i8] c"~~~~~~~~~~\0A\00"
@.str.2 = [23 x i8] c"1. Connect to server.\0A\00"
@.str.3 = [37 x i8] c"2. Get clients connected to server.\0A\00"
@.str.4 = [23 x i8] c"3. Write to client/s.\0A\00"
@.str.5 = [28 x i8] c"4. Disconnect from server.\0A\00"
@.str.6 = [10 x i8] c"5. Exit.\0A\00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [26 x i8] c"Please.. is not a joke. \0A\00"
define void @menu() {
%1 = alloca i32
%2 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %1)
%10 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%11 = load i32, i32* %1
switch i32 %11, label %23 [
i32 1, label %12
i32 2, label %14
i32 3, label %16
i32 4, label %18
i32 5, label %20
]
12: ; preds = %0
%13 = call i32 (...) @connect()
br label %25
14: ; preds = %0
%15 = call i32 (...) @getClientsID()
br label %25
16: ; preds = %0
%17 = call i32 (...) @sendMessage()
br label %25
18: ; preds = %0
%19 = call i32 (...) @disconnect()
br label %25
20: ; preds = %0
%21 = call i32 (...) @disconnect()
%22 = call i32 (...) @clientExit()
br label %25
23: ; preds = %0
%24 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0))
br label %25
25: ; preds = %23, %20, %18, %16, %14, %12
%26 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.7 = [3 x i8] c"%d\00"
@str = [7 x i8] c"Menu 1\00"
@str.10 = [11 x i8] c"~~~~~~~~~~\00"
@str.11 = [22 x i8] c"1. Connect to server.\00"
@str.12 = [36 x i8] c"2. Get clients connected to server.\00"
@str.13 = [22 x i8] c"3. Write to client/s.\00"
@str.14 = [27 x i8] c"4. Disconnect from server.\00"
@str.15 = [9 x i8] c"5. Exit.\00"
@str.16 = [25 x i8] c"Please.. is not a joke. \00"
define void @menu() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.10, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.11, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.12, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.13, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.14, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.15, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %1)
%11 = call i32 @putchar(i32 10)
%12 = load i32, i32* %1
switch i32 %12, label %24 [
i32 1, label %13
i32 2, label %15
i32 3, label %17
i32 4, label %19
i32 5, label %21
]
13: ; preds = %0
%14 = call i32 (...) @connect()
br label %26
15: ; preds = %0
%16 = call i32 (...) @getClientsID()
br label %26
17: ; preds = %0
%18 = call i32 (...) @sendMessage()
br label %26
19: ; preds = %0
%20 = call i32 (...) @disconnect()
br label %26
21: ; preds = %0
%22 = call i32 (...) @disconnect()
%23 = call i32 (...) @clientExit()
br label %26
24: ; preds = %0
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.16, i64 0, i64 0))
br label %26
26: ; preds = %24, %21, %19, %17, %15, %13
%27 = call i32 @putchar(i32 10)
ret void
}