#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*/ expand_hierarch_keyword(char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ *strstr(char *, char *);
int /*<<< orphan*/ strtok(char *, char *);
int isdetectedkeyword(char *line, char *keywords[], int nkeys) {
  int i;
  char kw[128];
  char esokw[128];
  strcpy(kw, line);
  strtok(kw, "=");
  i = (int)strlen(kw) - 1;
  while (kw[i] == ' ')
    i--;
  kw[i + 1] = (char)0;
  for (i = 0; i < nkeys; i++) {
    if (strstr(keywords[i], ".") != NULL) {
      expand_hierarch_keyword(keywords[i], esokw);
      if (!strcmp(kw, esokw)) {
        return i;
      }
    } else if (!strcmp(kw, keywords[i])) {
      return i;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<isdetectedkeyword>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0xa0(%rbp),%rdi
lea    0xe6c(%rip),%rsi
call   1060 <strtok@plt>
lea    -0xa0(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
movslq -0x20(%rbp),%rax
movsbl -0xa0(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
jne    11ce <isdetectedkeyword+0x6e>
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    11ab <isdetectedkeyword+0x4b>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,-0xa0(%rbp,%rax,1)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    129b <isdetectedkeyword+0x13b>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdfe(%rip),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
je     1257 <isdetectedkeyword+0xf7>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x120(%rbp),%rsi
call   1070 <expand_hierarch_keyword@plt>
lea    -0xa0(%rbp),%rdi
lea    -0x120(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1252 <isdetectedkeyword+0xf2>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12a2 <isdetectedkeyword+0x142>
jmp    1288 <isdetectedkeyword+0x128>
lea    -0xa0(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1283 <isdetectedkeyword+0x123>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12a2 <isdetectedkeyword+0x142>
jmp    1288 <isdetectedkeyword+0x128>
jmp    128d <isdetectedkeyword+0x12d>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11e5 <isdetectedkeyword+0x85>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isdetectedkeyword>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %edx,%ebp
mov    %rsi,%r12
mov    %rdi,%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xe75(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strtok@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
movslq %eax,%rcx
mov    %rax,%rdx
shl    $0x20,%rdx
movabs $0x100000000,%rax
add    %rdx,%rax
add    %rbx,%rcx
add    $0xffffffffffffffff,%rcx
movabs $0xffffffff00000000,%rdx
ff ff ff
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    %rdx,%rax
cmpb   $0x20,(%rcx)
lea    -0x1(%rcx),%rcx
je     11d0 <isdetectedkeyword+0x70>
sar    $0x20,%rax
movb   $0x0,(%rsp,%rax,1)
mov    $0xffffffff,%eax
test   %ebp,%ebp
jle    1251 <isdetectedkeyword+0xf1>
mov    %ebp,%r14d
xor    %ebp,%ebp
mov    %rsp,%r15
lea    0x80(%rsp),%r13
nopl   (%rax)
mov    (%r12,%rbp,8),%rbx
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1230 <isdetectedkeyword+0xd0>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1080 <expand_hierarch_keyword@plt>
mov    %r15,%rdi
mov    %r13,%rsi
jmp    1236 <isdetectedkeyword+0xd6>
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
je     124f <isdetectedkeyword+0xef>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1200 <isdetectedkeyword+0xa0>
mov    $0xffffffff,%eax
jmp    1251 <isdetectedkeyword+0xf1>
mov    %ebp,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"=\00"
@.str.1 = [2 x i8] c".\00"
define i32 @isdetectedkeyword(i8* %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32
%9 = alloca [128 x i8]
%10 = alloca [128 x i8]
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%12 = load i8*, i8** %5
%13 = call i32 @strcpy(i8* %11, i8* %12)
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%15 = call i32 @strtok(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%17 = call i64 @strlen(i8* %16)
%18 = trunc i64 %17 to i32
%19 = sub nsw i32 %18, 1
store i32 %19, i32* %8
br label %20
20: ; preds = %27, %3
%21 = load i32, i32* %8
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 32
br i1 %26, label %27, label %30
27: ; preds = %20
%28 = load i32, i32* %8
%29 = add nsw i32 %28, -1
store i32 %29, i32* %8
br label %20
30: ; preds = %20
%31 = load i32, i32* %8
%32 = add nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 %33
store i8 0, i8* %34
store i32 0, i32* %8
br label %35
35: ; preds = %75, %30
%36 = load i32, i32* %8
%37 = load i32, i32* %7
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %78
39: ; preds = %35
%40 = load i8**, i8*** %6
%41 = load i32, i32* %8
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
%44 = load i8*, i8** %43
%45 = call i32* @strstr(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%46 = icmp ne i32* %45, null
br i1 %46, label %47, label %62
47: ; preds = %39
%48 = load i8**, i8*** %6
%49 = load i32, i32* %8
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8*, i8** %48, i64 %50
%52 = load i8*, i8** %51
%53 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%54 = call i32 @expand_hierarch_keyword(i8* %52, i8* %53)
%55 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%56 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%57 = call i32 @strcmp(i8* %55, i8* %56)
%58 = icmp ne i32 %57, 0
br i1 %58, label %61, label %59
59: ; preds = %47
%60 = load i32, i32* %8
store i32 %60, i32* %4
br label %79
61: ; preds = %47
br label %74
62: ; preds = %39
%63 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%64 = load i8**, i8*** %6
%65 = load i32, i32* %8
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8*, i8** %64, i64 %66
%68 = load i8*, i8** %67
%69 = call i32 @strcmp(i8* %63, i8* %68)
%70 = icmp ne i32 %69, 0
br i1 %70, label %73, label %71
71: ; preds = %62
%72 = load i32, i32* %8
store i32 %72, i32* %4
br label %79
73: ; preds = %62
br label %74
74: ; preds = %73, %61
br label %75
75: ; preds = %74
%76 = load i32, i32* %8
%77 = add nsw i32 %76, 1
store i32 %77, i32* %8
br label %35
78: ; preds = %35
store i32 -1, i32* %4
br label %79
79: ; preds = %78, %71, %59
%80 = load i32, i32* %4
ret i32 %80
}

LLVM IR (-O2):
@.str = [2 x i8] c"=\00"
define i32 @isdetectedkeyword(i8* %0, i8** nocapture %1, i32 %2) {
%4 = alloca [128 x i8]
%5 = alloca [128 x i8]
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%8 = call i32 @strcpy(i8* %6, i8* %0)
%9 = call i32 @strtok(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = call i64 @strlen(i8* %6)
%11 = shl i64 %10, 32
%12 = ashr exact i64 %11, 32
br label %13
13: ; preds = %13, %3
%14 = phi i64 [ %15, %13 ], [ %12, %3 ]
%15 = add nsw i64 %14, -1
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 32
br i1 %18, label %13, label %19
19: ; preds = %13
%20 = shl i64 %14, 32
%21 = ashr exact i64 %20, 32
%22 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 %21
store i8 0, i8* %22
%23 = icmp sgt i32 %2, 0
br i1 %23, label %24, label %46
24: ; preds = %19
%25 = zext i32 %2 to i64
br label %26
26: ; preds = %24, %39
%27 = phi i64 [ 0, %24 ], [ %40, %39 ]
%28 = getelementptr inbounds i8*, i8** %1, i64 %27
%29 = load i8*, i8** %28
%30 = call i8* @strchr(i8* dereferenceable(1) %29, i32 46)
%31 = icmp eq i8* %30, null
br i1 %31, label %36, label %32
32: ; preds = %26
%33 = call i32 @expand_hierarch_keyword(i8* %29, i8* %7)
%34 = call i32 @strcmp(i8* %6, i8* %7)
%35 = icmp eq i32 %34, 0
br i1 %35, label %44, label %39
36: ; preds = %26
%37 = call i32 @strcmp(i8* %6, i8* dereferenceable(1) %29)
%38 = icmp eq i32 %37, 0
br i1 %38, label %42, label %39
39: ; preds = %32, %36
%40 = add nuw nsw i64 %27, 1
%41 = icmp eq i64 %40, %25
br i1 %41, label %46, label %26
42: ; preds = %36
%43 = trunc i64 %27 to i32
br label %46
44: ; preds = %32
%45 = trunc i64 %27 to i32
br label %46
46: ; preds = %39, %42, %44, %19
%47 = phi i32 [ -1, %19 ], [ %43, %42 ], [ %45, %44 ], [ -1, %39 ]
ret i32 %47
}