#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__ strcmp(char const *, char *);
const char *findCommand(const char *request) {
  typedef struct _command_t {
    char *header;
    char *cmdline;
  } command_t;
  static command_t commands[] = {
      {"/update/network/wifi", "/var/p2pfoodlab/bin/update-network wifi 2>&1"},
      {"/update/network/wired",
       "/var/p2pfoodlab/bin/update-network wired 2>&1"},
      {"/update/network/gsm", "/var/p2pfoodlab/bin/update-network gsm 2>&1"},
      {"/update/ssh", "/var/p2pfoodlab/bin/update-ssh 2>&1"},
      {"/update/crontab", "/var/p2pfoodlab/bin/update-crontab 2>&1"},
      {"/test/camera", "/var/p2pfoodlab/bin/test-camera 2>&1"},
      {"/update/sensors", "/var/p2pfoodlab/bin/arduino enable-sensors 2>&1"},
      {"/update/version", "/var/p2pfoodlab/bin/update-version 2>&1"},
      {"/update/poweroff", "/var/p2pfoodlab/bin/update-poweroff 2>&1"},
      {NULL, NULL}};
  for (int i = 0; commands[i].header != NULL; i++) {
    if (strcmp(request, commands[i].header) == 0)
      return commands[i].cmdline;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<findCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rcx
lea    0x2f02(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
cmpq   $0x0,(%rax)
je     1199 <findCommand+0x89>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rcx
lea    0x2ee2(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1186 <findCommand+0x76>
movslq -0x14(%rbp),%rcx
lea    0x2ebe(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    11a1 <findCommand+0x91>
jmp    118b <findCommand+0x7b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <findCommand+0x13>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findCommand>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11d5 <findCommand+0xc5>
lea    0xf12(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11d9 <findCommand+0xc9>
lea    0xf3e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11e0 <findCommand+0xd0>
lea    0xf66(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11e7 <findCommand+0xd7>
lea    0xf82(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11ee <findCommand+0xde>
lea    0xfa6(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11f5 <findCommand+0xe5>
lea    0xfc4(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11fc <findCommand+0xec>
lea    0xff0(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1203 <findCommand+0xf3>
lea    0x1014(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     120a <findCommand+0xfa>
xor    %eax,%eax
pop    %rbx
ret
xor    %eax,%eax
jmp    120f <findCommand+0xff>
mov    $0x1,%eax
jmp    120f <findCommand+0xff>
mov    $0x2,%eax
jmp    120f <findCommand+0xff>
mov    $0x3,%eax
jmp    120f <findCommand+0xff>
mov    $0x4,%eax
jmp    120f <findCommand+0xff>
mov    $0x5,%eax
jmp    120f <findCommand+0xff>
mov    $0x6,%eax
jmp    120f <findCommand+0xff>
mov    $0x7,%eax
jmp    120f <findCommand+0xff>
mov    $0x8,%eax
shl    $0x4,%rax
lea    0x2b66(%rip),%rcx
mov    0x8(%rax,%rcx,1),%rax
pop    %rbx
ret

LLVM IR (-O0):
%struct._command_t = type { i8*, i8* }
@findCommand.commands = internal global [10 x %struct._command_t] [%struct._command_t { i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i32 0, i32 0) }, %struct._command_t { i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i32 0, i32 0) }, %struct._command_t { i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i32 0, i32 0) }, %struct._command_t { i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i32 0, i32 0) }, %struct._command_t { i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.9, i32 0, i32 0) }, %struct._command_t { i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.11, i32 0, i32 0) }, %struct._command_t { i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.13, i32 0, i32 0) }, %struct._command_t { i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.15, i32 0, i32 0) }, %struct._command_t { i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.17, i32 0, i32 0) }, %struct._command_t zeroinitializer]
@.str = [21 x i8] c"/update/network/wifi\00"
@.str.1 = [45 x i8] c"/var/p2pfoodlab/bin/update-network wifi 2>&1\00"
@.str.2 = [22 x i8] c"/update/network/wired\00"
@.str.3 = [46 x i8] c"/var/p2pfoodlab/bin/update-network wired 2>&1\00"
@.str.4 = [20 x i8] c"/update/network/gsm\00"
@.str.5 = [44 x i8] c"/var/p2pfoodlab/bin/update-network gsm 2>&1\00"
@.str.6 = [12 x i8] c"/update/ssh\00"
@.str.7 = [36 x i8] c"/var/p2pfoodlab/bin/update-ssh 2>&1\00"
@.str.8 = [16 x i8] c"/update/crontab\00"
@.str.9 = [40 x i8] c"/var/p2pfoodlab/bin/update-crontab 2>&1\00"
@.str.10 = [13 x i8] c"/test/camera\00"
@.str.11 = [37 x i8] c"/var/p2pfoodlab/bin/test-camera 2>&1\00"
@.str.12 = [16 x i8] c"/update/sensors\00"
@.str.13 = [48 x i8] c"/var/p2pfoodlab/bin/arduino enable-sensors 2>&1\00"
@.str.14 = [16 x i8] c"/update/version\00"
@.str.15 = [40 x i8] c"/var/p2pfoodlab/bin/update-version 2>&1\00"
@.str.16 = [17 x i8] c"/update/poweroff\00"
@.str.17 = [41 x i8] c"/var/p2pfoodlab/bin/update-poweroff 2>&1\00"
define i8* @findCommand(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
br label %5
5: ; preds = %28, %1
%6 = load i32, i32* %4
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [10 x %struct._command_t], [10 x %struct._command_t]* @findCommand.commands, i64 0, i64 %7
%9 = getelementptr inbounds %struct._command_t, %struct._command_t* %8, i32 0, i32 0
%10 = load i8*, i8** %9
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %31
12: ; preds = %5
%13 = load i8*, i8** %3
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [10 x %struct._command_t], [10 x %struct._command_t]* @findCommand.commands, i64 0, i64 %15
%17 = getelementptr inbounds %struct._command_t, %struct._command_t* %16, i32 0, i32 0
%18 = load i8*, i8** %17
%19 = call i64 @strcmp(i8* %13, i8* %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %12
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [10 x %struct._command_t], [10 x %struct._command_t]* @findCommand.commands, i64 0, i64 %23
%25 = getelementptr inbounds %struct._command_t, %struct._command_t* %24, i32 0, i32 1
%26 = load i8*, i8** %25
store i8* %26, i8** %2
br label %32
27: ; preds = %12
br label %28
28: ; preds = %27
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %5
31: ; preds = %5
store i8* null, i8** %2
br label %32
32: ; preds = %31, %21
%33 = load i8*, i8** %2
ret i8* %33
}

LLVM IR (-O2):
%struct._command_t = type { i8*, i8* }
@findCommand.commands = internal unnamed_addr constant [10 x %struct._command_t] [%struct._command_t { i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i32 0, i32 0) }, %struct._command_t { i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i32 0, i32 0) }, %struct._command_t { i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i32 0, i32 0) }, %struct._command_t { i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i32 0, i32 0) }, %struct._command_t { i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.9, i32 0, i32 0) }, %struct._command_t { i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.11, i32 0, i32 0) }, %struct._command_t { i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.13, i32 0, i32 0) }, %struct._command_t { i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.15, i32 0, i32 0) }, %struct._command_t { i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.17, i32 0, i32 0) }, %struct._command_t zeroinitializer]
@.str = [21 x i8] c"/update/network/wifi\00"
@.str.1 = [45 x i8] c"/var/p2pfoodlab/bin/update-network wifi 2>&1\00"
@.str.2 = [22 x i8] c"/update/network/wired\00"
@.str.3 = [46 x i8] c"/var/p2pfoodlab/bin/update-network wired 2>&1\00"
@.str.4 = [20 x i8] c"/update/network/gsm\00"
@.str.5 = [44 x i8] c"/var/p2pfoodlab/bin/update-network gsm 2>&1\00"
@.str.6 = [12 x i8] c"/update/ssh\00"
@.str.7 = [36 x i8] c"/var/p2pfoodlab/bin/update-ssh 2>&1\00"
@.str.8 = [16 x i8] c"/update/crontab\00"
@.str.9 = [40 x i8] c"/var/p2pfoodlab/bin/update-crontab 2>&1\00"
@.str.10 = [13 x i8] c"/test/camera\00"
@.str.11 = [37 x i8] c"/var/p2pfoodlab/bin/test-camera 2>&1\00"
@.str.12 = [16 x i8] c"/update/sensors\00"
@.str.13 = [48 x i8] c"/var/p2pfoodlab/bin/arduino enable-sensors 2>&1\00"
@.str.14 = [16 x i8] c"/update/version\00"
@.str.15 = [40 x i8] c"/var/p2pfoodlab/bin/update-version 2>&1\00"
@.str.16 = [17 x i8] c"/update/poweroff\00"
@.str.17 = [41 x i8] c"/var/p2pfoodlab/bin/update-poweroff 2>&1\00"
define i8* @findCommand(i8* %0) {
%2 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %8
4: ; preds = %29, %26, %23, %20, %17, %14, %11, %8, %1
%5 = phi i64 [ 0, %1 ], [ 1, %8 ], [ 2, %11 ], [ 3, %14 ], [ 4, %17 ], [ 5, %20 ], [ 6, %23 ], [ 7, %26 ], [ 8, %29 ]
%6 = getelementptr inbounds [10 x %struct._command_t], [10 x %struct._command_t]* @findCommand.commands, i64 0, i64 %5, i32 1
%7 = load i8*, i8** %6
br label %32
8: ; preds = %1
%9 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %4, label %11
11: ; preds = %8
%12 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %4, label %14
14: ; preds = %11
%15 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %4, label %17
17: ; preds = %14
%18 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %4, label %20
20: ; preds = %17
%21 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %4, label %23
23: ; preds = %20
%24 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %4, label %26
26: ; preds = %23
%27 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.14, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %4, label %29
29: ; preds = %26
%30 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.16, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %4, label %32
32: ; preds = %29, %4
%33 = phi i8* [ %7, %4 ], [ null, %29 ]
ret i8* %33
}