#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 */
char *estrchr(char *, char, char);
int smatch(char *, char const *);
char *strchr(char const *, char);
int /*<<< orphan*/ strlen(char const *);
int wmatch(char *wlist, const char **s2) {
  char *matchstr;
  char *strend;
  const char *matchbuf;
  char *bufend;
  int result = 1;
  if (!wlist || !*s2)
    return 1;
  matchbuf = *s2;
  matchstr = wlist;
  bufend = strchr(matchbuf, ' ');
  if (bufend == NULL)
    *s2 += strlen(*s2);
  else {
    *s2 = bufend;
    *bufend = '\0';
  }
  do {
    if ((strend = estrchr(matchstr, '|', '\\')) != NULL)
      *strend = '\0';
    result = smatch(matchstr, matchbuf);
    if (strend != NULL)
      *strend++ = '|';
    if (!result)
      break;
  } while ((matchstr = strend) != NULL);
  if (bufend != NULL)
    *bufend = ' ';
  return result;
}


x86 assembly (clang, -O0):
<wmatch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x1,-0x3c(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1170 <wmatch+0x30>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    117c <wmatch+0x3c>
movl   $0x1,-0x4(%rbp)
jmp    1279 <wmatch+0x139>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x30(%rbp),%rdi
mov    $0x20,%esi
call   1060 <strchr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11cf <wmatch+0x8f>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1050 <strlen@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
movslq %edx,%rdx
add    %rdx,%rcx
mov    %rcx,(%rax)
jmp    11e1 <wmatch+0xa1>
mov    -0x38(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
jmp    11e6 <wmatch+0xa6>
mov    -0x20(%rbp),%rdi
mov    $0x7c,%esi
mov    $0x5c,%edx
call   1030 <estrchr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     120e <wmatch+0xce>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <smatch@plt>
mov    %eax,-0x3c(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     123b <wmatch+0xfb>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0x7c,(%rax)
cmpl   $0x0,-0x3c(%rbp)
jne    124a <wmatch+0x10a>
jmp    1261 <wmatch+0x121>
jmp    124f <wmatch+0x10f>
mov    -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11e6 <wmatch+0xa6>
cmpq   $0x0,-0x38(%rbp)
je     1273 <wmatch+0x133>
mov    -0x38(%rbp),%rax
movb   $0x20,(%rax)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wmatch>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    $0x1,%eax
test   %rdi,%rdi
je     11f3 <wmatch+0xb3>
mov    %rsi,%r12
mov    (%rsi),%r15
test   %r15,%r15
je     11f3 <wmatch+0xb3>
mov    %rdi,%r13
mov    %r15,%rdi
mov    $0x20,%esi
call   1060 <strchr@plt>
mov    %rax,%r14
test   %rax,%rax
je     1188 <wmatch+0x48>
mov    %r14,(%r12)
movb   $0x0,(%r14)
jmp    11a0 <wmatch+0x60>
mov    %r15,%rdi
call   1050 <strlen@plt>
cltq
add    %rax,(%r12)
cs nopw 0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    $0x7c,%esi
mov    $0x5c,%edx
call   1030 <estrchr@plt>
test   %rax,%rax
je     11df <wmatch+0x9f>
mov    %rax,%rbx
movb   $0x0,(%rax)
mov    %r13,%rdi
mov    %r15,%rsi
call   1040 <smatch@plt>
mov    %rbx,%r13
add    $0x1,%r13
movb   $0x7c,(%rbx)
test   %eax,%eax
jne    11a0 <wmatch+0x60>
xor    %eax,%eax
test   %r14,%r14
jne    11ef <wmatch+0xaf>
jmp    11f3 <wmatch+0xb3>
mov    %r13,%rdi
mov    %r15,%rsi
call   1040 <smatch@plt>
test   %r14,%r14
je     11f3 <wmatch+0xb3>
movb   $0x20,(%r14)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @wmatch(i8* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32 1, i32* %10
%11 = load i8*, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = load i8*, i8** %14
%16 = icmp ne i8* %15, null
br i1 %16, label %18, label %17
17: ; preds = %13, %2
store i32 1, i32* %3
br label %69
18: ; preds = %13
%19 = load i8**, i8*** %5
%20 = load i8*, i8** %19
store i8* %20, i8** %8
%21 = load i8*, i8** %4
store i8* %21, i8** %6
%22 = load i8*, i8** %8
%23 = call i8* @strchr(i8* %22, i8 signext 32)
store i8* %23, i8** %9
%24 = load i8*, i8** %9
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %34
26: ; preds = %18
%27 = load i8**, i8*** %5
%28 = load i8*, i8** %27
%29 = call i32 @strlen(i8* %28)
%30 = load i8**, i8*** %5
%31 = load i8*, i8** %30
%32 = sext i32 %29 to i64
%33 = getelementptr inbounds i8, i8* %31, i64 %32
store i8* %33, i8** %30
br label %38
34: ; preds = %18
%35 = load i8*, i8** %9
%36 = load i8**, i8*** %5
store i8* %35, i8** %36
%37 = load i8*, i8** %9
store i8 0, i8* %37
br label %38
38: ; preds = %34, %26
br label %39
39: ; preds = %59, %38
%40 = load i8*, i8** %6
%41 = call i8* @estrchr(i8* %40, i8 signext 124, i8 signext 92)
store i8* %41, i8** %7
%42 = icmp ne i8* %41, null
br i1 %42, label %43, label %45
43: ; preds = %39
%44 = load i8*, i8** %7
store i8 0, i8* %44
br label %45
45: ; preds = %43, %39
%46 = load i8*, i8** %6
%47 = load i8*, i8** %8
%48 = call i32 @smatch(i8* %46, i8* %47)
store i32 %48, i32* %10
%49 = load i8*, i8** %7
%50 = icmp ne i8* %49, null
br i1 %50, label %51, label %54
51: ; preds = %45
%52 = load i8*, i8** %7
%53 = getelementptr inbounds i8, i8* %52, i32 1
store i8* %53, i8** %7
store i8 124, i8* %52
br label %54
54: ; preds = %51, %45
%55 = load i32, i32* %10
%56 = icmp ne i32 %55, 0
br i1 %56, label %58, label %57
57: ; preds = %54
br label %62
58: ; preds = %54
br label %59
59: ; preds = %58
%60 = load i8*, i8** %7
store i8* %60, i8** %6
%61 = icmp ne i8* %60, null
br i1 %61, label %39, label %62
62: ; preds = %59, %57
%63 = load i8*, i8** %9
%64 = icmp ne i8* %63, null
br i1 %64, label %65, label %67
65: ; preds = %62
%66 = load i8*, i8** %9
store i8 32, i8* %66
br label %67
67: ; preds = %65, %62
%68 = load i32, i32* %10
store i32 %68, i32* %3
br label %69
69: ; preds = %67, %17
%70 = load i32, i32* %3
ret i32 %70
}

LLVM IR (-O2):
define i32 @wmatch(i8* %0, i8** nocapture %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %30, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = icmp eq i8* %5, null
br i1 %6, label %30, label %7
7: ; preds = %4
%8 = tail call i8* @strchr(i8* %5, i8 signext 32)
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = tail call i32 @strlen(i8* %5)
%12 = load i8*, i8** %1
%13 = sext i32 %11 to i64
%14 = getelementptr inbounds i8, i8* %12, i64 %13
store i8* %14, i8** %1
br label %16
15: ; preds = %7
store i8* %8, i8** %1
store i8 0, i8* %8
br label %16
16: ; preds = %15, %10
br label %17
17: ; preds = %16, %23
%18 = phi i8* [ %25, %23 ], [ %0, %16 ]
%19 = tail call i8* @estrchr(i8* %18, i8 signext 124, i8 signext 92)
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = tail call i32 @smatch(i8* %18, i8* %5)
br label %27
23: ; preds = %17
store i8 0, i8* %19
%24 = tail call i32 @smatch(i8* %18, i8* %5)
%25 = getelementptr inbounds i8, i8* %19, i64 1
store i8 124, i8* %19
%26 = icmp eq i32 %24, 0
br i1 %26, label %27, label %17
27: ; preds = %23, %21
%28 = phi i32 [ %22, %21 ], [ 0, %23 ]
br i1 %9, label %30, label %29
29: ; preds = %27
store i8 32, i8* %8
br label %30
30: ; preds = %27, %29, %2, %4
%31 = phi i32 [ 1, %4 ], [ 1, %2 ], [ %28, %29 ], [ %28, %27 ]
ret i32 %31
}