#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(char *str, char *wild) {
  int len = 0;
  for (;;) {
    if (toupper(*str++) != toupper(*wild++))
      return (0);
    ++len;
    switch (*wild) {
    case 0:
    case '?':
    case '*':
      return (len);
    }
  }
}


x86 assembly (clang, -O0):
<subMatch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %rax,-0x28(%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    -0x28(%rbp),%rax
cmp    %rcx,%rax
je     1175 <subMatch+0x65>
movl   $0x0,-0x4(%rbp)
jmp    11c7 <subMatch+0xb7>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x2c(%rbp)
test   %eax,%eax
je     11b7 <subMatch+0xa7>
jmp    1195 <subMatch+0x85>
mov    -0x2c(%rbp),%eax
sub    $0x2a,%eax
je     11b7 <subMatch+0xa7>
jmp    11a6 <subMatch+0x96>
mov    -0x2c(%rbp),%eax
sub    $0x3f,%eax
jne    11c2 <subMatch+0xb2>
jmp    11b7 <subMatch+0xa7>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c7 <subMatch+0xb7>
jmp    1127 <subMatch+0x17>
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    %rsi,%r12
mov    %rdi,%r15
xor    %r14d,%r14d
movabs $0x8000040000000001,%rbp
xor    %ebx,%ebx
movsbl (%r15,%rbx,1),%edi
call   1030 <toupper@plt>
mov    %rax,%r13
movsbl (%r12,%rbx,1),%edi
call   1030 <toupper@plt>
cmp    %rax,%r13
jne    1164 <subMatch+0x54>
movsbl 0x1(%r12,%rbx,1),%eax
add    $0x1,%rbx
cmp    $0x3f,%eax
ja     1130 <subMatch+0x20>
bt     %rax,%rbp
jae    1130 <subMatch+0x20>
mov    %ebx,%r14d
mov    %r14d,%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) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 0, i32* %6
br label %7
7: ; preds = %28, %2
%8 = load i8*, i8** %4
%9 = getelementptr inbounds i8, i8* %8, i32 1
store i8* %9, i8** %4
%10 = load i8, i8* %8
%11 = sext i8 %10 to i32
%12 = call i64 @toupper(i32 %11)
%13 = load i8*, i8** %5
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %5
%15 = load i8, i8* %13
%16 = sext i8 %15 to i32
%17 = call i64 @toupper(i32 %16)
%18 = icmp ne i64 %12, %17
br i1 %18, label %19, label %20
19: ; preds = %7
store i32 0, i32* %3
br label %29
20: ; preds = %7
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
%23 = load i8*, i8** %5
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
switch i32 %25, label %28 [
i32 0, label %26
i32 63, label %26
i32 42, label %26
]
26: ; preds = %20, %20, %20
%27 = load i32, i32* %6
store i32 %27, i32* %3
br label %29
28: ; preds = %20
br label %7
29: ; preds = %26, %19
%30 = load i32, i32* %3
ret i32 %30
}

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