#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int get_server_status();
int launch_chat();
int launch_clients(int);
int launch_server();
int sscanf(char *, char *, int *);
int /*<<< orphan*/ stderr;
int strlen(char *);
int main(int argc, char *argv[]) {
  int ret = -1;
  int num_client;
  if ((argc != 2) && (argc != 3)) {
  usage:
    fprintf(stderr, "usage: %s a|m|s|c num_client\n", argv[0]);
    goto leave;
  }
  if ((strlen(argv[1]) != 1))
    goto usage;
  switch (argv[1][0]) {
  case 'a':
    if (argc != 3)
      goto usage;
    if (sscanf(argv[2], "%d", &num_client) != 1)
      goto usage;
    ret = launch_clients(num_client);
    break;
  case 's':
    ret = launch_server();
    break;
  case 'm':
    ret = get_server_status();
    break;
  case 'c':
    ret = launch_chat();
    break;
  default:
    goto usage;
  }
leave:
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11c7 <main+0x57>
cmpl   $0x3,-0x8(%rbp)
je     11c7 <main+0x57>
jmp    11a6 <main+0x36>
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe8f(%rip),%rsi
call   1050 <fprintf@plt>
jmp    128f <main+0x11f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
je     11e2 <main+0x72>
jmp    11a6 <main+0x36>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x12,%eax
ja     1285 <main+0x115>
mov    -0x20(%rbp),%rax
lea    0xdf6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x3,-0x8(%rbp)
je     1222 <main+0xb2>
jmp    11a6 <main+0x36>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe39(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1060 <sscanf@plt>
cmp    $0x1,%eax
je     1248 <main+0xd8>
jmp    11a6 <main+0x36>
mov    -0x18(%rbp),%edi
call   1070 <launch_clients@plt>
mov    %eax,-0x14(%rbp)
jmp    128a <main+0x11a>
mov    $0x0,%al
call   1080 <launch_server@plt>
mov    %eax,-0x14(%rbp)
jmp    128a <main+0x11a>
mov    $0x0,%al
call   1090 <get_server_status@plt>
mov    %eax,-0x14(%rbp)
jmp    128a <main+0x11a>
mov    $0x0,%al
call   1040 <launch_chat@plt>
mov    %eax,-0x14(%rbp)
jmp    128a <main+0x11a>
jmp    11a6 <main+0x36>
jmp    128f <main+0x11f>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%eax
and    $0xfffffffe,%eax
cmp    $0x2,%eax
jne    11db <main+0x6b>
mov    %edi,%ebp
mov    0x8(%rbx),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jne    11db <main+0x6b>
mov    0x8(%rbx),%rax
movsbl (%rax),%eax
add    $0xffffff9f,%eax
ror    %eax
cmp    $0x9,%eax
ja     11db <main+0x6b>
lea    0xe58(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmp    $0x3,%ebp
jne    11db <main+0x6b>
mov    0x10(%rbx),%rdi
lea    0xe85(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1060 <sscanf@plt>
cmp    $0x1,%eax
jne    11db <main+0x6b>
mov    0x4(%rsp),%edi
call   1070 <launch_clients@plt>
jmp    11f8 <main+0x88>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe3a(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1090 <get_server_status@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <launch_chat@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1080 <launch_server@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"usage: %s a|m|s|c num_client\0A\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %6
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %20
10: ; preds = %2
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 3
br i1 %12, label %13, label %20
13: ; preds = %10
br label %14
14: ; preds = %54, %44, %37, %26, %13
%15 = load i32, i32* @stderr
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %18)
br label %56
20: ; preds = %10, %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @strlen(i8* %23)
%25 = icmp ne i32 %24, 1
br i1 %25, label %26, label %27
26: ; preds = %20
br label %14
27: ; preds = %20
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = getelementptr inbounds i8, i8* %30, i64 0
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
switch i32 %33, label %54 [
i32 97, label %34
i32 115, label %48
i32 109, label %50
i32 99, label %52
]
34: ; preds = %27
%35 = load i32, i32* %4
%36 = icmp ne i32 %35, 3
br i1 %36, label %37, label %38
37: ; preds = %34
br label %14
38: ; preds = %34
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 2
%41 = load i8*, i8** %40
%42 = call i32 @sscanf(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%43 = icmp ne i32 %42, 1
br i1 %43, label %44, label %45
44: ; preds = %38
br label %14
45: ; preds = %38
%46 = load i32, i32* %7
%47 = call i32 @launch_clients(i32 %46)
store i32 %47, i32* %6
br label %55
48: ; preds = %27
%49 = call i32 (...) @launch_server()
store i32 %49, i32* %6
br label %55
50: ; preds = %27
%51 = call i32 (...) @get_server_status()
store i32 %51, i32* %6
br label %55
52: ; preds = %27
%53 = call i32 (...) @launch_chat()
store i32 %53, i32* %6
br label %55
54: ; preds = %27
br label %14
55: ; preds = %52, %50, %48, %45
br label %56
56: ; preds = %55, %14
%57 = load i32, i32* %6
ret i32 %57
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"usage: %s a|m|s|c num_client\0A\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp eq i32 %0, 3
%6 = and i32 %0, -2
%7 = icmp eq i32 %6, 2
br i1 %7, label %12, label %8
8: ; preds = %17, %24, %23, %12, %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %38
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32 @strlen(i8* %14)
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %8
17: ; preds = %12
%18 = load i8*, i8** %13
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = add nsw i32 %20, -97
%22 = tail call i32 @llvm.fshl.i32(i32 %21, i32 %21, i32 31)
switch i32 %22, label %8 [
i32 0, label %23
i32 9, label %32
i32 6, label %34
i32 1, label %36
]
23: ; preds = %17
br i1 %5, label %24, label %8
24: ; preds = %23
%25 = getelementptr inbounds i8*, i8** %1, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @sscanf(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %8
29: ; preds = %24
%30 = load i32, i32* %3
%31 = call i32 @launch_clients(i32 %30)
br label %38
32: ; preds = %17
%33 = tail call i32 (...) @launch_server()
br label %38
34: ; preds = %17
%35 = tail call i32 (...) @get_server_status()
br label %38
36: ; preds = %17
%37 = tail call i32 (...) @launch_chat()
br label %38
38: ; preds = %29, %32, %34, %36, %8
%39 = phi i32 [ -1, %8 ], [ %37, %36 ], [ %35, %34 ], [ %33, %32 ], [ %31, %29 ]
ret i32 %39
}