#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__ str_starts(char const *, char *);
unsigned short config_str_to_servo_index(const char *str) {
  if (str_starts(str, "back_left_knee"))
    return 0;
  if (str_starts(str, "back_left_hip"))
    return 1;
  if (str_starts(str, "front_left_knee"))
    return 2;
  if (str_starts(str, "front_left_hip"))
    return 3;
  if (str_starts(str, "back_right_knee"))
    return 4;
  if (str_starts(str, "back_right_hip"))
    return 5;
  if (str_starts(str, "front_right_knee"))
    return 6;
  if (str_starts(str, "front_right_hip"))
    return 7;
  return -1;
}


x86 assembly (clang, -O0):
<config_str_to_servo_index>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed9(%rip),%rsi
call   1030 <str_starts@plt>
cmp    $0x0,%rax
je     1141 <config_str_to_servo_index+0x31>
movw   $0x0,-0x2(%rbp)
jmp    124a <config_str_to_servo_index+0x13a>
mov    -0x10(%rbp),%rdi
lea    0xec3(%rip),%rsi
call   1030 <str_starts@plt>
cmp    $0x0,%rax
je     1166 <config_str_to_servo_index+0x56>
movw   $0x1,-0x2(%rbp)
jmp    124a <config_str_to_servo_index+0x13a>
mov    -0x10(%rbp),%rdi
lea    0xeac(%rip),%rsi
call   1030 <str_starts@plt>
cmp    $0x0,%rax
je     118b <config_str_to_servo_index+0x7b>
movw   $0x2,-0x2(%rbp)
jmp    124a <config_str_to_servo_index+0x13a>
mov    -0x10(%rbp),%rdi
lea    0xe97(%rip),%rsi
call   1030 <str_starts@plt>
cmp    $0x0,%rax
je     11b0 <config_str_to_servo_index+0xa0>
movw   $0x3,-0x2(%rbp)
jmp    124a <config_str_to_servo_index+0x13a>
mov    -0x10(%rbp),%rdi
lea    0xe81(%rip),%rsi
call   1030 <str_starts@plt>
cmp    $0x0,%rax
je     11d5 <config_str_to_servo_index+0xc5>
movw   $0x4,-0x2(%rbp)
jmp    124a <config_str_to_servo_index+0x13a>
mov    -0x10(%rbp),%rdi
lea    0xe6c(%rip),%rsi
call   1030 <str_starts@plt>
cmp    $0x0,%rax
je     11fa <config_str_to_servo_index+0xea>
movw   $0x5,-0x2(%rbp)
jmp    124a <config_str_to_servo_index+0x13a>
mov    -0x10(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   1030 <str_starts@plt>
cmp    $0x0,%rax
je     121f <config_str_to_servo_index+0x10f>
movw   $0x6,-0x2(%rbp)
jmp    124a <config_str_to_servo_index+0x13a>
mov    -0x10(%rbp),%rdi
lea    0xe42(%rip),%rsi
call   1030 <str_starts@plt>
cmp    $0x0,%rax
je     1244 <config_str_to_servo_index+0x134>
movw   $0x7,-0x2(%rbp)
jmp    124a <config_str_to_servo_index+0x13a>
movw   $0xffff,-0x2(%rbp)
movzwl -0x2(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_str_to_servo_index>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rsi
call   1030 <str_starts@plt>
test   %rax,%rax
je     1129 <config_str_to_servo_index+0x19>
xor    %eax,%eax
pop    %rbx
ret
lea    0xedf(%rip),%rsi
mov    %rbx,%rdi
call   1030 <str_starts@plt>
mov    %rax,%rcx
mov    $0x1,%ax
test   %rcx,%rcx
jne    1127 <config_str_to_servo_index+0x17>
lea    0xed2(%rip),%rsi
mov    %rbx,%rdi
call   1030 <str_starts@plt>
mov    %rax,%rcx
mov    $0x2,%ax
test   %rcx,%rcx
jne    1127 <config_str_to_servo_index+0x17>
lea    0xec7(%rip),%rsi
mov    %rbx,%rdi
call   1030 <str_starts@plt>
mov    %rax,%rcx
mov    $0x3,%ax
test   %rcx,%rcx
jne    1127 <config_str_to_servo_index+0x17>
lea    0xebb(%rip),%rsi
mov    %rbx,%rdi
call   1030 <str_starts@plt>
mov    %rax,%rcx
mov    $0x4,%ax
test   %rcx,%rcx
jne    1127 <config_str_to_servo_index+0x17>
lea    0xeb0(%rip),%rsi
mov    %rbx,%rdi
call   1030 <str_starts@plt>
mov    %rax,%rcx
mov    $0x5,%ax
test   %rcx,%rcx
jne    1127 <config_str_to_servo_index+0x17>
lea    0xea0(%rip),%rsi
mov    %rbx,%rdi
call   1030 <str_starts@plt>
mov    %rax,%rcx
mov    $0x6,%ax
test   %rcx,%rcx
jne    1127 <config_str_to_servo_index+0x17>
lea    0xe92(%rip),%rsi
mov    %rbx,%rdi
call   1030 <str_starts@plt>
cmp    $0x1,%rax
sbb    %eax,%eax
or     $0x7,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"back_left_knee\00"
@.str.1 = [14 x i8] c"back_left_hip\00"
@.str.2 = [16 x i8] c"front_left_knee\00"
@.str.3 = [15 x i8] c"front_left_hip\00"
@.str.4 = [16 x i8] c"back_right_knee\00"
@.str.5 = [15 x i8] c"back_right_hip\00"
@.str.6 = [17 x i8] c"front_right_knee\00"
@.str.7 = [16 x i8] c"front_right_hip\00"
define zeroext i16 @config_str_to_servo_index(i8* %0) {
%2 = alloca i16
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i64 @str_starts(i8* %4, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i16 0, i16* %2
br label %44
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i64 @str_starts(i8* %9, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
store i16 1, i16* %2
br label %44
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = call i64 @str_starts(i8* %14, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i16 2, i16* %2
br label %44
18: ; preds = %13
%19 = load i8*, i8** %3
%20 = call i64 @str_starts(i8* %19, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
store i16 3, i16* %2
br label %44
23: ; preds = %18
%24 = load i8*, i8** %3
%25 = call i64 @str_starts(i8* %24, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23
store i16 4, i16* %2
br label %44
28: ; preds = %23
%29 = load i8*, i8** %3
%30 = call i64 @str_starts(i8* %29, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %28
store i16 5, i16* %2
br label %44
33: ; preds = %28
%34 = load i8*, i8** %3
%35 = call i64 @str_starts(i8* %34, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %33
store i16 6, i16* %2
br label %44
38: ; preds = %33
%39 = load i8*, i8** %3
%40 = call i64 @str_starts(i8* %39, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %38
store i16 7, i16* %2
br label %44
43: ; preds = %38
store i16 -1, i16* %2
br label %44
44: ; preds = %43, %42, %37, %32, %27, %22, %17, %12, %7
%45 = load i16, i16* %2
ret i16 %45
}

LLVM IR (-O2):
@.str = [15 x i8] c"back_left_knee\00"
@.str.1 = [14 x i8] c"back_left_hip\00"
@.str.2 = [16 x i8] c"front_left_knee\00"
@.str.3 = [15 x i8] c"front_left_hip\00"
@.str.4 = [16 x i8] c"back_right_knee\00"
@.str.5 = [15 x i8] c"back_right_hip\00"
@.str.6 = [17 x i8] c"front_right_knee\00"
@.str.7 = [16 x i8] c"front_right_hip\00"
define zeroext i16 @config_str_to_servo_index(i8* %0) {
%2 = tail call i64 @str_starts(i8* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %26
4: ; preds = %1
%5 = tail call i64 @str_starts(i8* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %26
7: ; preds = %4
%8 = tail call i64 @str_starts(i8* %0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %26
10: ; preds = %7
%11 = tail call i64 @str_starts(i8* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %26
13: ; preds = %10
%14 = tail call i64 @str_starts(i8* %0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %26
16: ; preds = %13
%17 = tail call i64 @str_starts(i8* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %26
19: ; preds = %16
%20 = tail call i64 @str_starts(i8* %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = tail call i64 @str_starts(i8* %0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
%25 = select i1 %24, i16 -1, i16 7
br label %26
26: ; preds = %22, %19, %16, %13, %10, %7, %4, %1
%27 = phi i16 [ 0, %1 ], [ 1, %4 ], [ 2, %7 ], [ 3, %10 ], [ 4, %13 ], [ 5, %16 ], [ 6, %19 ], [ %25, %22 ]
ret i16 %27
}