#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*/ join_command(int);
int /*<<< orphan*/ leave_command(int);
int /*<<< orphan*/ quit_command();
int /*<<< orphan*/ send_command(int, char *);
int /*<<< orphan*/ show_command(char);
int /*<<< orphan*/ sscanf(char const *, char *, char *, ...);
scalar_t__ strcmp(char *, char *);
void command_dispatcher(const char *command) {
  int group_id;
  char message_body[1024];
  char verb[1024];
  sscanf(command, "%s", verb);
  if (strcmp(verb, "join") == 0) {
    sscanf(command, "%s %d", verb, &group_id);
    join_command(group_id);
  } else if (strcmp(verb, "send") == 0) {
    sscanf(command, "%s %d %[^\n]%*c", verb, &group_id, message_body);
    send_command(group_id, message_body);
  } else if (strcmp(verb, "leave") == 0) {
    sscanf(command, "%s %d", verb, &group_id);
    leave_command(group_id);
  } else if (strcmp(verb, "show") == 0) {
    char show_c;
    sscanf(command, "%s %c", verb, &show_c);
    show_command(show_c);
  } else if (strcmp(verb, "quit") == 0) {
    quit_command();
  }
}


x86 assembly (clang, -O0):
<command_dispatcher>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x810(%rbp),%rdx
lea    0xe6f(%rip),%rsi
mov    $0x0,%al
call   1070 <sscanf@plt>
lea    -0x810(%rbp),%rdi
lea    0xe5d(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11df <command_dispatcher+0x6f>
mov    -0x8(%rbp),%rdi
lea    -0x810(%rbp),%rdx
lea    0xe41(%rip),%rsi
lea    -0xc(%rbp),%rcx
mov    $0x0,%al
call   1070 <sscanf@plt>
mov    -0xc(%rbp),%edi
call   1080 <join_command@plt>
jmp    1301 <command_dispatcher+0x191>
lea    -0x810(%rbp),%rdi
lea    0xe21(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1234 <command_dispatcher+0xc4>
mov    -0x8(%rbp),%rdi
lea    -0x810(%rbp),%rdx
lea    -0x410(%rbp),%r8
lea    0xdfe(%rip),%rsi
lea    -0xc(%rbp),%rcx
mov    $0x0,%al
call   1070 <sscanf@plt>
mov    -0xc(%rbp),%edi
lea    -0x410(%rbp),%rsi
call   1090 <send_command@plt>
jmp    12fc <command_dispatcher+0x18c>
lea    -0x810(%rbp),%rdi
lea    0xde0(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    127b <command_dispatcher+0x10b>
mov    -0x8(%rbp),%rdi
lea    -0x810(%rbp),%rdx
lea    0xda5(%rip),%rsi
lea    -0xc(%rbp),%rcx
mov    $0x0,%al
call   1070 <sscanf@plt>
mov    -0xc(%rbp),%edi
call   1030 <leave_command@plt>
jmp    12f7 <command_dispatcher+0x187>
lea    -0x810(%rbp),%rdi
lea    0xd9f(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12c9 <command_dispatcher+0x159>
mov    -0x8(%rbp),%rdi
lea    -0x810(%rbp),%rdx
lea    0xd83(%rip),%rsi
lea    -0x811(%rbp),%rcx
mov    $0x0,%al
call   1070 <sscanf@plt>
movsbl -0x811(%rbp),%edi
call   1040 <show_command@plt>
jmp    12f2 <command_dispatcher+0x182>
lea    -0x810(%rbp),%rdi
lea    0xd5c(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12ed <command_dispatcher+0x17d>
mov    $0x0,%al
call   1050 <quit_command@plt>
jmp    12f2 <command_dispatcher+0x182>
jmp    12f7 <command_dispatcher+0x187>
jmp    12fc <command_dispatcher+0x18c>
jmp    1301 <command_dispatcher+0x191>
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<command_dispatcher>:
push   %r14
push   %rbx
sub    $0x818,%rsp
mov    %rdi,%r14
lea    0xe7c(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <sscanf@plt>
lea    0xe69(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     121b <command_dispatcher+0xab>
lea    0xe60(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1244 <command_dispatcher+0xd4>
lea    0xe5a(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1278 <command_dispatcher+0x108>
lea    0xe46(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     129e <command_dispatcher+0x12e>
lea    0xe37(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    12c9 <command_dispatcher+0x159>
xor    %eax,%eax
call   1050 <quit_command@plt>
jmp    12c9 <command_dispatcher+0x159>
lea    0xde6(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <sscanf@plt>
mov    0xc(%rsp),%edi
call   1080 <join_command@plt>
jmp    12c9 <command_dispatcher+0x159>
lea    0xdc8(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x410(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%r8
xor    %eax,%eax
call   1070 <sscanf@plt>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
call   1090 <send_command@plt>
jmp    12c9 <command_dispatcher+0x159>
lea    0xd89(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <sscanf@plt>
mov    0xc(%rsp),%edi
call   1030 <leave_command@plt>
jmp    12c9 <command_dispatcher+0x159>
lea    0xd88(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0x410(%rsp),%rcx
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <sscanf@plt>
movsbl 0x410(%rsp),%edi
call   1040 <show_command@plt>
add    $0x818,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"join\00"
@.str.2 = [6 x i8] c"%s %d\00"
@.str.3 = [5 x i8] c"send\00"
@.str.4 = [15 x i8] c"%s %d %[^\0A]%*c\00"
@.str.5 = [6 x i8] c"leave\00"
@.str.6 = [5 x i8] c"show\00"
@.str.7 = [6 x i8] c"%s %c\00"
@.str.8 = [5 x i8] c"quit\00"
define void @command_dispatcher(i8* nocapture %0) {
%2 = alloca i32
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca i8
%6 = bitcast i32* %2 to i8*
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%9 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %1
%13 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %8, i32* %2)
%14 = load i32, i32* %2
%15 = call i32 @join_command(i32 %14)
br label %42
16: ; preds = %1
%17 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %8, i32* %2, i8* %7)
%21 = load i32, i32* %2
%22 = call i32 @send_command(i32 %21, i8* %7)
br label %42
23: ; preds = %16
%24 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %8, i32* %2)
%28 = load i32, i32* %2
%29 = call i32 @leave_command(i32 %28)
br label %42
30: ; preds = %23
%31 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %8, i8* %5)
%35 = load i8, i8* %5
%36 = call i32 @show_command(i8 signext %35)
br label %42
37: ; preds = %30
%38 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = call i32 (...) @quit_command()
br label %42
42: ; preds = %19, %33, %40, %37, %26, %12
ret void
}