#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 */
typedef int uint8_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ setM0Forward(int, int);
int /*<<< orphan*/ setM0Reverse(int, int);
int /*<<< orphan*/ setM1Forward(int, int);
int /*<<< orphan*/ setM1Reverse(int, int);
scalar_t__ strcmp(char *, char *);
char *strtok(char *, char const *);
void processMotorControl(char *postContent) {
  uint8_t speed;
  char *dir, *start;
  const char delim[2] = "_";
  dir = strtok(postContent, delim);
  start = strtok(NULL, delim);
  printf("processMotorControl (%s) %s\n", dir, start);
  if (0 == strcmp(start, "START")) {
    speed = 0xFF;
  } else if (0 == strcmp(start, "STOP")) {
    speed = 0;
  } else {
    return;
  }
  if (0 == strcmp(dir, "UP")) {
    setM0Forward(0x09, speed);
    setM1Forward(0x09, speed);
  } else if (0 == strcmp(dir, "DOWN")) {
    setM0Reverse(0x09, speed);
    setM1Reverse(0x09, speed);
  } else if (0 == strcmp(dir, "LEFT")) {
    setM0Forward(0x09, speed);
    setM1Reverse(0x09, speed);
  } else if (0 == strcmp(dir, "RIGHT")) {
    setM0Reverse(0x09, speed);
    setM1Forward(0x09, speed);
  } else {
    return;
  }
}


x86 assembly (clang, -O0):
<processMotorControl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0xe7d(%rip),%ax
mov    %ax,-0x22(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x22(%rbp),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x18(%rbp)
lea    -0x22(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1080 <strtok@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe4a(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
lea    0xe57(%rip),%rsi
call   1070 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11e7 <processMotorControl+0x77>
movl   $0xff,-0xc(%rbp)
jmp    121b <processMotorControl+0xab>
mov    -0x20(%rbp),%rdi
lea    0xe33(%rip),%rsi
call   1070 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1211 <processMotorControl+0xa1>
movl   $0x0,-0xc(%rbp)
jmp    1216 <processMotorControl+0xa6>
jmp    1323 <processMotorControl+0x1b3>
jmp    121b <processMotorControl+0xab>
mov    -0x18(%rbp),%rdi
lea    0xe04(%rip),%rsi
call   1070 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1258 <processMotorControl+0xe8>
mov    -0xc(%rbp),%esi
mov    $0x9,%edi
call   1030 <setM0Forward@plt>
mov    -0xc(%rbp),%esi
mov    $0x9,%edi
call   1040 <setM1Forward@plt>
jmp    1323 <processMotorControl+0x1b3>
mov    -0x18(%rbp),%rdi
lea    0xdca(%rip),%rsi
call   1070 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1295 <processMotorControl+0x125>
mov    -0xc(%rbp),%esi
mov    $0x9,%edi
call   1090 <setM0Reverse@plt>
mov    -0xc(%rbp),%esi
mov    $0x9,%edi
call   1060 <setM1Reverse@plt>
jmp    131e <processMotorControl+0x1ae>
mov    -0x18(%rbp),%rdi
lea    0xd92(%rip),%rsi
call   1070 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    12d2 <processMotorControl+0x162>
mov    -0xc(%rbp),%esi
mov    $0x9,%edi
call   1030 <setM0Forward@plt>
mov    -0xc(%rbp),%esi
mov    $0x9,%edi
call   1060 <setM1Reverse@plt>
jmp    1319 <processMotorControl+0x1a9>
mov    -0x18(%rbp),%rdi
lea    0xd5a(%rip),%rsi
call   1070 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    130f <processMotorControl+0x19f>
mov    -0xc(%rbp),%esi
mov    $0x9,%edi
call   1090 <setM0Reverse@plt>
mov    -0xc(%rbp),%esi
mov    $0x9,%edi
call   1040 <setM1Forward@plt>
jmp    1314 <processMotorControl+0x1a4>
jmp    1323 <processMotorControl+0x1b3>
jmp    1319 <processMotorControl+0x1a9>
jmp    131e <processMotorControl+0x1ae>
jmp    1323 <processMotorControl+0x1b3>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<processMotorControl>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movw   $0x5f,0xe(%rsp)
lea    0xe(%rsp),%rbx
mov    %rbx,%rsi
call   1080 <strtok@plt>
mov    %rax,%r15
xor    %r14d,%r14d
xor    %edi,%edi
mov    %rbx,%rsi
call   1080 <strtok@plt>
mov    %rax,%rbx
lea    0xe59(%rip),%rdi
mov    %r15,%rsi
mov    %rax,%rdx
call   1050 <printf@plt>
lea    0xe64(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11e4 <processMotorControl+0x74>
lea    0xe56(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11ea <processMotorControl+0x7a>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    $0xff,%r14d
lea    0xe37(%rip),%rsi
mov    %r15,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1249 <processMotorControl+0xd9>
lea    0xe26(%rip),%rsi
mov    %r15,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     126c <processMotorControl+0xfc>
lea    0xe17(%rip),%rsi
mov    %r15,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     127b <processMotorControl+0x10b>
lea    0xe08(%rip),%rsi
mov    %r15,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    11da <processMotorControl+0x6a>
mov    $0x9,%edi
mov    %r14d,%esi
call   1090 <setM0Reverse@plt>
jmp    1256 <processMotorControl+0xe6>
mov    $0x9,%edi
mov    %r14d,%esi
call   1030 <setM0Forward@plt>
mov    $0x9,%edi
mov    %r14d,%esi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <setM1Forward@plt>
mov    $0x9,%edi
mov    %r14d,%esi
call   1090 <setM0Reverse@plt>
jmp    1288 <processMotorControl+0x118>
mov    $0x9,%edi
mov    %r14d,%esi
call   1030 <setM0Forward@plt>
mov    $0x9,%edi
mov    %r14d,%esi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <setM1Reverse@plt>

LLVM IR (-O0):
@__const.processMotorControl.delim = [2 x i8] c"_\00"
@.str = [29 x i8] c"processMotorControl (%s) %s\0A\00"
@.str.1 = [6 x i8] c"START\00"
@.str.2 = [5 x i8] c"STOP\00"
@.str.3 = [3 x i8] c"UP\00"
@.str.4 = [5 x i8] c"DOWN\00"
@.str.5 = [5 x i8] c"LEFT\00"
@.str.6 = [6 x i8] c"RIGHT\00"
define void @processMotorControl(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [2 x i8]
store i8* %0, i8** %2
%7 = bitcast [2 x i8]* %6 to i8*
%8 = load i8*, i8** %2
%9 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
%10 = call i8* @strtok(i8* %8, i8* %9)
store i8* %10, i8** %4
%11 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
%12 = call i8* @strtok(i8* null, i8* %11)
store i8* %12, i8** %5
%13 = load i8*, i8** %4
%14 = load i8*, i8** %5
%15 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %14)
%16 = load i8*, i8** %5
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 0, %17
br i1 %18, label %19, label %20
19: ; preds = %1
store i32 255, i32* %3
br label %27
20: ; preds = %1
%21 = load i8*, i8** %5
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i64 0, %22
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 0, i32* %3
br label %26
25: ; preds = %20
br label %67
26: ; preds = %24
br label %27
27: ; preds = %26, %19
%28 = load i8*, i8** %4
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%30 = icmp eq i64 0, %29
br i1 %30, label %31, label %36
31: ; preds = %27
%32 = load i32, i32* %3
%33 = call i32 @setM0Forward(i32 9, i32 %32)
%34 = load i32, i32* %3
%35 = call i32 @setM1Forward(i32 9, i32 %34)
br label %67
36: ; preds = %27
%37 = load i8*, i8** %4
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%39 = icmp eq i64 0, %38
br i1 %39, label %40, label %45
40: ; preds = %36
%41 = load i32, i32* %3
%42 = call i32 @setM0Reverse(i32 9, i32 %41)
%43 = load i32, i32* %3
%44 = call i32 @setM1Reverse(i32 9, i32 %43)
br label %66
45: ; preds = %36
%46 = load i8*, i8** %4
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%48 = icmp eq i64 0, %47
br i1 %48, label %49, label %54
49: ; preds = %45
%50 = load i32, i32* %3
%51 = call i32 @setM0Forward(i32 9, i32 %50)
%52 = load i32, i32* %3
%53 = call i32 @setM1Reverse(i32 9, i32 %52)
br label %65
54: ; preds = %45
%55 = load i8*, i8** %4
%56 = call i64 @strcmp(i8* %55, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%57 = icmp eq i64 0, %56
br i1 %57, label %58, label %63
58: ; preds = %54
%59 = load i32, i32* %3
%60 = call i32 @setM0Reverse(i32 9, i32 %59)
%61 = load i32, i32* %3
%62 = call i32 @setM1Forward(i32 9, i32 %61)
br label %64
63: ; preds = %54
br label %67
64: ; preds = %58
br label %65
65: ; preds = %64, %49
br label %66
66: ; preds = %65, %40
br label %67
67: ; preds = %25, %63, %66, %31
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"processMotorControl (%s) %s\0A\00"
@.str.1 = [6 x i8] c"START\00"
@.str.2 = [5 x i8] c"STOP\00"
@.str.3 = [3 x i8] c"UP\00"
@.str.4 = [5 x i8] c"DOWN\00"
@.str.5 = [5 x i8] c"LEFT\00"
@.str.6 = [6 x i8] c"RIGHT\00"
define void @processMotorControl(i8* %0) {
%2 = alloca i16
%3 = bitcast i16* %2 to i8*
store i16 95, i16* %2
%4 = call i8* @strtok(i8* %0, i8* %3)
%5 = call i8* @strtok(i8* null, i8* %3)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %4, i8* %5)
%7 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %1
%10 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %37
12: ; preds = %9, %1
%13 = phi i32 [ 255, %1 ], [ 0, %9 ]
%14 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = tail call i32 @setM0Forward(i32 9, i32 %13)
%18 = tail call i32 @setM1Forward(i32 9, i32 %13)
br label %37
19: ; preds = %12
%20 = tail call i64 @strcmp(i8* %4, 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 = %19
%23 = tail call i32 @setM0Reverse(i32 9, i32 %13)
%24 = tail call i32 @setM1Reverse(i32 9, i32 %13)
br label %37
25: ; preds = %19
%26 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = tail call i32 @setM0Forward(i32 9, i32 %13)
%30 = tail call i32 @setM1Reverse(i32 9, i32 %13)
br label %37
31: ; preds = %25
%32 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = tail call i32 @setM0Reverse(i32 9, i32 %13)
%36 = tail call i32 @setM1Forward(i32 9, i32 %13)
br label %37
37: ; preds = %16, %28, %34, %22, %31, %9
ret void
}