#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 atoi(char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int parse_command(char *command, int params[]) {
  if (!strcmp(command, "/join")) {
    return 0;
  } else if (!strcmp(command, "/ready")) {
    return 1;
  } else if (!strcmp(command, "/area")) {
    return 2;
  } else if (!strncmp(command, "/place", 6)) {
    params[0] = atoi(&command[7]);
    return 3;
  } else if (!strcmp(command, "/quit")) {
    return 4;
  }
  return 255;
}


x86 assembly (clang, -O0):
<parse_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1165 <parse_command+0x35>
movl   $0x0,-0x4(%rbp)
jmp    122e <parse_command+0xfe>
mov    -0x10(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    118a <parse_command+0x5a>
movl   $0x1,-0x4(%rbp)
jmp    122e <parse_command+0xfe>
mov    -0x10(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11af <parse_command+0x7f>
movl   $0x2,-0x4(%rbp)
jmp    122e <parse_command+0xfe>
mov    -0x10(%rbp),%rdi
lea    0xe59(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11ee <parse_command+0xbe>
mov    -0x10(%rbp),%rdi
add    $0x7,%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x3,-0x4(%rbp)
jmp    122e <parse_command+0xfe>
mov    -0x10(%rbp),%rdi
lea    0xe21(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1213 <parse_command+0xe3>
movl   $0x4,-0x4(%rbp)
jmp    122e <parse_command+0xfe>
jmp    1218 <parse_command+0xe8>
jmp    121d <parse_command+0xed>
jmp    1222 <parse_command+0xf2>
jmp    1227 <parse_command+0xf7>
movl   $0xff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_command>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xebf(%rip),%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11a8 <parse_command+0x78>
lea    0xeb5(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11ac <parse_command+0x7c>
lea    0xea9(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11b3 <parse_command+0x83>
lea    0xe9c(%rip),%rsi
mov    %rbx,%rdi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11ba <parse_command+0x8a>
lea    0xe8b(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
mov    $0x4,%ecx
mov    $0xff,%eax
cmove  %ecx,%eax
jmp    11ce <parse_command+0x9e>
xor    %eax,%eax
jmp    11ce <parse_command+0x9e>
mov    $0x1,%eax
jmp    11ce <parse_command+0x9e>
mov    $0x2,%eax
jmp    11ce <parse_command+0x9e>
add    $0x7,%rbx
mov    %rbx,%rdi
call   1050 <atoi@plt>
mov    %eax,(%r14)
mov    $0x3,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [6 x i8] c"/join\00"
@.str.1 = [7 x i8] c"/ready\00"
@.str.2 = [6 x i8] c"/area\00"
@.str.3 = [7 x i8] c"/place\00"
@.str.4 = [6 x i8] c"/quit\00"
define i32 @parse_command(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
store i8* %0, i8** %4
store i32* %1, i32** %5
%6 = load i8*, i8** %4
%7 = call i32 @strcmp(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i32 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %2
store i32 0, i32* %3
br label %40
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = call i32 @strcmp(i8* %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp ne i32 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %10
store i32 1, i32* %3
br label %40
15: ; preds = %10
%16 = load i8*, i8** %4
%17 = call i32 @strcmp(i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp ne i32 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %15
store i32 2, i32* %3
br label %40
20: ; preds = %15
%21 = load i8*, i8** %4
%22 = call i32 @strncmp(i8* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6)
%23 = icmp ne i32 %22, 0
br i1 %23, label %30, label %24
24: ; preds = %20
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i64 7
%27 = call i32 @atoi(i8* %26)
%28 = load i32*, i32** %5
%29 = getelementptr inbounds i32, i32* %28, i64 0
store i32 %27, i32* %29
store i32 3, i32* %3
br label %40
30: ; preds = %20
%31 = load i8*, i8** %4
%32 = call i32 @strcmp(i8* %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%33 = icmp ne i32 %32, 0
br i1 %33, label %35, label %34
34: ; preds = %30
store i32 4, i32* %3
br label %40
35: ; preds = %30
br label %36
36: ; preds = %35
br label %37
37: ; preds = %36
br label %38
38: ; preds = %37
br label %39
39: ; preds = %38
store i32 255, i32* %3
br label %40
40: ; preds = %39, %34, %24, %19, %14, %9
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str = [6 x i8] c"/join\00"
@.str.1 = [7 x i8] c"/ready\00"
@.str.2 = [6 x i8] c"/area\00"
@.str.3 = [7 x i8] c"/place\00"
@.str.4 = [6 x i8] c"/quit\00"
define i32 @parse_command(i8* %0, i32* nocapture writeonly %1) {
%3 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, 0
br i1 %4, label %21, label %5
5: ; preds = %2
%6 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %21, label %8
8: ; preds = %5
%9 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %21, label %11
11: ; preds = %8
%12 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = getelementptr inbounds i8, i8* %0, i64 7
%16 = tail call i32 @atoi(i8* %15)
store i32 %16, i32* %1
br label %21
17: ; preds = %11
%18 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
%20 = select i1 %19, i32 4, i32 255
br label %21
21: ; preds = %17, %8, %5, %2, %14
%22 = phi i32 [ 3, %14 ], [ 0, %2 ], [ 1, %5 ], [ 2, %8 ], [ %20, %17 ]
ret i32 %22
}