#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 */
char *strstr(char *, char *);
int check_command(char *p) {
  if (strstr(p, "CONNECT") == p) {
    return 0;
  }
  if (strstr(p, "DISCONNECT") == p) {
    return 1;
  }
  if (strstr(p, "GETSECTOR") == p) {
    return 2;
  }
  return -1;
}


x86 assembly (clang, -O0):
<check_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xedc(%rip),%rsi
call   1030 <strstr@plt>
cmp    -0x10(%rbp),%rax
jne    1142 <check_command+0x32>
movl   $0x0,-0x4(%rbp)
jmp    1195 <check_command+0x85>
mov    -0x10(%rbp),%rdi
lea    0xeb3(%rip),%rsi
call   1030 <strstr@plt>
cmp    -0x10(%rbp),%rax
jne    1168 <check_command+0x58>
movl   $0x1,-0x4(%rbp)
jmp    1195 <check_command+0x85>
mov    -0x10(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1030 <strstr@plt>
cmp    -0x10(%rbp),%rax
jne    118e <check_command+0x7e>
movl   $0x2,-0x4(%rbp)
jmp    1195 <check_command+0x85>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_command>:
push   %rbx
mov    %rdi,%rbx
lea    0xee8(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     115e <check_command+0x4e>
lea    0xed0(%rip),%rsi
mov    $0xa,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     1162 <check_command+0x52>
lea    0xec3(%rip),%rsi
mov    $0x9,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
neg    %eax
sbb    %eax,%eax
or     $0x2,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"CONNECT\00"
@.str.1 = [11 x i8] c"DISCONNECT\00"
@.str.2 = [10 x i8] c"GETSECTOR\00"
define i32 @check_command(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i8* @strstr(i8* %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%6 = load i8*, i8** %3
%7 = icmp eq i8* %5, %6
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 0, i32* %2
br label %22
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i8* @strstr(i8* %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%12 = load i8*, i8** %3
%13 = icmp eq i8* %11, %12
br i1 %13, label %14, label %15
14: ; preds = %9
store i32 1, i32* %2
br label %22
15: ; preds = %9
%16 = load i8*, i8** %3
%17 = call i8* @strstr(i8* %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%18 = load i8*, i8** %3
%19 = icmp eq i8* %17, %18
br i1 %19, label %20, label %21
20: ; preds = %15
store i32 2, i32* %2
br label %22
21: ; preds = %15
store i32 -1, i32* %2
br label %22
22: ; preds = %21, %20, %14, %8
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
@.str = [8 x i8] c"CONNECT\00"
@.str.1 = [11 x i8] c"DISCONNECT\00"
@.str.2 = [10 x i8] c"GETSECTOR\00"
define i32 @check_command(i8* nocapture %0) {
%2 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 7)
%3 = icmp eq i32 %2, 0
br i1 %3, label %11, label %4
4: ; preds = %1
%5 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i64 10)
%6 = icmp eq i32 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i64 9)
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i32 2, i32 -1
br label %11
11: ; preds = %7, %4, %1
%12 = phi i32 [ 0, %1 ], [ 1, %4 ], [ %10, %7 ]
ret i32 %12
}