#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 */
scalar_t__ toupper(int /*<<< orphan*/);
int subMatch(const char *str, const char *wild, char single, char multi) {
  int len = 0;
  for (;;) {
    if (toupper(*str++) != toupper(*wild++))
      return (0);
    ++len;
    char c = *wild;
    if (c == 0 || c == single || c == multi)
      return len;
  }
}


x86 assembly (clang, -O0):
<subMatch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %cl,%al
mov    %dl,%cl
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %cl,-0x19(%rbp)
mov    %al,-0x1a(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
je     117f <subMatch+0x6f>
movl   $0x0,-0x4(%rbp)
jmp    11ce <subMatch+0xbe>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x21(%rbp)
movsbl -0x21(%rbp),%eax
cmp    $0x0,%eax
je     11be <subMatch+0xae>
movsbl -0x21(%rbp),%eax
movsbl -0x19(%rbp),%ecx
cmp    %ecx,%eax
je     11be <subMatch+0xae>
movsbl -0x21(%rbp),%eax
movsbl -0x1a(%rbp),%ecx
cmp    %ecx,%eax
jne    11c9 <subMatch+0xb9>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ce <subMatch+0xbe>
jmp    1131 <subMatch+0x21>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<subMatch>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r12d
mov    %edx,%r15d
mov    %rsi,%rbp
mov    %rdi,%r13
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
movsbl 0x0(%r13,%r14,1),%edi
call   1030 <toupper@plt>
mov    %rax,%rbx
movsbl 0x0(%rbp,%r14,1),%edi
call   1030 <toupper@plt>
cmp    %rax,%rbx
jne    116b <subMatch+0x5b>
movzbl 0x1(%rbp,%r14,1),%eax
add    $0x1,%r14
cmp    %r12b,%al
je     1166 <subMatch+0x56>
test   %al,%al
je     1166 <subMatch+0x56>
cmp    %r15b,%al
jne    1130 <subMatch+0x20>
mov    %r14d,%eax
jmp    116d <subMatch+0x5d>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @subMatch(i8* nocapture %0, i8* nocapture %1, i8 signext %2, i8 signext %3) {
br label %5
5: ; preds = %17, %4
%6 = phi i8* [ %1, %4 ], [ %12, %17 ]
%7 = phi i8* [ %0, %4 ], [ %18, %17 ]
%8 = phi i32 [ 0, %4 ], [ %19, %17 ]
%9 = load i8, i8* %7
%10 = sext i8 %9 to i32
%11 = tail call i64 @toupper(i32 %10)
%12 = getelementptr inbounds i8, i8* %6, i64 1
%13 = load i8, i8* %6
%14 = sext i8 %13 to i32
%15 = tail call i64 @toupper(i32 %14)
%16 = icmp eq i64 %11, %15
br i1 %16, label %17, label %26
17: ; preds = %5
%18 = getelementptr inbounds i8, i8* %7, i64 1
%19 = add nuw nsw i32 %8, 1
%20 = load i8, i8* %12
%21 = icmp eq i8 %20, 0
%22 = icmp eq i8 %20, %2
%23 = or i1 %21, %22
%24 = icmp eq i8 %20, %3
%25 = or i1 %24, %23
br i1 %25, label %26, label %5
26: ; preds = %5, %17
%27 = phi i32 [ %19, %17 ], [ 0, %5 ]
ret i32 %27
}