#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*/ strlen(char const *);
scalar_t__ strncmp(char *, char const *, int /*<<< orphan*/);
char *strtok_r(char *, char *, char **);
int find_matched(char *line, const char **keys, const int arr_size) {
  char *next = NULL, *entry = NULL;
  int found = 0;
  if (!strtok_r(line, "=", &next)) {
    return 0;
  }
  while ((entry = strtok_r(NULL, ";", &next)) != NULL) {
    int idx;
    for (idx = 0; idx < arr_size; idx++) {
      if (0 == strncmp(entry, keys[idx], strlen(keys[idx]))) {
        found += 1;
        break;
      }
    }
  }
  return found;
}


x86 assembly (clang, -O0):
<find_matched>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe9b(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1050 <strtok_r@plt>
cmp    $0x0,%rax
jne    1184 <find_matched+0x54>
movl   $0x0,-0x4(%rbp)
jmp    1230 <find_matched+0x100>
jmp    1189 <find_matched+0x59>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe6e(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1050 <strtok_r@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     122a <find_matched+0xfa>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1225 <find_matched+0xf5>
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1212 <find_matched+0xe2>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1225 <find_matched+0xf5>
jmp    1217 <find_matched+0xe7>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11b2 <find_matched+0x82>
jmp    1189 <find_matched+0x59>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_matched>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%r13d
mov    %rsi,%rbx
movq   $0x0,0x10(%rsp)
lea    0xeac(%rip),%rsi
lea    0x10(%rsp),%rdx
call   1050 <strtok_r@plt>
test   %rax,%rax
je     11f9 <find_matched+0xc9>
lea    0xe94(%rip),%rsi
xor    %eax,%eax
mov    %rax,0x8(%rsp)
lea    0x10(%rsp),%rdx
xor    %edi,%edi
call   1050 <strtok_r@plt>
test   %rax,%rax
je     1200 <find_matched+0xd0>
mov    %rax,%rbp
mov    %r13d,%r12d
xor    %eax,%eax
mov    %rax,0x8(%rsp)
jmp    11c8 <find_matched+0x98>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x8(%rsp),%rax
add    $0x1,%eax
mov    %rax,0x8(%rsp)
xor    %edi,%edi
lea    0xe4c(%rip),%rsi
lea    0x10(%rsp),%rdx
call   1050 <strtok_r@plt>
mov    %rax,%rbp
test   %rax,%rax
je     1200 <find_matched+0xd0>
test   %r13d,%r13d
jle    11ad <find_matched+0x7d>
xor    %r14d,%r14d
mov    (%rbx,%r14,8),%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11a0 <find_matched+0x70>
add    $0x1,%r14
cmp    %r14,%r12
jne    11d0 <find_matched+0xa0>
jmp    11ad <find_matched+0x7d>
xor    %eax,%eax
mov    %rax,0x8(%rsp)
mov    0x8(%rsp),%rax
add    $0x18,%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 @find_matched(i8* %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
store i8* null, i8** %8
store i8* null, i8** %9
store i32 0, i32* %10
%12 = load i8*, i8** %5
%13 = call i8* @strtok_r(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %8)
%14 = icmp ne i8* %13, null
br i1 %14, label %16, label %15
15: ; preds = %3
store i32 0, i32* %4
br label %50
16: ; preds = %3
br label %17
17: ; preds = %47, %16
%18 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %8)
store i8* %18, i8** %9
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %48
20: ; preds = %17
store i32 0, i32* %11
br label %21
21: ; preds = %44, %20
%22 = load i32, i32* %11
%23 = load i32, i32* %7
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %47
25: ; preds = %21
%26 = load i8*, i8** %9
%27 = load i8**, i8*** %6
%28 = load i32, i32* %11
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = load i8**, i8*** %6
%33 = load i32, i32* %11
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
%36 = load i8*, i8** %35
%37 = call i32 @strlen(i8* %36)
%38 = call i64 @strncmp(i8* %26, i8* %31, i32 %37)
%39 = icmp eq i64 0, %38
br i1 %39, label %40, label %43
40: ; preds = %25
%41 = load i32, i32* %10
%42 = add nsw i32 %41, 1
store i32 %42, i32* %10
br label %47
43: ; preds = %25
br label %44
44: ; preds = %43
%45 = load i32, i32* %11
%46 = add nsw i32 %45, 1
store i32 %46, i32* %11
br label %21
47: ; preds = %40, %21
br label %17
48: ; preds = %17
%49 = load i32, i32* %10
store i32 %49, i32* %4
br label %50
50: ; preds = %48, %15
%51 = load i32, i32* %4
ret i32 %51
}

LLVM IR (-O2):
@.str = [2 x i8] c"=\00"
@.str.1 = [2 x i8] c";\00"
define i32 @find_matched(i8* %0, i8** nocapture %1, i32 %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%6 = call i8* @strtok_r(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %4)
%7 = icmp eq i8* %6, null
br i1 %7, label %33, label %8
8: ; preds = %3
%9 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %4)
%10 = icmp eq i8* %9, null
br i1 %10, label %33, label %11
11: ; preds = %8
%12 = icmp sgt i32 %2, 0
%13 = zext i32 %2 to i64
br label %14
14: ; preds = %11, %29
%15 = phi i8* [ %9, %11 ], [ %31, %29 ]
%16 = phi i32 [ 0, %11 ], [ %30, %29 ]
br i1 %12, label %19, label %29
17: ; preds = %19
%18 = icmp eq i64 %26, %13
br i1 %18, label %29, label %19
19: ; preds = %14, %17
%20 = phi i64 [ %26, %17 ], [ 0, %14 ]
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = load i8*, i8** %21
%23 = call i32 @strlen(i8* %22)
%24 = call i64 @strncmp(i8* %15, i8* %22, i32 %23)
%25 = icmp eq i64 %24, 0
%26 = add nuw nsw i64 %20, 1
br i1 %25, label %27, label %17
27: ; preds = %19
%28 = add nsw i32 %16, 1
br label %29
29: ; preds = %17, %14, %27
%30 = phi i32 [ %28, %27 ], [ %16, %14 ], [ %16, %17 ]
%31 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %4)
%32 = icmp eq i8* %31, null
br i1 %32, label %33, label %14
33: ; preds = %29, %8, %3
%34 = phi i32 [ 0, %3 ], [ 0, %8 ], [ %30, %29 ]
ret i32 %34
}