#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*/ Destroy(char *);
char *GetTok(char const *, char *, char **);
scalar_t__ fnmatch(char const *, char const *, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char const *);
int ItemMatches(const char *Item, const char *MatchList) {
  const char *ptr, *mptr;
  char *Match = NULL;
  int result = 0;
  if ((Item ? strlen(Item) : 0) == 0)
    return (0);
  ptr = GetTok(MatchList, ",", &Match);
  while (ptr) {
    mptr = Match;
    if (*mptr == '!')
      mptr++;
    if (fnmatch(mptr, Item, 0) == 0) {
      if (*Match != '!') {
        result = 1;
        break;
      }
    } else if (*Match == '!') {
      result = 1;
      break;
    }
    ptr = GetTok(ptr, ",", &Match);
  }
  Destroy(Match);
  return (result);
}


x86 assembly (clang, -O0):
<ItemMatches>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     117b <ItemMatches+0x3b>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x38(%rbp)
jmp    1185 <ItemMatches+0x45>
xor    %eax,%eax
mov    %eax,-0x38(%rbp)
jmp    1185 <ItemMatches+0x45>
mov    -0x38(%rbp),%eax
cmp    $0x0,%eax
jne    119d <ItemMatches+0x5d>
movl   $0x0,-0x4(%rbp)
jmp    126b <ItemMatches+0x12b>
mov    -0x18(%rbp),%rdi
lea    0xe58(%rip),%rsi
lea    -0x30(%rbp),%rdx
call   1030 <GetTok@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     125c <ItemMatches+0x11c>
mov    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x21,%eax
jne    11e4 <ItemMatches+0xa4>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1050 <fnmatch@plt>
cmp    $0x0,%rax
jne    121e <ItemMatches+0xde>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x21,%eax
je     1219 <ItemMatches+0xd9>
movl   $0x1,-0x34(%rbp)
jmp    125c <ItemMatches+0x11c>
jmp    123f <ItemMatches+0xff>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x21,%eax
jne    123a <ItemMatches+0xfa>
movl   $0x1,-0x34(%rbp)
jmp    125c <ItemMatches+0x11c>
jmp    123f <ItemMatches+0xff>
mov    -0x20(%rbp),%rdi
lea    0xdb6(%rip),%rsi
lea    -0x30(%rbp),%rdx
call   1030 <GetTok@plt>
mov    %rax,-0x20(%rbp)
jmp    11b5 <ItemMatches+0x75>
mov    -0x30(%rbp),%rdi
call   1060 <Destroy@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ItemMatches>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movq   $0x0,(%rsp)
xor    %ebx,%ebx
test   %rdi,%rdi
je     11f8 <ItemMatches+0xb8>
mov    %rsi,%r15
mov    %rdi,%r14
call   1040 <strlen@plt>
test   %eax,%eax
je     11f8 <ItemMatches+0xb8>
lea    0xe8b(%rip),%rsi
mov    %rsp,%rdx
mov    %r15,%rdi
call   1030 <GetTok@plt>
test   %rax,%rax
je     11ed <ItemMatches+0xad>
mov    %rax,%rbx
lea    0xe71(%rip),%r15
mov    %rsp,%r12
jmp    11bb <ItemMatches+0x7b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x21,%cl
jne    11e6 <ItemMatches+0xa6>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <GetTok@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11ed <ItemMatches+0xad>
mov    (%rsp),%rax
xor    %edi,%edi
cmpb   $0x21,(%rax)
sete   %dil
add    %rax,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1050 <fnmatch@plt>
mov    (%rsp),%rcx
movzbl (%rcx),%ecx
test   %rax,%rax
je     11a0 <ItemMatches+0x60>
cmp    $0x21,%cl
jne    11a5 <ItemMatches+0x65>
mov    $0x1,%ebx
jmp    11ef <ItemMatches+0xaf>
xor    %ebx,%ebx
mov    (%rsp),%rdi
call   1060 <Destroy@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c",\00"
define i32 @ItemMatches(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* null, i8** %8
store i32 0, i32* %9
%10 = load i8*, i8** %4
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call i32 @strlen(i8* %13)
br label %16
15: ; preds = %2
br label %16
16: ; preds = %15, %12
%17 = phi i32 [ %14, %12 ], [ 0, %15 ]
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %16
store i32 0, i32* %3
br label %61
20: ; preds = %16
%21 = load i8*, i8** %5
%22 = call i8* @GetTok(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %8)
store i8* %22, i8** %6
br label %23
23: ; preds = %54, %20
%24 = load i8*, i8** %6
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %57
26: ; preds = %23
%27 = load i8*, i8** %8
store i8* %27, i8** %7
%28 = load i8*, i8** %7
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 33
br i1 %31, label %32, label %35
32: ; preds = %26
%33 = load i8*, i8** %7
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %7
br label %35
35: ; preds = %32, %26
%36 = load i8*, i8** %7
%37 = load i8*, i8** %4
%38 = call i64 @fnmatch(i8* %36, i8* %37, i32 0)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %47
40: ; preds = %35
%41 = load i8*, i8** %8
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp ne i32 %43, 33
br i1 %44, label %45, label %46
45: ; preds = %40
store i32 1, i32* %9
br label %57
46: ; preds = %40
br label %54
47: ; preds = %35
%48 = load i8*, i8** %8
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 33
br i1 %51, label %52, label %53
52: ; preds = %47
store i32 1, i32* %9
br label %57
53: ; preds = %47
br label %54
54: ; preds = %53, %46
%55 = load i8*, i8** %6
%56 = call i8* @GetTok(i8* %55, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %8)
store i8* %56, i8** %6
br label %23
57: ; preds = %52, %45, %23
%58 = load i8*, i8** %8
%59 = call i32 @Destroy(i8* %58)
%60 = load i32, i32* %9
store i32 %60, i32* %3
br label %61
61: ; preds = %57, %19
%62 = load i32, i32* %3
ret i32 %62
}

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