#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 *);
scalar_t__ strncmp(char *, char *, int /*<<< orphan*/);
int getRunLengthCodeInTable(char **table, char *bits, int table_size) {
  int i = 0;
  for (i = 0; i < table_size; i++) {
    if (strncmp(table[i], bits, strlen(bits)) == 0 &&
        strncmp(table[i], bits, strlen(table[i])) == 0) {
      return i;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<getRunLengthCodeInTable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11e7 <getRunLengthCodeInTable+0xc7>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11d4 <getRunLengthCodeInTable+0xb4>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11d4 <getRunLengthCodeInTable+0xb4>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ee <getRunLengthCodeInTable+0xce>
jmp    11d9 <getRunLengthCodeInTable+0xb9>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1141 <getRunLengthCodeInTable+0x21>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getRunLengthCodeInTable>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0xffffffff,%r14d
test   %edx,%edx
jle    1198 <getRunLengthCodeInTable+0x78>
mov    %rsi,%r12
mov    %rdi,%r15
mov    %edx,%r13d
xor    %ebx,%ebx
jmp    1159 <getRunLengthCodeInTable+0x39>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %rbx,%r13
je     1198 <getRunLengthCodeInTable+0x78>
mov    (%r15,%rbx,8),%rbp
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1150 <getRunLengthCodeInTable+0x30>
mov    (%r15,%rbx,8),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1150 <getRunLengthCodeInTable+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 @getRunLengthCodeInTable(i8** %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8** %0, i8*** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 0, i32* %8
store i32 0, i32* %8
br label %9
9: ; preds = %42, %3
%10 = load i32, i32* %8
%11 = load i32, i32* %7
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %45
13: ; preds = %9
%14 = load i8**, i8*** %5
%15 = load i32, i32* %8
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
%18 = load i8*, i8** %17
%19 = load i8*, i8** %6
%20 = load i8*, i8** %6
%21 = call i32 @strlen(i8* %20)
%22 = call i64 @strncmp(i8* %18, i8* %19, i32 %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %41
24: ; preds = %13
%25 = load i8**, i8*** %5
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
%30 = load i8*, i8** %6
%31 = load i8**, i8*** %5
%32 = load i32, i32* %8
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
%36 = call i32 @strlen(i8* %35)
%37 = call i64 @strncmp(i8* %29, i8* %30, i32 %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %24
%40 = load i32, i32* %8
store i32 %40, i32* %4
br label %46
41: ; preds = %24, %13
br label %42
42: ; preds = %41
%43 = load i32, i32* %8
%44 = add nsw i32 %43, 1
store i32 %44, i32* %8
br label %9
45: ; preds = %9
store i32 -1, i32* %4
br label %46
46: ; preds = %45, %39
%47 = load i32, i32* %4
ret i32 %47
}

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