#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 /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, int /*<<< orphan*/);
int getrulenum(char *word) {
  if (!strcmp(word, "<and>"))
    return 1;
  else if (!strncmp(word, "<near>", strlen("<near>")))
    return 6;
  else if (!strcmp(word, "<or>"))
    return 2;
  else if (!strcmp(word, "<not>"))
    return 3;
  else if (!strcmp(word, "<precd>"))
    return 4;
  else if (!strcmp(word, "<andnot>"))
    return 5;
  return 0;
}


x86 assembly (clang, -O0):
<getrulenum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1161 <getrulenum+0x31>
movl   $0x1,-0x4(%rbp)
jmp    1250 <getrulenum+0x120>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    0xe96(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%edx
lea    0xe84(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    119c <getrulenum+0x6c>
movl   $0x6,-0x4(%rbp)
jmp    1250 <getrulenum+0x120>
mov    -0x10(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11c1 <getrulenum+0x91>
movl   $0x2,-0x4(%rbp)
jmp    1250 <getrulenum+0x120>
mov    -0x10(%rbp),%rdi
lea    0xe46(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11e6 <getrulenum+0xb6>
movl   $0x3,-0x4(%rbp)
jmp    1250 <getrulenum+0x120>
mov    -0x10(%rbp),%rdi
lea    0xe27(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    120b <getrulenum+0xdb>
movl   $0x4,-0x4(%rbp)
jmp    1250 <getrulenum+0x120>
mov    -0x10(%rbp),%rdi
lea    0xe0a(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1230 <getrulenum+0x100>
movl   $0x5,-0x4(%rbp)
jmp    1250 <getrulenum+0x120>
jmp    1235 <getrulenum+0x105>
jmp    123a <getrulenum+0x10a>
jmp    123f <getrulenum+0x10f>
jmp    1244 <getrulenum+0x114>
jmp    1249 <getrulenum+0x119>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getrulenum>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xec2(%rip),%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11bb <getrulenum+0x8b>
lea    0xeb8(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11c2 <getrulenum+0x92>
lea    0xe9f(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11c9 <getrulenum+0x99>
lea    0xe91(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11d0 <getrulenum+0xa0>
lea    0xe84(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11d7 <getrulenum+0xa7>
lea    0xe79(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
lea    (%rcx,%rcx,4),%eax
jmp    11dc <getrulenum+0xac>
mov    $0x1,%eax
jmp    11dc <getrulenum+0xac>
mov    $0x6,%eax
jmp    11dc <getrulenum+0xac>
mov    $0x2,%eax
jmp    11dc <getrulenum+0xac>
mov    $0x3,%eax
jmp    11dc <getrulenum+0xac>
mov    $0x4,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [6 x i8] c"<and>\00"
@.str.1 = [7 x i8] c"<near>\00"
@.str.2 = [5 x i8] c"<or>\00"
@.str.3 = [6 x i8] c"<not>\00"
@.str.4 = [8 x i8] c"<precd>\00"
@.str.5 = [9 x i8] c"<andnot>\00"
define i32 @getrulenum(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @strcmp(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = icmp ne i32 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %1
store i32 1, i32* %2
br label %40
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @strncmp(i8* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %8
store i32 6, i32* %2
br label %40
14: ; preds = %8
%15 = load i8*, i8** %3
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %19, label %18
18: ; preds = %14
store i32 2, i32* %2
br label %40
19: ; preds = %14
%20 = load i8*, i8** %3
%21 = call i32 @strcmp(i8* %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp ne i32 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %19
store i32 3, i32* %2
br label %40
24: ; preds = %19
%25 = load i8*, i8** %3
%26 = call i32 @strcmp(i8* %25, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%27 = icmp ne i32 %26, 0
br i1 %27, label %29, label %28
28: ; preds = %24
store i32 4, i32* %2
br label %40
29: ; preds = %24
%30 = load i8*, i8** %3
%31 = call i32 @strcmp(i8* %30, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%32 = icmp ne i32 %31, 0
br i1 %32, label %34, label %33
33: ; preds = %29
store i32 5, i32* %2
br label %40
34: ; preds = %29
br label %35
35: ; preds = %34
br label %36
36: ; preds = %35
br label %37
37: ; preds = %36
br label %38
38: ; preds = %37
br label %39
39: ; preds = %38
store i32 0, i32* %2
br label %40
40: ; preds = %39, %33, %28, %23, %18, %13, %7
%41 = load i32, i32* %2
ret i32 %41
}

LLVM IR (-O2):
@.str = [6 x i8] c"<and>\00"
@.str.1 = [7 x i8] c"<near>\00"
@.str.2 = [5 x i8] c"<or>\00"
@.str.3 = [6 x i8] c"<not>\00"
@.str.4 = [8 x i8] c"<precd>\00"
@.str.5 = [9 x i8] c"<andnot>\00"
define i32 @getrulenum(i8* %0) {
%2 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %21, label %4
4: ; preds = %1
%5 = tail call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %21, label %8
8: ; preds = %4
%9 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %21, label %11
11: ; preds = %8
%12 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %21, label %14
14: ; preds = %11
%15 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %14
%18 = 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))
%19 = icmp eq i32 %18, 0
%20 = select i1 %19, i32 5, i32 0
br label %21
21: ; preds = %17, %14, %11, %8, %4, %1
%22 = phi i32 [ 1, %1 ], [ 6, %4 ], [ 2, %8 ], [ 3, %11 ], [ 4, %14 ], [ %20, %17 ]
ret i32 %22
}