#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 message(int, char *);
scalar_t__ strcmp(char *, char *);
int processBBBCommand(int client, char *command) {
  int return_val = -1;
  if (strcmp(command, "LED on") == 0) {
    return_val = message(client, "*** Turning the LED on  ***\n");
  } else if (strcmp(command, "LED off") == 0) {
    return_val = message(client, "*** Turning the LED off ***\n");
  } else if (strcmp(command, "quit") == 0) {
    return_val = message(client, "*** Killing the BBB Serial Server ***\n");
  } else {
    return_val = message(client, "*** Unknown command! ***\n");
  }
  return return_val;
}


x86 assembly (clang, -O0):
<processBBBCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xebf(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1167 <processBBBCommand+0x47>
mov    -0x4(%rbp),%edi
lea    0xead(%rip),%rsi
call   1030 <message@plt>
mov    %eax,-0x14(%rbp)
jmp    11e5 <processBBBCommand+0xc5>
mov    -0x10(%rbp),%rdi
lea    0xeb2(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1198 <processBBBCommand+0x78>
mov    -0x4(%rbp),%edi
lea    0xea1(%rip),%rsi
call   1030 <message@plt>
mov    %eax,-0x14(%rbp)
jmp    11e0 <processBBBCommand+0xc0>
mov    -0x10(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11c9 <processBBBCommand+0xa9>
mov    -0x4(%rbp),%edi
lea    0xe92(%rip),%rsi
call   1030 <message@plt>
mov    %eax,-0x14(%rbp)
jmp    11db <processBBBCommand+0xbb>
mov    -0x4(%rbp),%edi
lea    0xea2(%rip),%rsi
call   1030 <message@plt>
mov    %eax,-0x14(%rbp)
jmp    11e0 <processBBBCommand+0xc0>
jmp    11e5 <processBBBCommand+0xc5>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<processBBBCommand>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xed1(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1176 <processBBBCommand+0x56>
lea    0xee1(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     117f <processBBBCommand+0x5f>
lea    0xef2(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
lea    0xee5(%rip),%rax
lea    0xf05(%rip),%rsi
cmove  %rax,%rsi
jmp    1186 <processBBBCommand+0x66>
lea    0xe8a(%rip),%rsi
jmp    1186 <processBBBCommand+0x66>
lea    0xea6(%rip),%rsi
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <message@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"LED on\00"
@.str.1 = [29 x i8] c"*** Turning the LED on ***\0A\00"
@.str.2 = [8 x i8] c"LED off\00"
@.str.3 = [29 x i8] c"*** Turning the LED off ***\0A\00"
@.str.4 = [5 x i8] c"quit\00"
@.str.5 = [39 x i8] c"*** Killing the BBB Serial Server ***\0A\00"
@.str.6 = [26 x i8] c"*** Unknown command! ***\0A\00"
define i32 @processBBBCommand(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
store i32 -1, i32* %5
%6 = load i8*, i8** %4
%7 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* %3
%11 = call i32 @message(i32 %10, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
store i32 %11, i32* %5
br label %31
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i32, i32* %3
%18 = call i32 @message(i32 %17, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
store i32 %18, i32* %5
br label %30
19: ; preds = %12
%20 = load i8*, i8** %4
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i32, i32* %3
%25 = call i32 @message(i32 %24, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
store i32 %25, i32* %5
br label %29
26: ; preds = %19
%27 = load i32, i32* %3
%28 = call i32 @message(i32 %27, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
store i32 %28, i32* %5
br label %29
29: ; preds = %26, %23
br label %30
30: ; preds = %29, %16
br label %31
31: ; preds = %30, %9
%32 = load i32, i32* %5
ret i32 %32
}

LLVM IR (-O2):
@.str = [7 x i8] c"LED on\00"
@.str.1 = [29 x i8] c"*** Turning the LED on ***\0A\00"
@.str.2 = [8 x i8] c"LED off\00"
@.str.3 = [29 x i8] c"*** Turning the LED off ***\0A\00"
@.str.4 = [5 x i8] c"quit\00"
@.str.5 = [39 x i8] c"*** Killing the BBB Serial Server ***\0A\00"
@.str.6 = [26 x i8] c"*** Unknown command! ***\0A\00"
define i32 @processBBBCommand(i32 %0, i8* %1) {
%3 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %12, label %5
5: ; preds = %2
%6 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %5
%9 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
%11 = select i1 %10, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0)
br label %12
12: ; preds = %8, %5, %2
%13 = phi i8* [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), %5 ], [ %11, %8 ]
%14 = tail call i32 @message(i32 %0, i8* %13)
ret i32 %14
}