#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 equal_nocase(unsigned char const *, size_t, unsigned char const *, size_t,
                 unsigned int);
unsigned char *valid_star(unsigned char const *, size_t, unsigned int);
int wildcard_match(unsigned char const *, int, unsigned char const *, int,
                   unsigned char const *, size_t, unsigned int);
int equal_wildcard(const unsigned char *pattern, size_t pattern_len,
                   const unsigned char *subject, size_t subject_len,
                   unsigned int flags) {
  const unsigned char *star = NULL;
  if (!(subject_len > 1 && subject[0] == '.'))
    star = valid_star(pattern, pattern_len, flags);
  if (star == NULL)
    return equal_nocase(pattern, pattern_len, subject, subject_len, flags);
  return wildcard_match(pattern, star - pattern, star + 1,
                        (pattern + pattern_len) - star - 1, subject,
                        subject_len, flags);
}


x86 assembly (clang, -O0):
<equal_wildcard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
movq   $0x0,-0x38(%rbp)
cmpq   $0x1,-0x28(%rbp)
jbe    116f <equal_wildcard+0x3f>
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x2e,%eax
je     1183 <equal_wildcard+0x53>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1030 <valid_star@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11af <equal_wildcard+0x7f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
call   1050 <equal_nocase@plt>
mov    %eax,-0x4(%rbp)
jmp    11f3 <equal_wildcard+0xc3>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
mov    -0x38(%rbp),%rdx
add    $0x1,%rdx
mov    -0x10(%rbp),%rax
add    -0x18(%rbp),%rax
mov    -0x38(%rbp),%rcx
sub    %rcx,%rax
sub    $0x1,%rax
mov    %eax,%ecx
mov    -0x20(%rbp),%r8
mov    -0x28(%rbp),%r9
mov    -0x2c(%rbp),%eax
mov    %eax,(%rsp)
call   1040 <wildcard_match@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<equal_wildcard>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %r8d,%r15d
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%rbp
cmp    $0x2,%rcx
jb     1157 <equal_wildcard+0x27>
cmpb   $0x2e,(%r14)
je     119c <equal_wildcard+0x6c>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1030 <valid_star@plt>
test   %rax,%rax
je     119c <equal_wildcard+0x6c>
mov    %eax,%esi
sub    %ebp,%esi
mov    %rax,%rdx
add    $0x1,%rdx
add    %ebp,%ebx
not    %eax
add    %ebx,%eax
mov    %r15d,(%rsp)
mov    %rbp,%rdi
mov    %eax,%ecx
mov    %r14,%r8
mov    %r12,%r9
call   1040 <wildcard_match@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %r15d,%r8d
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <equal_nocase@plt>

LLVM IR (-O0):
define i32 @equal_wildcard(i8* %0, i64 %1, i8* %2, i64 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32
%12 = alloca i8*
store i8* %0, i8** %7
store i64 %1, i64* %8
store i8* %2, i8** %9
store i64 %3, i64* %10
store i32 %4, i32* %11
store i8* null, i8** %12
%13 = load i64, i64* %10
%14 = icmp ugt i64 %13, 1
br i1 %14, label %15, label %21
15: ; preds = %5
%16 = load i8*, i8** %9
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = icmp eq i32 %19, 46
br i1 %20, label %26, label %21
21: ; preds = %15, %5
%22 = load i8*, i8** %7
%23 = load i64, i64* %8
%24 = load i32, i32* %11
%25 = call i8* @valid_star(i8* %22, i64 %23, i32 %24)
store i8* %25, i8** %12
br label %26
26: ; preds = %21, %15
%27 = load i8*, i8** %12
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %36
29: ; preds = %26
%30 = load i8*, i8** %7
%31 = load i64, i64* %8
%32 = load i8*, i8** %9
%33 = load i64, i64* %10
%34 = load i32, i32* %11
%35 = call i32 @equal_nocase(i8* %30, i64 %31, i8* %32, i64 %33, i32 %34)
store i32 %35, i32* %6
br label %59
36: ; preds = %26
%37 = load i8*, i8** %7
%38 = load i8*, i8** %12
%39 = load i8*, i8** %7
%40 = ptrtoint i8* %38 to i64
%41 = ptrtoint i8* %39 to i64
%42 = sub i64 %40, %41
%43 = trunc i64 %42 to i32
%44 = load i8*, i8** %12
%45 = getelementptr inbounds i8, i8* %44, i64 1
%46 = load i8*, i8** %7
%47 = load i64, i64* %8
%48 = getelementptr inbounds i8, i8* %46, i64 %47
%49 = load i8*, i8** %12
%50 = ptrtoint i8* %48 to i64
%51 = ptrtoint i8* %49 to i64
%52 = sub i64 %50, %51
%53 = sub nsw i64 %52, 1
%54 = trunc i64 %53 to i32
%55 = load i8*, i8** %9
%56 = load i64, i64* %10
%57 = load i32, i32* %11
%58 = call i32 @wildcard_match(i8* %37, i32 %43, i8* %45, i32 %54, i8* %55, i64 %56, i32 %57)
store i32 %58, i32* %6
br label %59
59: ; preds = %36, %29
%60 = load i32, i32* %6
ret i32 %60
}

LLVM IR (-O2):
define i32 @equal_wildcard(i8* %0, i64 %1, i8* %2, i64 %3, i32 %4) {
%6 = icmp ugt i64 %3, 1
br i1 %6, label %7, label %10
7: ; preds = %5
%8 = load i8, i8* %2
%9 = icmp eq i8 %8, 46
br i1 %9, label %13, label %10
10: ; preds = %5, %7
%11 = tail call i8* @valid_star(i8* %0, i64 %1, i32 %4)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %15
13: ; preds = %7, %10
%14 = tail call i32 @equal_nocase(i8* %0, i64 %1, i8* %2, i64 %3, i32 %4)
br label %27
15: ; preds = %10
%16 = ptrtoint i8* %11 to i64
%17 = ptrtoint i8* %0 to i64
%18 = sub i64 %16, %17
%19 = trunc i64 %18 to i32
%20 = getelementptr inbounds i8, i8* %11, i64 1
%21 = getelementptr inbounds i8, i8* %0, i64 %1
%22 = ptrtoint i8* %21 to i64
%23 = xor i64 %16, -1
%24 = add i64 %23, %22
%25 = trunc i64 %24 to i32
%26 = tail call i32 @wildcard_match(i8* %0, i32 %19, i8* %20, i32 %25, i8* %2, i64 %3, i32 %4)
br label %27
27: ; preds = %15, %13
%28 = phi i32 [ %14, %13 ], [ %26, %15 ]
ret i32 %28
}