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

/* Variables and functions */
int /*<<< orphan*/ ci_strcmp(char *, char *);
int cond_from_str(char *str) {
  struct condstr {
    char *str;
    unsigned cond;
  };
  static struct condstr strings[] = {
      {"Z", 0x0},   {"E", 0x0},  {"NZ", 0x1}, {"NE", 0x1},  {"C", 0x2},
      {"GEU", 0x2}, {"NC", 0x3}, {"LU", 0x3}, {"N", 0x4},   {"NN", 0x5},
      {"O", 0x6},   {"NO", 0x7}, {"GU", 0x8}, {"LEU", 0x9}, {"GE", 0xA},
      {"L", 0xB},   {"G", 0xC},  {"LE", 0xD}, {"F", 0xE},   {"T", 0xF},
  };
  int i;
  for (i = 0; i < sizeof(strings) / sizeof(strings[0]); ++i)
    if (!ci_strcmp(strings[i].str, str))
      return strings[i].cond;
  return -1;
}


x86 assembly (clang, -O0):
<cond_from_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    $0x14,%rax
jae    1188 <cond_from_str+0x78>
movslq -0x14(%rbp),%rcx
lea    0x2ef4(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <ci_strcmp@plt>
cmp    $0x0,%eax
jne    1175 <cond_from_str+0x65>
movslq -0x14(%rbp),%rcx
lea    0x2ecd(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    118f <cond_from_str+0x7f>
jmp    117a <cond_from_str+0x6a>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <cond_from_str+0x13>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cond_from_str>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x8,%ebx
lea    0x2bbc(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    -0x8(%rbx,%r15,1),%rdi
mov    %r14,%rsi
call   1030 <ci_strcmp@plt>
test   %eax,%eax
je     1155 <cond_from_str+0x45>
add    $0x10,%rbx
cmp    $0x148,%rbx
jne    1130 <cond_from_str+0x20>
mov    $0xffffffff,%eax
jmp    1159 <cond_from_str+0x49>
mov    (%rbx,%r15,1),%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.condstr = type { i8*, i32 }
@cond_from_str.strings = internal global [20 x %struct.condstr] [%struct.condstr { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i32 0 }, %struct.condstr { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i32 0 }, %struct.condstr { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i32 1 }, %struct.condstr { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i32 1 }, %struct.condstr { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i32 0, i32 0), i32 2 }, %struct.condstr { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i32 2 }, %struct.condstr { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i32 0, i32 0), i32 3 }, %struct.condstr { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i32 0, i32 0), i32 3 }, %struct.condstr { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i32 0, i32 0), i32 4 }, %struct.condstr { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i32 0, i32 0), i32 5 }, %struct.condstr { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i32 0, i32 0), i32 6 }, %struct.condstr { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i32 0, i32 0), i32 7 }, %struct.condstr { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i32 0, i32 0), i32 8 }, %struct.condstr { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i32 0, i32 0), i32 9 }, %struct.condstr { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i32 0, i32 0), i32 10 }, %struct.condstr { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i32 0, i32 0), i32 11 }, %struct.condstr { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i32 0, i32 0), i32 12 }, %struct.condstr { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i32 0, i32 0), i32 13 }, %struct.condstr { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i32 0, i32 0), i32 14 }, %struct.condstr { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.19, i32 0, i32 0), i32 15 }]
@.str = [2 x i8] c"Z\00"
@.str.1 = [2 x i8] c"E\00"
@.str.2 = [3 x i8] c"NZ\00"
@.str.3 = [3 x i8] c"NE\00"
@.str.4 = [2 x i8] c"C\00"
@.str.5 = [4 x i8] c"GEU\00"
@.str.6 = [3 x i8] c"NC\00"
@.str.7 = [3 x i8] c"LU\00"
@.str.8 = [2 x i8] c"N\00"
@.str.9 = [3 x i8] c"NN\00"
@.str.10 = [2 x i8] c"O\00"
@.str.11 = [3 x i8] c"NO\00"
@.str.12 = [3 x i8] c"GU\00"
@.str.13 = [4 x i8] c"LEU\00"
@.str.14 = [3 x i8] c"GE\00"
@.str.15 = [2 x i8] c"L\00"
@.str.16 = [2 x i8] c"G\00"
@.str.17 = [3 x i8] c"LE\00"
@.str.18 = [2 x i8] c"F\00"
@.str.19 = [2 x i8] c"T\00"
define i32 @cond_from_str(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
br label %5
5: ; preds = %25, %1
%6 = load i32, i32* %4
%7 = sext i32 %6 to i64
%8 = icmp ult i64 %7, 20
br i1 %8, label %9, label %28
9: ; preds = %5
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [20 x %struct.condstr], [20 x %struct.condstr]* @cond_from_str.strings, i64 0, i64 %11
%13 = getelementptr inbounds %struct.condstr, %struct.condstr* %12, i32 0, i32 0
%14 = load i8*, i8** %13
%15 = load i8*, i8** %3
%16 = call i32 @ci_strcmp(i8* %14, i8* %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %24, label %18
18: ; preds = %9
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [20 x %struct.condstr], [20 x %struct.condstr]* @cond_from_str.strings, i64 0, i64 %20
%22 = getelementptr inbounds %struct.condstr, %struct.condstr* %21, i32 0, i32 1
%23 = load i32, i32* %22
store i32 %23, i32* %2
br label %29
24: ; preds = %9
br label %25
25: ; preds = %24
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
br label %5
28: ; preds = %5
store i32 -1, i32* %2
br label %29
29: ; preds = %28, %18
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
%struct.condstr = type { i8*, i32 }
@cond_from_str.strings = internal unnamed_addr constant [20 x %struct.condstr] [%struct.condstr { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i32 0 }, %struct.condstr { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i32 0 }, %struct.condstr { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i32 1 }, %struct.condstr { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i32 1 }, %struct.condstr { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i32 0, i32 0), i32 2 }, %struct.condstr { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i32 2 }, %struct.condstr { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i32 0, i32 0), i32 3 }, %struct.condstr { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i32 0, i32 0), i32 3 }, %struct.condstr { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i32 0, i32 0), i32 4 }, %struct.condstr { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i32 0, i32 0), i32 5 }, %struct.condstr { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i32 0, i32 0), i32 6 }, %struct.condstr { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i32 0, i32 0), i32 7 }, %struct.condstr { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i32 0, i32 0), i32 8 }, %struct.condstr { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i32 0, i32 0), i32 9 }, %struct.condstr { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i32 0, i32 0), i32 10 }, %struct.condstr { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i32 0, i32 0), i32 11 }, %struct.condstr { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i32 0, i32 0), i32 12 }, %struct.condstr { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i32 0, i32 0), i32 13 }, %struct.condstr { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i32 0, i32 0), i32 14 }, %struct.condstr { i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.19, i32 0, i32 0), i32 15 }]
@.str = [2 x i8] c"Z\00"
@.str.1 = [2 x i8] c"E\00"
@.str.2 = [3 x i8] c"NZ\00"
@.str.3 = [3 x i8] c"NE\00"
@.str.4 = [2 x i8] c"C\00"
@.str.5 = [4 x i8] c"GEU\00"
@.str.6 = [3 x i8] c"NC\00"
@.str.7 = [3 x i8] c"LU\00"
@.str.8 = [2 x i8] c"N\00"
@.str.9 = [3 x i8] c"NN\00"
@.str.10 = [2 x i8] c"O\00"
@.str.11 = [3 x i8] c"NO\00"
@.str.12 = [3 x i8] c"GU\00"
@.str.13 = [4 x i8] c"LEU\00"
@.str.14 = [3 x i8] c"GE\00"
@.str.15 = [2 x i8] c"L\00"
@.str.16 = [2 x i8] c"G\00"
@.str.17 = [3 x i8] c"LE\00"
@.str.18 = [2 x i8] c"F\00"
@.str.19 = [2 x i8] c"T\00"
define i32 @cond_from_str(i8* %0) {
br label %2
2: ; preds = %1, %12
%3 = phi i64 [ 0, %1 ], [ %13, %12 ]
%4 = getelementptr inbounds [20 x %struct.condstr], [20 x %struct.condstr]* @cond_from_str.strings, i64 0, i64 %3, i32 0
%5 = load i8*, i8** %4
%6 = tail call i32 @ci_strcmp(i8* %5, i8* %0)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = and i64 %3, 4294967295
%10 = getelementptr inbounds [20 x %struct.condstr], [20 x %struct.condstr]* @cond_from_str.strings, i64 0, i64 %9, i32 1
%11 = load i32, i32* %10
br label %15
12: ; preds = %2
%13 = add nuw nsw i64 %3, 1
%14 = icmp eq i64 %13, 20
br i1 %14, label %15, label %2
15: ; preds = %12, %8
%16 = phi i32 [ %11, %8 ], [ -1, %12 ]
ret i32 %16
}