#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 */
scalar_t__ strcmp(char *, char *);
int lex_multiple_anchor_count(char *key, int idx, char **key_tbl, unsigned sz) {
  unsigned i, c;
  c = 0;
  if (sz < 1) {
    return (0);
  }
  for (i = idx + 1; i < sz; i++) {
    if (strcmp(key_tbl[i], key) == 0) {
      c++;
    }
  }
  return (c);
}


x86 assembly (clang, -O0):
<lex_multiple_anchor_count>:
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,-0x2c(%rbp)
cmpl   $0x1,-0x24(%rbp)
jae    1143 <lex_multiple_anchor_count+0x33>
movl   $0x0,-0x4(%rbp)
jmp    1198 <lex_multiple_anchor_count+0x88>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jae    1192 <lex_multiple_anchor_count+0x82>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    117f <lex_multiple_anchor_count+0x6f>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1184 <lex_multiple_anchor_count+0x74>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    114c <lex_multiple_anchor_count+0x3c>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lex_multiple_anchor_count>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
add    $0x1,%esi
xor    %ebp,%ebp
cmp    %ecx,%esi
jae    114c <lex_multiple_anchor_count+0x3c>
mov    %ecx,%r12d
mov    %rdx,%r14
mov    %rdi,%r15
mov    %esi,%ebx
xor    %ebp,%ebp
xchg   %ax,%ax
mov    (%r14,%rbx,8),%rdi
mov    %r15,%rsi
call   1030 <strcmp@plt>
cmp    $0x1,%rax
adc    $0x0,%ebp
add    $0x1,%rbx
cmp    %r12d,%ebx
jb     1130 <lex_multiple_anchor_count+0x20>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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