#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 /*<<< orphan*/ accepted_strings;

/* Variables and functions */
int /*<<< orphan*/ strcmp(char *, char *);
int select_str(char *s) {
  int i;
  char *accepted_strings[] = {"$repeaterId\n", "$callsign\n", "$hardware\n",
                              "$firmware\n",   "$mode\n",     "$txfreq\n",
                              "$rxfreq\n"};
  for (i = 0; i < sizeof(accepted_strings) / sizeof(*accepted_strings); i++) {
    if (!strcmp(s, accepted_strings[i]))
      return i;
  }
  return -1;
}


x86 assembly (clang, -O0):
<select_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
lea    0x2ca9(%rip),%rsi
mov    $0x38,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    $0x7,%rax
jae    118f <select_str+0x6f>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    117c <select_str+0x5c>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1196 <select_str+0x76>
jmp    1181 <select_str+0x61>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1148 <select_str+0x28>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<select_str>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     119b <select_str+0x8b>
lea    0xee2(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     119f <select_str+0x8f>
lea    0xeda(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11a6 <select_str+0x96>
lea    0xed2(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11ad <select_str+0x9d>
lea    0xeca(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11b4 <select_str+0xa4>
lea    0xebe(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11bb <select_str+0xab>
lea    0xeb4(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
neg    %eax
sbb    %eax,%eax
or     $0x6,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret
mov    $0x2,%eax
pop    %rbx
ret
mov    $0x3,%eax
pop    %rbx
ret
mov    $0x4,%eax
pop    %rbx
ret
mov    $0x5,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"$repeaterId\0A\00"
@.str.1 = [11 x i8] c"$callsign\0A\00"
@.str.2 = [11 x i8] c"$hardware\0A\00"
@.str.3 = [11 x i8] c"$firmware\0A\00"
@.str.4 = [7 x i8] c"$mode\0A\00"
@.str.5 = [9 x i8] c"$txfreq\0A\00"
@.str.6 = [9 x i8] c"$rxfreq\0A\00"
@__const.select_str.accepted_strings = [7 x i8*] [i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i32 0, i32 0)]
define i32 @select_str(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [7 x i8*]
store i8* %0, i8** %3
%6 = bitcast [7 x i8*]* %5 to i8*
store i32 0, i32* %4
br label %7
7: ; preds = %22, %1
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = icmp ult i64 %9, 7
br i1 %10, label %11, label %25
11: ; preds = %7
%12 = load i8*, i8** %3
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [7 x i8*], [7 x i8*]* %5, i64 0, i64 %14
%16 = load i8*, i8** %15
%17 = call i32 @strcmp(i8* %12, i8* %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %11
%20 = load i32, i32* %4
store i32 %20, i32* %2
br label %26
21: ; preds = %11
br label %22
22: ; preds = %21
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %7
25: ; preds = %7
store i32 -1, i32* %2
br label %26
26: ; preds = %25, %19
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
@.str = [13 x i8] c"$repeaterId\0A\00"
@.str.1 = [11 x i8] c"$callsign\0A\00"
@.str.2 = [11 x i8] c"$hardware\0A\00"
@.str.3 = [11 x i8] c"$firmware\0A\00"
@.str.4 = [7 x i8] c"$mode\0A\00"
@.str.5 = [9 x i8] c"$txfreq\0A\00"
@.str.6 = [9 x i8] c"$rxfreq\0A\00"
define i32 @select_str(i8* nocapture %0) {
%2 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(13) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %23, label %4
4: ; preds = %1
%5 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %23, label %7
7: ; preds = %4
%8 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %23, label %10
10: ; preds = %7
%11 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %23, label %13
13: ; preds = %10
%14 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %23, label %16
16: ; preds = %13
%17 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %16
%20 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
%22 = select i1 %21, i32 6, i32 -1
br label %23
23: ; preds = %19, %16, %13, %10, %7, %4, %1
%24 = phi i32 [ 0, %1 ], [ 1, %4 ], [ 2, %7 ], [ 3, %10 ], [ 4, %13 ], [ 5, %16 ], [ %22, %19 ]
ret i32 %24
}