#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*/);
char *strtabmatch(char **p, char *s) {
  while (*p && strncmp(*p + 1, s, strlen(*p + 1)))
    p++;
  return (!*p || **p == '-') ? NULL : *p;
}


x86 assembly (clang, -O0):
<strtabmatch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rcx
xor    %eax,%eax
cmpq   $0x0,(%rcx)
mov    %al,-0x11(%rbp)
je     1183 <strtabmatch+0x63>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
add    $0x1,%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1193 <strtabmatch+0x73>
jmp    11a4 <strtabmatch+0x84>
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
jmp    1130 <strtabmatch+0x10>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     11c5 <strtabmatch+0xa5>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11d0 <strtabmatch+0xb0>
xor    %eax,%eax
mov    %rax,-0x30(%rbp)
jmp    11db <strtabmatch+0xbb>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strtabmatch>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    (%rdi),%rbx
test   %rbx,%rbx
je     116d <strtabmatch+0x4d>
mov    %rsi,%r15
mov    %rdi,%r12
add    $0x8,%r12
xor    %r14d,%r14d
nopl   (%rax)
add    $0x1,%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1172 <strtabmatch+0x52>
mov    (%r12),%rbx
add    $0x8,%r12
test   %rbx,%rbx
jne    1140 <strtabmatch+0x20>
jmp    1186 <strtabmatch+0x66>
xor    %r14d,%r14d
jmp    1186 <strtabmatch+0x66>
mov    -0x8(%r12),%rax
xor    %r14d,%r14d
test   %rax,%rax
je     1186 <strtabmatch+0x66>
cmpb   $0x2d,(%rax)
cmovne %rax,%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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