#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 is_prefix(char const *, char *);
char **tbl_ent_match(const char *name, char **tbl, int ent_sz) {
  char **c;
  char **found;
  int n;
  if (!name)
    return 0;
  found = 0;
  for (c = tbl; *c; c = (char **)((char *)c + ent_sz)) {
    n = is_prefix(name, *c);
    if (n == 0)
      continue;
    if (n < 0)
      return c;
    if (found)
      return (char **)((void *)1);
    found = c;
  }
  return found;
}


x86 assembly (clang, -O0):
<tbl_ent_match>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    113b <tbl_ent_match+0x2b>
movq   $0x0,-0x8(%rbp)
jmp    11cf <tbl_ent_match+0xbf>
movq   $0x0,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpq   $0x0,(%rax)
je     11c7 <tbl_ent_match+0xb7>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    (%rax),%rsi
call   1030 <is_prefix@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    117b <tbl_ent_match+0x6b>
jmp    11b3 <tbl_ent_match+0xa3>
cmpl   $0x0,-0x34(%rbp)
jge    1192 <tbl_ent_match+0x82>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11cf <tbl_ent_match+0xbf>
cmpq   $0x0,-0x30(%rbp)
je     11ab <tbl_ent_match+0x9b>
mov    $0x1,%eax
mov    %rax,-0x8(%rbp)
jmp    11cf <tbl_ent_match+0xbf>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
jmp    114b <tbl_ent_match+0x3b>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tbl_ent_match>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     116a <tbl_ent_match+0x5a>
mov    %rsi,%rbx
mov    (%rsi),%rsi
test   %rsi,%rsi
je     116a <tbl_ent_match+0x5a>
mov    %rdi,%r15
movslq %edx,%r12
xor    %r14d,%r14d
jmp    114c <tbl_ent_match+0x3c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%rbx,%r12,1),%rsi
add    %r12,%rbx
test   %rsi,%rsi
je     116d <tbl_ent_match+0x5d>
mov    %r15,%rdi
call   1030 <is_prefix@plt>
test   %eax,%eax
je     1140 <tbl_ent_match+0x30>
js     117c <tbl_ent_match+0x6c>
test   %r14,%r14
mov    %rbx,%r14
je     1140 <tbl_ent_match+0x30>
mov    $0x1,%r14d
jmp    116d <tbl_ent_match+0x5d>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %rbx,%r14
jmp    116d <tbl_ent_match+0x5d>

LLVM IR (-O0):
define i8** @tbl_ent_match(i8* %0, i8** %1, i32 %2) {
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i8**
%10 = alloca i32
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %3
store i8** null, i8*** %4
br label %48
14: ; preds = %3
store i8** null, i8*** %9
%15 = load i8**, i8*** %6
store i8** %15, i8*** %8
br label %16
16: ; preds = %39, %14
%17 = load i8**, i8*** %8
%18 = load i8*, i8** %17
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %46
20: ; preds = %16
%21 = load i8*, i8** %5
%22 = load i8**, i8*** %8
%23 = load i8*, i8** %22
%24 = call i32 @is_prefix(i8* %21, i8* %23)
store i32 %24, i32* %10
%25 = load i32, i32* %10
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %20
br label %39
28: ; preds = %20
%29 = load i32, i32* %10
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = load i8**, i8*** %8
store i8** %32, i8*** %4
br label %48
33: ; preds = %28
%34 = load i8**, i8*** %9
%35 = icmp ne i8** %34, null
br i1 %35, label %36, label %37
36: ; preds = %33
store i8** inttoptr (i64 1 to i8**), i8*** %4
br label %48
37: ; preds = %33
%38 = load i8**, i8*** %8
store i8** %38, i8*** %9
br label %39
39: ; preds = %37, %27
%40 = load i8**, i8*** %8
%41 = bitcast i8** %40 to i8*
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = bitcast i8* %44 to i8**
store i8** %45, i8*** %8
br label %16
46: ; preds = %16
%47 = load i8**, i8*** %9
store i8** %47, i8*** %4
br label %48
48: ; preds = %46, %36, %31, %13
%49 = load i8**, i8*** %4
ret i8** %49
}

LLVM IR (-O2):
define i8** @tbl_ent_match(i8* %0, i8** %1, i32 %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %27, label %5
5: ; preds = %3
%6 = load i8*, i8** %1
%7 = icmp eq i8* %6, null
br i1 %7, label %27, label %8
8: ; preds = %5
%9 = sext i32 %2 to i64
br label %10
10: ; preds = %8, %20
%11 = phi i8* [ %6, %8 ], [ %25, %20 ]
%12 = phi i8** [ null, %8 ], [ %21, %20 ]
%13 = phi i8** [ %1, %8 ], [ %24, %20 ]
%14 = tail call i32 @is_prefix(i8* %0, i8* %11)
%15 = icmp eq i32 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %10
%17 = icmp slt i32 %14, 0
br i1 %17, label %27, label %18
18: ; preds = %16
%19 = icmp eq i8** %12, null
br i1 %19, label %20, label %27
20: ; preds = %18, %10
%21 = phi i8** [ %12, %10 ], [ %13, %18 ]
%22 = bitcast i8** %13 to i8*
%23 = getelementptr inbounds i8, i8* %22, i64 %9
%24 = bitcast i8* %23 to i8**
%25 = load i8*, i8** %24
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %10
27: ; preds = %16, %18, %20, %5, %3
%28 = phi i8** [ null, %3 ], [ null, %5 ], [ %13, %16 ], [ inttoptr (i64 1 to i8**), %18 ], [ %21, %20 ]
ret i8** %28
}