#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 */
unsigned int strlen(char const *const);
scalar_t__ strncmp(char const *, char const *const, unsigned int);
int web_find_keyword(const char *data, unsigned int size,
                     const char *const *keywords, unsigned int keywords_count) {
  unsigned int i;
  for (i = 0; i < keywords_count; ++i) {
    if ((strlen(keywords[i]) == size) &&
        (strncmp(data, keywords[i], size) == 0))
      return i;
  }
  return -1;
}


x86 assembly (clang, -O0):
<web_find_keyword>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jae    11a1 <web_find_keyword+0x81>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
cmp    -0x14(%rbp),%eax
jne    118e <web_find_keyword+0x6e>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    (%rax,%rcx,8),%rsi
mov    -0x14(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    118e <web_find_keyword+0x6e>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a8 <web_find_keyword+0x88>
jmp    1193 <web_find_keyword+0x73>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    113d <web_find_keyword+0x1d>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<web_find_keyword>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0xffffffff,%r14d
test   %ecx,%ecx
je     117c <web_find_keyword+0x5c>
mov    %rdx,%r12
mov    %esi,%ebp
mov    %rdi,%r15
mov    %ecx,%r13d
xor    %ebx,%ebx
jmp    1159 <web_find_keyword+0x39>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rbx,%r13
je     117c <web_find_keyword+0x5c>
mov    (%r12,%rbx,8),%rdi
call   1040 <strlen@plt>
cmp    %ebp,%eax
jne    1150 <web_find_keyword+0x30>
mov    (%r12,%rbx,8),%rsi
mov    %r15,%rdi
mov    %ebp,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1150 <web_find_keyword+0x30>
mov    %ebx,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @web_find_keyword(i8* %0, i32 %1, i8** %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8** %2, i8*** %8
store i32 %3, i32* %9
store i32 0, i32* %10
br label %11
11: ; preds = %37, %4
%12 = load i32, i32* %10
%13 = load i32, i32* %9
%14 = icmp ult i32 %12, %13
br i1 %14, label %15, label %40
15: ; preds = %11
%16 = load i8**, i8*** %8
%17 = load i32, i32* %10
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %16, i64 %18
%20 = load i8*, i8** %19
%21 = call i32 @strlen(i8* %20)
%22 = load i32, i32* %7
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %36
24: ; preds = %15
%25 = load i8*, i8** %6
%26 = load i8**, i8*** %8
%27 = load i32, i32* %10
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = load i32, i32* %7
%32 = call i64 @strncmp(i8* %25, i8* %30, i32 %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %24
%35 = load i32, i32* %10
store i32 %35, i32* %5
br label %41
36: ; preds = %24, %15
br label %37
37: ; preds = %36
%38 = load i32, i32* %10
%39 = add i32 %38, 1
store i32 %39, i32* %10
br label %11
40: ; preds = %11
store i32 -1, i32* %5
br label %41
41: ; preds = %40, %34
%42 = load i32, i32* %5
ret i32 %42
}

LLVM IR (-O2):
define i32 @web_find_keyword(i8* %0, i32 %1, i8** nocapture %2, i32 %3) {
%5 = icmp eq i32 %3, 0
br i1 %5, label %23, label %6
6: ; preds = %4
%7 = zext i32 %3 to i64
br label %8
8: ; preds = %6, %18
%9 = phi i64 [ 0, %6 ], [ %19, %18 ]
%10 = getelementptr inbounds i8*, i8** %2, i64 %9
%11 = load i8*, i8** %10
%12 = tail call i32 @strlen(i8* %11)
%13 = icmp eq i32 %12, %1
br i1 %13, label %14, label %18
14: ; preds = %8
%15 = load i8*, i8** %10
%16 = tail call i64 @strncmp(i8* %0, i8* %15, i32 %1)
%17 = icmp eq i64 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %8, %14
%19 = add nuw nsw i64 %9, 1
%20 = icmp eq i64 %19, %7
br i1 %20, label %23, label %8
21: ; preds = %14
%22 = trunc i64 %9 to i32
br label %23
23: ; preds = %18, %21, %4
%24 = phi i32 [ -1, %4 ], [ %22, %21 ], [ -1, %18 ]
ret i32 %24
}