#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*/ list_command();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ quit_command();
int /*<<< orphan*/ send_all_command(char *);
int /*<<< orphan*/ send_command(char *, char *);
int sscanf(char const *, char *, char *, ...);
int /*<<< orphan*/ strcmp(char *, char *);
void command_dispatcher(const char *command) {
  char verb[255];
  int len;
  len = sscanf(command, "%s", verb);
  if (len < 1)
    return;
  if (!strcmp(verb, "quit")) {
    quit_command();
  } else if (!strcmp(verb, "send")) {
    char user[255];
    char message[1024];
    len = sscanf(command, "%s %s %s", verb, user, message);
    if (len < 3) {
      printf("send user message\n");
      return;
    }
    send_command(message, user);
  } else if (!strcmp(verb, "sendall")) {
    char message[1024];
    len = sscanf(command, "%s %s", verb, message);
    if (len < 2) {
      printf("sendall message\n");
      return;
    }
    send_all_command(message);
  } else if (!strcmp(verb, "list")) {
    list_command();
  }
}


x86 assembly (clang, -O0):
<command_dispatcher>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x110(%rbp),%rdx
lea    0xe7f(%rip),%rsi
mov    $0x0,%al
call   1060 <sscanf@plt>
mov    %eax,-0x114(%rbp)
cmpl   $0x1,-0x114(%rbp)
jge    11b0 <command_dispatcher+0x40>
jmp    12fa <command_dispatcher+0x18a>
lea    -0x110(%rbp),%rdi
lea    0xe42(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11d8 <command_dispatcher+0x68>
mov    $0x0,%al
call   1040 <quit_command@plt>
jmp    12fa <command_dispatcher+0x18a>
lea    -0x110(%rbp),%rdi
lea    0xe1f(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1257 <command_dispatcher+0xe7>
mov    -0x8(%rbp),%rdi
lea    -0x110(%rbp),%rdx
lea    -0x220(%rbp),%rcx
lea    -0x620(%rbp),%r8
lea    0xdf6(%rip),%rsi
mov    $0x0,%al
call   1060 <sscanf@plt>
mov    %eax,-0x114(%rbp)
cmpl   $0x3,-0x114(%rbp)
jge    123f <command_dispatcher+0xcf>
lea    0xdde(%rip),%rdi
call   1030 <printf@plt>
jmp    12fa <command_dispatcher+0x18a>
lea    -0x620(%rbp),%rdi
lea    -0x220(%rbp),%rsi
call   1080 <send_command@plt>
jmp    12f5 <command_dispatcher+0x185>
lea    -0x110(%rbp),%rdi
lea    0xdc1(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    12c8 <command_dispatcher+0x158>
mov    -0x8(%rbp),%rdi
lea    -0x110(%rbp),%rdx
lea    -0xa20(%rbp),%rcx
lea    0xd81(%rip),%rsi
mov    $0x0,%al
call   1060 <sscanf@plt>
mov    %eax,-0x114(%rbp)
cmpl   $0x2,-0x114(%rbp)
jge    12b7 <command_dispatcher+0x147>
lea    0xd81(%rip),%rdi
call   1030 <printf@plt>
jmp    12fa <command_dispatcher+0x18a>
lea    -0xa20(%rbp),%rdi
call   1070 <send_all_command@plt>
jmp    12f0 <command_dispatcher+0x180>
lea    -0x110(%rbp),%rdi
lea    0xd69(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    12eb <command_dispatcher+0x17b>
mov    $0x0,%al
call   1090 <list_command@plt>
jmp    12f0 <command_dispatcher+0x180>
jmp    12f5 <command_dispatcher+0x185>
jmp    12fa <command_dispatcher+0x18a>
add    $0xa20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<command_dispatcher>:
push   %rbx
sub    $0x600,%rsp
mov    %rdi,%rbx
lea    0xe9e(%rip),%rsi
mov    %rsp,%rdx
xor    %eax,%eax
call   1050 <sscanf@plt>
test   %eax,%eax
jle    1263 <command_dispatcher+0x103>
mov    $0x74697571,%eax
xor    (%rsp),%eax
movzbl 0x4(%rsp),%ecx
or     %eax,%ecx
je     11e5 <command_dispatcher+0x85>
mov    $0x646e6573,%eax
xor    (%rsp),%eax
movzbl 0x4(%rsp),%ecx
or     %eax,%ecx
je     11ee <command_dispatcher+0x8e>
movabs $0x6c6c61646e6573,%rax
cmp    %rax,(%rsp)
jne    1225 <command_dispatcher+0xc5>
lea    0xe50(%rip),%rsi
mov    %rsp,%rdx
lea    0x200(%rsp),%rcx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <sscanf@plt>
cmp    $0x1,%eax
jg     1256 <command_dispatcher+0xf6>
lea    0xe4c(%rip),%rdi
call   1030 <puts@plt>
jmp    1263 <command_dispatcher+0x103>
xor    %eax,%eax
call   1040 <quit_command@plt>
jmp    1263 <command_dispatcher+0x103>
lea    0xe15(%rip),%rsi
mov    %rsp,%rdx
lea    0x100(%rsp),%rcx
lea    0x200(%rsp),%r8
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <sscanf@plt>
cmp    $0x2,%eax
jg     123f <command_dispatcher+0xdf>
lea    0xdfa(%rip),%rdi
call   1030 <puts@plt>
jmp    1263 <command_dispatcher+0x103>
mov    $0x7473696c,%eax
xor    (%rsp),%eax
movzbl 0x4(%rsp),%ecx
or     %eax,%ecx
jne    1263 <command_dispatcher+0x103>
xor    %eax,%eax
call   1080 <list_command@plt>
jmp    1263 <command_dispatcher+0x103>
lea    0x200(%rsp),%rdi
lea    0x100(%rsp),%rsi
call   1070 <send_command@plt>
jmp    1263 <command_dispatcher+0x103>
lea    0x200(%rsp),%rdi
call   1060 <send_all_command@plt>
add    $0x600,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"quit\00"
@.str.2 = [5 x i8] c"send\00"
@.str.3 = [9 x i8] c"%s %s %s\00"
@.str.4 = [19 x i8] c"send user message\0A\00"
@.str.5 = [8 x i8] c"sendall\00"
@.str.6 = [6 x i8] c"%s %s\00"
@.str.7 = [17 x i8] c"sendall message\0A\00"
@.str.8 = [5 x i8] c"list\00"
define void @command_dispatcher(i8* %0) {
%2 = alloca i8*
%3 = alloca [255 x i8]
%4 = alloca i32
%5 = alloca [255 x i8]
%6 = alloca [1024 x i8]
%7 = alloca [1024 x i8]
store i8* %0, i8** %2
%8 = load i8*, i8** %2
%9 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%10 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %9)
store i32 %10, i32* %4
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 1
br i1 %12, label %13, label %14
13: ; preds = %1
br label %63
14: ; preds = %1
%15 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %14
%19 = call i32 (...) @quit_command()
br label %63
20: ; preds = %14
%21 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%22 = call i32 @strcmp(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp ne i32 %22, 0
br i1 %23, label %38, label %24
24: ; preds = %20
%25 = load i8*, i8** %2
%26 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%27 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%29 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %25, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %26, i8* %27, i8* %28)
store i32 %29, i32* %4
%30 = load i32, i32* %4
%31 = icmp slt i32 %30, 3
br i1 %31, label %32, label %34
32: ; preds = %24
%33 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
br label %63
34: ; preds = %24
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%36 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%37 = call i32 @send_command(i8* %35, i8* %36)
br label %62
38: ; preds = %20
%39 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%40 = call i32 @strcmp(i8* %39, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%41 = icmp ne i32 %40, 0
br i1 %41, label %54, label %42
42: ; preds = %38
%43 = load i8*, i8** %2
%44 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%45 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%46 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %43, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* %44, i8* %45)
store i32 %46, i32* %4
%47 = load i32, i32* %4
%48 = icmp slt i32 %47, 2
br i1 %48, label %49, label %51
49: ; preds = %42
%50 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
br label %63
51: ; preds = %42
%52 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%53 = call i32 @send_all_command(i8* %52)
br label %61
54: ; preds = %38
%55 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%56 = call i32 @strcmp(i8* %55, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%57 = icmp ne i32 %56, 0
br i1 %57, label %60, label %58
58: ; preds = %54
%59 = call i32 (...) @list_command()
br label %60
60: ; preds = %58, %54
br label %61
61: ; preds = %60, %51
br label %62
62: ; preds = %61, %34
br label %63
63: ; preds = %13, %32, %49, %62, %18
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"quit\00"
@.str.2 = [5 x i8] c"send\00"
@.str.3 = [9 x i8] c"%s %s %s\00"
@.str.6 = [6 x i8] c"%s %s\00"
@.str.8 = [5 x i8] c"list\00"
@str = [18 x i8] c"send user message\00"
@str.9 = [16 x i8] c"sendall message\00"
define void @command_dispatcher(i8* nocapture %0) {
%2 = alloca [255 x i8]
%3 = alloca [255 x i8]
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
%6 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%7 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = icmp slt i32 %7, 1
br i1 %8, label %45, label %9
9: ; preds = %1
%10 = call i32 @bcmp(i8* dereferenceable(5) %6, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 5)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 (...) @quit_command()
br label %45
14: ; preds = %9
%15 = call i32 @bcmp(i8* dereferenceable(5) %6, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 5)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %27
17: ; preds = %14
%18 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%20 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %6, i8* %18, i8* %19)
%21 = icmp slt i32 %20, 3
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %26
24: ; preds = %17
%25 = call i32 @send_command(i8* %19, i8* %18)
br label %26
26: ; preds = %24, %22
br label %45
27: ; preds = %14
%28 = bitcast [255 x i8]* %2 to i64*
%29 = load i64, i64* %28
%30 = icmp eq i64 %29, 30518463037334899
br i1 %30, label %31, label %40
31: ; preds = %27
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%33 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* %6, i8* %32)
%34 = icmp slt i32 %33, 2
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.9, i64 0, i64 0))
br label %39
37: ; preds = %31
%38 = call i32 @send_all_command(i8* %32)
br label %39
39: ; preds = %37, %35
br label %45
40: ; preds = %27
%41 = call i32 @bcmp(i8* dereferenceable(5) %6, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i64 5)
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = call i32 (...) @list_command()
br label %45
45: ; preds = %39, %26, %12, %43, %40, %1
ret void
}