#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*/ endswith(char *, char *);
char *strrchr(char *, char);
int wildmatch(char *, char const *);
int wildmatch_ext(char *pattern, const char *text) {
  int i, r;
  if (!endswith(pattern, "/***"))
    return wildmatch(pattern, text);
  i = strrchr(pattern, '/') - pattern;
  pattern[i] = '\0';
  if ((r = wildmatch(pattern, text)))
    return r;
  pattern[i] = '/';
  pattern[i + 3] = '\0';
  r = wildmatch(pattern, text);
  pattern[i + 3] = '*';
  return r;
}


x86 assembly (clang, -O0):
<wildmatch_ext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1040 <endswith@plt>
cmp    $0x0,%eax
jne    116e <wildmatch_ext+0x3e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <wildmatch@plt>
mov    %eax,-0x4(%rbp)
jmp    11fa <wildmatch_ext+0xca>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <wildmatch@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
je     11b6 <wildmatch_ext+0x86>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11fa <wildmatch_ext+0xca>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x2f,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <wildmatch@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movb   $0x2a,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wildmatch_ext>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xebb(%rip),%rsi
call   1040 <endswith@plt>
test   %eax,%eax
je     11b3 <wildmatch_ext+0x83>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
mov    %rax,%r15
sub    %rbx,%r15
movslq %r15d,%r12
movb   $0x0,(%rbx,%r12,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <wildmatch@plt>
test   %eax,%eax
jne    11a7 <wildmatch_ext+0x77>
shl    $0x20,%r15
movb   $0x2f,(%rbx,%r12,1)
movabs $0x300000000,%r12
add    %r15,%r12
sar    $0x20,%r12
movb   $0x0,(%rbx,%r12,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <wildmatch@plt>
movb   $0x2a,(%rbx,%r12,1)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <wildmatch@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"/***\00"
define i32 @wildmatch_ext(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = call i32 @endswith(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%10 = icmp ne i32 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = load i8*, i8** %5
%14 = call i32 @wildmatch(i8* %12, i8* %13)
store i32 %14, i32* %3
br label %52
15: ; preds = %2
%16 = load i8*, i8** %4
%17 = call i8* @strrchr(i8* %16, i8 signext 47)
%18 = load i8*, i8** %4
%19 = ptrtoint i8* %17 to i64
%20 = ptrtoint i8* %18 to i64
%21 = sub i64 %19, %20
%22 = trunc i64 %21 to i32
store i32 %22, i32* %6
%23 = load i8*, i8** %4
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
store i8 0, i8* %26
%27 = load i8*, i8** %4
%28 = load i8*, i8** %5
%29 = call i32 @wildmatch(i8* %27, i8* %28)
store i32 %29, i32* %7
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %15
%32 = load i32, i32* %7
store i32 %32, i32* %3
br label %52
33: ; preds = %15
%34 = load i8*, i8** %4
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
store i8 47, i8* %37
%38 = load i8*, i8** %4
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 3
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %38, i64 %41
store i8 0, i8* %42
%43 = load i8*, i8** %4
%44 = load i8*, i8** %5
%45 = call i32 @wildmatch(i8* %43, i8* %44)
store i32 %45, i32* %7
%46 = load i8*, i8** %4
%47 = load i32, i32* %6
%48 = add nsw i32 %47, 3
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %46, i64 %49
store i8 42, i8* %50
%51 = load i32, i32* %7
store i32 %51, i32* %3
br label %52
52: ; preds = %33, %31, %11
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
@.str = [5 x i8] c"/***\00"
define i32 @wildmatch_ext(i8* %0, i8* %1) {
%3 = tail call i32 @endswith(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @wildmatch(i8* %0, i8* %1)
br label %22
7: ; preds = %2
%8 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 47)
%9 = ptrtoint i8* %8 to i64
%10 = ptrtoint i8* %0 to i64
%11 = sub i64 %9, %10
%12 = shl i64 %11, 32
%13 = ashr exact i64 %12, 32
%14 = getelementptr inbounds i8, i8* %0, i64 %13
store i8 0, i8* %14
%15 = tail call i32 @wildmatch(i8* %0, i8* %1)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %7
store i8 47, i8* %14
%18 = add i64 %12, 12884901888
%19 = ashr exact i64 %18, 32
%20 = getelementptr inbounds i8, i8* %0, i64 %19
store i8 0, i8* %20
%21 = tail call i32 @wildmatch(i8* %0, i8* %1)
store i8 42, i8* %20
br label %22
22: ; preds = %7, %17, %5
%23 = phi i32 [ %21, %17 ], [ %6, %5 ], [ %15, %7 ]
ret i32 %23
}