#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*/ fnmatch(char const *, char const *, int /*<<< orphan*/);
int ylog_match(const char *pat, const char *fn) {
  const char *f;
  if (!fnmatch(pat, fn, 0))
    return 1;
  for (f = fn; *f; f++)
    if (*f == '/' && f[1] != '/' && !fnmatch(pat, f + 1, 0))
      return 1;
  return 0;
}


x86 assembly (clang, -O0):
<ylog_match>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1030 <fnmatch@plt>
cmp    $0x0,%eax
jne    1144 <ylog_match+0x34>
movl   $0x1,-0x4(%rbp)
jmp    11bf <ylog_match+0xaf>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     11b8 <ylog_match+0xa8>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    11a2 <ylog_match+0x92>
mov    -0x20(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2f,%eax
je     11a2 <ylog_match+0x92>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0x1,%rsi
xor    %edx,%edx
call   1030 <fnmatch@plt>
cmp    $0x0,%eax
jne    11a2 <ylog_match+0x92>
movl   $0x1,-0x4(%rbp)
jmp    11bf <ylog_match+0xaf>
jmp    11a7 <ylog_match+0x97>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    114c <ylog_match+0x3c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ylog_match>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%rbp
xor    %edx,%edx
call   1030 <fnmatch@plt>
mov    $0x1,%r14d
test   %eax,%eax
jne    1134 <ylog_match+0x24>
jmp    115b <ylog_match+0x4b>
nopl   (%rax)
test   %al,%al
je     1158 <ylog_match+0x48>
add    $0x1,%rbx
movzbl -0x1(%rbx),%eax
cmp    $0x2f,%al
jne    1130 <ylog_match+0x20>
cmpb   $0x2f,(%rbx)
je     1134 <ylog_match+0x24>
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <fnmatch@plt>
test   %eax,%eax
jne    1134 <ylog_match+0x24>
jmp    115b <ylog_match+0x4b>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @ylog_match(i8* %0, i8* %1) {
%3 = tail call i32 @fnmatch(i8* %0, i8* %1, i32 0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %17, label %5
5: ; preds = %2, %15
%6 = phi i8* [ %16, %15 ], [ %1, %2 ]
%7 = load i8, i8* %6
switch i8 %7, label %15 [
i8 0, label %17
i8 47, label %8
]
8: ; preds = %5
%9 = getelementptr inbounds i8, i8* %6, i64 1
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 47
br i1 %11, label %15, label %12
12: ; preds = %8
%13 = tail call i32 @fnmatch(i8* %0, i8* %9, i32 0)
%14 = icmp eq i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %5, %8, %12
%16 = getelementptr inbounds i8, i8* %6, i64 1
br label %5
17: ; preds = %5, %12, %2
%18 = phi i32 [ 1, %2 ], [ 0, %5 ], [ 1, %12 ]
ret i32 %18
}