#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 */
scalar_t__ strncmp(char *, char *, int);
int control_command(char *cmdbuffer, char **arg_offset) {
  if (strncmp(cmdbuffer, "return", 6) == 0) {
    *arg_offset = &cmdbuffer[7];
    return 1;
  } else if (strncmp(cmdbuffer, "delete", 6) == 0) {
    *arg_offset = &cmdbuffer[7];
    return 5;
  } else if (strncmp(cmdbuffer, "export", 6) == 0) {
    *arg_offset = &cmdbuffer[7];
    return 3;
  } else if (strncmp(cmdbuffer, "import", 6) == 0) {
    *arg_offset = &cmdbuffer[7];
    return 2;
  } else if (strncmp(cmdbuffer, "shutdown", 8) == 0) {
    *arg_offset = NULL;
    return 6;
  }
  *arg_offset = cmdbuffer;
  return -1;
}


x86 assembly (clang, -O0):
<control_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed5(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    115a <control_command+0x4a>
mov    -0x10(%rbp),%rcx
add    $0x7,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1264 <control_command+0x154>
mov    -0x10(%rbp),%rdi
lea    0xea2(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1194 <control_command+0x84>
mov    -0x10(%rbp),%rcx
add    $0x7,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x5,-0x4(%rbp)
jmp    1264 <control_command+0x154>
mov    -0x10(%rbp),%rdi
lea    0xe6f(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11ce <control_command+0xbe>
mov    -0x10(%rbp),%rcx
add    $0x7,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x3,-0x4(%rbp)
jmp    1264 <control_command+0x154>
mov    -0x10(%rbp),%rdi
lea    0xe3c(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1208 <control_command+0xf8>
mov    -0x10(%rbp),%rcx
add    $0x7,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x2,-0x4(%rbp)
jmp    1264 <control_command+0x154>
mov    -0x10(%rbp),%rdi
lea    0xe09(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    123e <control_command+0x12e>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x6,-0x4(%rbp)
jmp    1264 <control_command+0x154>
jmp    1243 <control_command+0x133>
jmp    1248 <control_command+0x138>
jmp    124d <control_command+0x13d>
jmp    1252 <control_command+0x142>
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<control_command>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xedf(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11a0 <control_command+0x90>
lea    0xed0(%rip),%rsi
mov    %rbx,%rdi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11ab <control_command+0x9b>
lea    0xebe(%rip),%rsi
mov    %rbx,%rdi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11b6 <control_command+0xa6>
lea    0xeac(%rip),%rsi
mov    %rbx,%rdi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11c1 <control_command+0xb1>
lea    0xe9a(%rip),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
cmove  %rax,%rbx
neg    %rax
sbb    %eax,%eax
or     $0x6,%eax
jmp    11ca <control_command+0xba>
add    $0x7,%rbx
mov    $0x1,%eax
jmp    11ca <control_command+0xba>
add    $0x7,%rbx
mov    $0x5,%eax
jmp    11ca <control_command+0xba>
add    $0x7,%rbx
mov    $0x3,%eax
jmp    11ca <control_command+0xba>
add    $0x7,%rbx
mov    $0x2,%eax
mov    %rbx,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"return\00"
@.str.1 = [7 x i8] c"delete\00"
@.str.2 = [7 x i8] c"export\00"
@.str.3 = [7 x i8] c"import\00"
@.str.4 = [9 x i8] c"shutdown\00"
define i32 @control_command(i8* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8**
store i8* %0, i8** %4
store i8** %1, i8*** %5
%6 = load i8*, i8** %4
%7 = call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i64 7
%12 = load i8**, i8*** %5
store i8* %11, i8** %12
store i32 1, i32* %3
br label %50
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = call i64 @strncmp(i8* %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i64 7
%20 = load i8**, i8*** %5
store i8* %19, i8** %20
store i32 5, i32* %3
br label %50
21: ; preds = %13
%22 = load i8*, i8** %4
%23 = call i64 @strncmp(i8* %22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 6)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i64 7
%28 = load i8**, i8*** %5
store i8* %27, i8** %28
store i32 3, i32* %3
br label %50
29: ; preds = %21
%30 = load i8*, i8** %4
%31 = call i64 @strncmp(i8* %30, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %29
%34 = load i8*, i8** %4
%35 = getelementptr inbounds i8, i8* %34, i64 7
%36 = load i8**, i8*** %5
store i8* %35, i8** %36
store i32 2, i32* %3
br label %50
37: ; preds = %29
%38 = load i8*, i8** %4
%39 = call i64 @strncmp(i8* %38, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 8)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %37
%42 = load i8**, i8*** %5
store i8* null, i8** %42
store i32 6, i32* %3
br label %50
43: ; preds = %37
br label %44
44: ; preds = %43
br label %45
45: ; preds = %44
br label %46
46: ; preds = %45
br label %47
47: ; preds = %46
%48 = load i8*, i8** %4
%49 = load i8**, i8*** %5
store i8* %48, i8** %49
store i32 -1, i32* %3
br label %50
50: ; preds = %47, %41, %33, %25, %17, %9
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
@.str = [7 x i8] c"return\00"
@.str.1 = [7 x i8] c"delete\00"
@.str.2 = [7 x i8] c"export\00"
@.str.3 = [7 x i8] c"import\00"
@.str.4 = [9 x i8] c"shutdown\00"
define i32 @control_command(i8* %0, i8** nocapture writeonly %1) {
%3 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %0, i64 7
br label %27
7: ; preds = %2
%8 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = getelementptr inbounds i8, i8* %0, i64 7
br label %27
12: ; preds = %7
%13 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 6)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = getelementptr inbounds i8, i8* %0, i64 7
br label %27
17: ; preds = %12
%18 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = getelementptr inbounds i8, i8* %0, i64 7
br label %27
22: ; preds = %17
%23 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 8)
%24 = icmp eq i64 %23, 0
%25 = select i1 %24, i8* null, i8* %0
%26 = select i1 %24, i32 6, i32 -1
br label %27
27: ; preds = %22, %20, %15, %10, %5
%28 = phi i8* [ %21, %20 ], [ %16, %15 ], [ %11, %10 ], [ %6, %5 ], [ %25, %22 ]
%29 = phi i32 [ 2, %20 ], [ 3, %15 ], [ 5, %10 ], [ 1, %5 ], [ %26, %22 ]
store i8* %28, i8** %1
ret i32 %29
}