#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 EINVAL;
int do_execute_command(char *);
int do_read_command(char *);
int do_write_command(char *);
int /*<<< orphan*/ puts(char *);
scalar_t__ strcmp(char *, char *);
char *strsep(char **, char *);
int dispatch_command(char *command) {
  char *verb = strsep(&command, " ");
  if (strcmp(verb, "true") == 0) {
    puts("ok");
    return 0;
  } else if (strcmp(verb, "execute") == 0) {
    return do_execute_command(command);
  } else if (strcmp(verb, "read") == 0) {
    return do_read_command(command);
  } else if (strcmp(verb, "write") == 0) {
    return do_write_command(command);
  } else {
    return -EINVAL;
  }
}


x86 assembly (clang, -O0):
<dispatch_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1060 <strsep@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe77(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11b2 <dispatch_command+0x52>
lea    0xe66(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    1241 <dispatch_command+0xe1>
mov    -0x18(%rbp),%rdi
lea    0xe4d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11dd <dispatch_command+0x7d>
mov    -0x10(%rbp),%rdi
call   1080 <do_execute_command@plt>
mov    %eax,-0x4(%rbp)
jmp    1241 <dispatch_command+0xe1>
mov    -0x18(%rbp),%rdi
lea    0xe2a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1208 <dispatch_command+0xa8>
mov    -0x10(%rbp),%rdi
call   1050 <do_read_command@plt>
mov    %eax,-0x4(%rbp)
jmp    1241 <dispatch_command+0xe1>
mov    -0x18(%rbp),%rdi
lea    0xe04(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1233 <dispatch_command+0xd3>
mov    -0x10(%rbp),%rdi
call   1070 <do_write_command@plt>
mov    %eax,-0x4(%rbp)
jmp    1241 <dispatch_command+0xe1>
xor    %eax,%eax
mov    0x2da4(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dispatch_command>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,0x8(%rsp)
lea    0xe8f(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1060 <strsep@plt>
mov    %rax,%rbx
lea    0xe7d(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11db <dispatch_command+0x7b>
lea    0xe71(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11eb <dispatch_command+0x8b>
lea    0xe65(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11f7 <dispatch_command+0x97>
lea    0xe56(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1203 <dispatch_command+0xa3>
mov    0x2e0b(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
jmp    120d <dispatch_command+0xad>
lea    0xe25(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
jmp    120d <dispatch_command+0xad>
mov    0x8(%rsp),%rdi
call   1080 <do_execute_command@plt>
jmp    120d <dispatch_command+0xad>
mov    0x8(%rsp),%rdi
call   1050 <do_read_command@plt>
jmp    120d <dispatch_command+0xad>
mov    0x8(%rsp),%rdi
call   1070 <do_write_command@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [5 x i8] c"true\00"
@.str.2 = [3 x i8] c"ok\00"
@.str.3 = [8 x i8] c"execute\00"
@.str.4 = [5 x i8] c"read\00"
@.str.5 = [6 x i8] c"write\00"
@EINVAL = global i32 0
define i32 @dispatch_command(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = call i8* @strsep(i8** %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %5, i8** %4
%6 = load i8*, i8** %4
%7 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 @puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
br label %35
11: ; preds = %1
%12 = load i8*, i8** %4
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i8*, i8** %3
%17 = call i32 @do_execute_command(i8* %16)
store i32 %17, i32* %2
br label %35
18: ; preds = %11
%19 = load i8*, i8** %4
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i8*, i8** %3
%24 = call i32 @do_read_command(i8* %23)
store i32 %24, i32* %2
br label %35
25: ; preds = %18
%26 = load i8*, i8** %4
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i8*, i8** %3
%31 = call i32 @do_write_command(i8* %30)
store i32 %31, i32* %2
br label %35
32: ; preds = %25
%33 = load i32, i32* @EINVAL
%34 = sub nsw i32 0, %33
store i32 %34, i32* %2
br label %35
35: ; preds = %32, %29, %22, %15, %9
%36 = load i32, i32* %2
ret i32 %36
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [5 x i8] c"true\00"
@.str.2 = [3 x i8] c"ok\00"
@.str.3 = [8 x i8] c"execute\00"
@.str.4 = [5 x i8] c"read\00"
@.str.5 = [6 x i8] c"write\00"
@EINVAL = global i32 0
define i32 @dispatch_command(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = call i8* @strsep(i8** %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %29
8: ; preds = %1
%9 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i8*, i8** %2
%13 = call i32 @do_execute_command(i8* %12)
br label %29
14: ; preds = %8
%15 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i8*, i8** %2
%19 = call i32 @do_read_command(i8* %18)
br label %29
20: ; preds = %14
%21 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i8*, i8** %2
%25 = call i32 @do_write_command(i8* %24)
br label %29
26: ; preds = %20
%27 = load i32, i32* @EINVAL
%28 = sub nsw i32 0, %27
br label %29
29: ; preds = %26, %23, %17, %11, %6
%30 = phi i32 [ 0, %6 ], [ %13, %11 ], [ %19, %17 ], [ %25, %23 ], [ %28, %26 ]
ret i32 %30
}