#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 matchalphanum(char);
int matchdigit(char);
int matchwhitespace(char);
int matchmetachar(char c, const char *str) {
  switch (str[0]) {
  case 'd':
    return matchdigit(c);
  case 'D':
    return !matchdigit(c);
  case 'w':
    return matchalphanum(c);
  case 'W':
    return !matchalphanum(c);
  case 's':
    return matchwhitespace(c);
  case 'S':
    return !matchwhitespace(c);
  default:
    return (c == str[0]);
  }
}


x86 assembly (clang, -O0):
<matchmetachar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffbc,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x33,%eax
ja     11fc <matchmetachar+0xcc>
mov    -0x18(%rbp),%rax
lea    0xe9a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsbl -0x5(%rbp),%edi
call   1030 <matchdigit@plt>
mov    %eax,-0x4(%rbp)
jmp    1214 <matchmetachar+0xe4>
movsbl -0x5(%rbp),%edi
call   1030 <matchdigit@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1214 <matchmetachar+0xe4>
movsbl -0x5(%rbp),%edi
call   1050 <matchalphanum@plt>
mov    %eax,-0x4(%rbp)
jmp    1214 <matchmetachar+0xe4>
movsbl -0x5(%rbp),%edi
call   1050 <matchalphanum@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1214 <matchmetachar+0xe4>
movsbl -0x5(%rbp),%edi
call   1040 <matchwhitespace@plt>
mov    %eax,-0x4(%rbp)
jmp    1214 <matchmetachar+0xe4>
movsbl -0x5(%rbp),%edi
call   1040 <matchwhitespace@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1214 <matchmetachar+0xe4>
movsbl -0x5(%rbp),%eax
mov    -0x10(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matchmetachar>:
push   %rax
movsbl (%rsi),%ecx
lea    -0x44(%rcx),%eax
cmp    $0x33,%eax
ja     1157 <matchmetachar+0x27>
lea    0xebd(%rip),%rdx
movslq (%rdx,%rax,4),%rax
add    %rdx,%rax
jmp    *%rax
movsbl %dil,%edi
call   1030 <matchdigit@plt>
jmp    1172 <matchmetachar+0x42>
xor    %eax,%eax
cmp    %dil,%cl
jmp    1178 <matchmetachar+0x48>
movsbl %dil,%edi
call   1040 <matchwhitespace@plt>
jmp    1172 <matchmetachar+0x42>
movsbl %dil,%edi
call   1050 <matchalphanum@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
pop    %rcx
ret
movsbl %dil,%edi
pop    %rax
jmp    1030 <matchdigit@plt>
movsbl %dil,%edi
pop    %rax
jmp    1040 <matchwhitespace@plt>
movsbl %dil,%edi
pop    %rax
jmp    1050 <matchalphanum@plt>

LLVM IR (-O0):
define i32 @matchmetachar(i8 signext %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8*
store i8 %0, i8* %4
store i8* %1, i8** %5
%6 = load i8*, i8** %5
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
switch i32 %9, label %37 [
i32 100, label %10
i32 68, label %13
i32 119, label %19
i32 87, label %22
i32 115, label %28
i32 83, label %31
]
10: ; preds = %2
%11 = load i8, i8* %4
%12 = call i32 @matchdigit(i8 signext %11)
store i32 %12, i32* %3
br label %46
13: ; preds = %2
%14 = load i8, i8* %4
%15 = call i32 @matchdigit(i8 signext %14)
%16 = icmp ne i32 %15, 0
%17 = xor i1 %16, true
%18 = zext i1 %17 to i32
store i32 %18, i32* %3
br label %46
19: ; preds = %2
%20 = load i8, i8* %4
%21 = call i32 @matchalphanum(i8 signext %20)
store i32 %21, i32* %3
br label %46
22: ; preds = %2
%23 = load i8, i8* %4
%24 = call i32 @matchalphanum(i8 signext %23)
%25 = icmp ne i32 %24, 0
%26 = xor i1 %25, true
%27 = zext i1 %26 to i32
store i32 %27, i32* %3
br label %46
28: ; preds = %2
%29 = load i8, i8* %4
%30 = call i32 @matchwhitespace(i8 signext %29)
store i32 %30, i32* %3
br label %46
31: ; preds = %2
%32 = load i8, i8* %4
%33 = call i32 @matchwhitespace(i8 signext %32)
%34 = icmp ne i32 %33, 0
%35 = xor i1 %34, true
%36 = zext i1 %35 to i32
store i32 %36, i32* %3
br label %46
37: ; preds = %2
%38 = load i8, i8* %4
%39 = sext i8 %38 to i32
%40 = load i8*, i8** %5
%41 = getelementptr inbounds i8, i8* %40, i64 0
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %39, %43
%45 = zext i1 %44 to i32
store i32 %45, i32* %3
br label %46
46: ; preds = %37, %31, %28, %22, %19, %13, %10
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
define i32 @matchmetachar(i8 signext %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = sext i8 %3 to i32
switch i32 %4, label %23 [
i32 100, label %5
i32 68, label %7
i32 119, label %11
i32 87, label %13
i32 115, label %17
i32 83, label %19
]
5: ; preds = %2
%6 = tail call i32 @matchdigit(i8 signext %0)
br label %26
7: ; preds = %2
%8 = tail call i32 @matchdigit(i8 signext %0)
%9 = icmp eq i32 %8, 0
%10 = zext i1 %9 to i32
br label %26
11: ; preds = %2
%12 = tail call i32 @matchalphanum(i8 signext %0)
br label %26
13: ; preds = %2
%14 = tail call i32 @matchalphanum(i8 signext %0)
%15 = icmp eq i32 %14, 0
%16 = zext i1 %15 to i32
br label %26
17: ; preds = %2
%18 = tail call i32 @matchwhitespace(i8 signext %0)
br label %26
19: ; preds = %2
%20 = tail call i32 @matchwhitespace(i8 signext %0)
%21 = icmp eq i32 %20, 0
%22 = zext i1 %21 to i32
br label %26
23: ; preds = %2
%24 = icmp eq i8 %3, %0
%25 = zext i1 %24 to i32
br label %26
26: ; preds = %23, %19, %17, %13, %11, %7, %5
%27 = phi i32 [ %25, %23 ], [ %22, %19 ], [ %18, %17 ], [ %16, %13 ], [ %12, %11 ], [ %10, %7 ], [ %6, %5 ]
ret i32 %27
}