#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 isalnum(unsigned char);
int isalpha(unsigned char);
int iscntrl(unsigned char);
int isdigit(unsigned char);
int islower(unsigned char);
int ispunct(unsigned char);
int isspace(unsigned char);
int isupper(unsigned char);
int tolower(unsigned char);
int matchclass(int c, int cl) {
  int res;
  switch (tolower((unsigned char)cl)) {
  case 'a':
    res = isalpha((unsigned char)c);
    break;
  case 'c':
    res = iscntrl((unsigned char)c);
    break;
  case 'd':
    res = isdigit((unsigned char)c);
    break;
  case 'l':
    res = islower((unsigned char)c);
    break;
  case 'p':
    res = ispunct((unsigned char)c);
    break;
  case 's':
    res = isspace((unsigned char)c);
    break;
  case 'u':
    res = isupper((unsigned char)c);
    break;
  case 'w':
    res = isalnum((unsigned char)c);
    break;
  default:
    return (cl == c);
  }
  return (islower((unsigned char)cl) ? res : !res);
}


x86 assembly (clang, -O0):
<matchclass>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movzbl -0xc(%rbp),%edi
call   1090 <tolower@plt>
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x16,%eax
ja     1265 <matchclass+0xd5>
mov    -0x18(%rbp),%rax
lea    0xe3c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%eax
movzbl %al,%edi
call   10a0 <isalpha@plt>
mov    %eax,-0x10(%rbp)
jmp    127b <matchclass+0xeb>
mov    -0x8(%rbp),%eax
movzbl %al,%edi
call   1050 <iscntrl@plt>
mov    %eax,-0x10(%rbp)
jmp    127b <matchclass+0xeb>
mov    -0x8(%rbp),%eax
movzbl %al,%edi
call   1030 <isdigit@plt>
mov    %eax,-0x10(%rbp)
jmp    127b <matchclass+0xeb>
mov    -0x8(%rbp),%eax
movzbl %al,%edi
call   1040 <islower@plt>
mov    %eax,-0x10(%rbp)
jmp    127b <matchclass+0xeb>
mov    -0x8(%rbp),%eax
movzbl %al,%edi
call   1070 <ispunct@plt>
mov    %eax,-0x10(%rbp)
jmp    127b <matchclass+0xeb>
mov    -0x8(%rbp),%eax
movzbl %al,%edi
call   1080 <isspace@plt>
mov    %eax,-0x10(%rbp)
jmp    127b <matchclass+0xeb>
mov    -0x8(%rbp),%eax
movzbl %al,%edi
call   10b0 <isupper@plt>
mov    %eax,-0x10(%rbp)
jmp    127b <matchclass+0xeb>
mov    -0x8(%rbp),%eax
movzbl %al,%edi
call   1060 <isalnum@plt>
mov    %eax,-0x10(%rbp)
jmp    127b <matchclass+0xeb>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    12b1 <matchclass+0x121>
mov    -0xc(%rbp),%eax
movzbl %al,%edi
call   1040 <islower@plt>
cmp    $0x0,%eax
je     129a <matchclass+0x10a>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    12ab <matchclass+0x11b>
cmpl   $0x0,-0x10(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matchclass>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%ebp
movzbl %bl,%r14d
mov    %r14d,%edi
call   1090 <tolower@plt>
add    $0xffffff9f,%eax
cmp    $0x16,%eax
ja     11c7 <matchclass+0x37>
lea    0xe4d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movzbl %bpl,%edi
call   10a0 <isalpha@plt>
jmp    121b <matchclass+0x8b>
xor    %eax,%eax
cmp    %ebp,%ebx
sete   %al
jmp    1233 <matchclass+0xa3>
movzbl %bpl,%edi
call   1050 <iscntrl@plt>
jmp    121b <matchclass+0x8b>
movzbl %bpl,%edi
call   1030 <isdigit@plt>
jmp    121b <matchclass+0x8b>
movzbl %bpl,%edi
call   1040 <islower@plt>
jmp    121b <matchclass+0x8b>
movzbl %bpl,%edi
call   1070 <ispunct@plt>
jmp    121b <matchclass+0x8b>
movzbl %bpl,%edi
call   1080 <isspace@plt>
jmp    121b <matchclass+0x8b>
movzbl %bpl,%edi
call   10b0 <isupper@plt>
jmp    121b <matchclass+0x8b>
movzbl %bpl,%edi
call   1060 <isalnum@plt>
mov    %eax,%ebp
mov    %r14d,%edi
call   1040 <islower@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ebp,%ebp
sete   %al
test   %ecx,%ecx
cmovne %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @matchclass(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %5
%8 = trunc i32 %7 to i8
%9 = call i32 @tolower(i8 zeroext %8)
switch i32 %9, label %42 [
i32 97, label %10
i32 99, label %14
i32 100, label %18
i32 108, label %22
i32 112, label %26
i32 115, label %30
i32 117, label %34
i32 119, label %38
]
10: ; preds = %2
%11 = load i32, i32* %4
%12 = trunc i32 %11 to i8
%13 = call i32 @isalpha(i8 zeroext %12)
store i32 %13, i32* %6
br label %47
14: ; preds = %2
%15 = load i32, i32* %4
%16 = trunc i32 %15 to i8
%17 = call i32 @iscntrl(i8 zeroext %16)
store i32 %17, i32* %6
br label %47
18: ; preds = %2
%19 = load i32, i32* %4
%20 = trunc i32 %19 to i8
%21 = call i32 @isdigit(i8 zeroext %20)
store i32 %21, i32* %6
br label %47
22: ; preds = %2
%23 = load i32, i32* %4
%24 = trunc i32 %23 to i8
%25 = call i32 @islower(i8 zeroext %24)
store i32 %25, i32* %6
br label %47
26: ; preds = %2
%27 = load i32, i32* %4
%28 = trunc i32 %27 to i8
%29 = call i32 @ispunct(i8 zeroext %28)
store i32 %29, i32* %6
br label %47
30: ; preds = %2
%31 = load i32, i32* %4
%32 = trunc i32 %31 to i8
%33 = call i32 @isspace(i8 zeroext %32)
store i32 %33, i32* %6
br label %47
34: ; preds = %2
%35 = load i32, i32* %4
%36 = trunc i32 %35 to i8
%37 = call i32 @isupper(i8 zeroext %36)
store i32 %37, i32* %6
br label %47
38: ; preds = %2
%39 = load i32, i32* %4
%40 = trunc i32 %39 to i8
%41 = call i32 @isalnum(i8 zeroext %40)
store i32 %41, i32* %6
br label %47
42: ; preds = %2
%43 = load i32, i32* %5
%44 = load i32, i32* %4
%45 = icmp eq i32 %43, %44
%46 = zext i1 %45 to i32
store i32 %46, i32* %3
br label %61
47: ; preds = %38, %34, %30, %26, %22, %18, %14, %10
%48 = load i32, i32* %5
%49 = trunc i32 %48 to i8
%50 = call i32 @islower(i8 zeroext %49)
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %54
52: ; preds = %47
%53 = load i32, i32* %6
br label %59
54: ; preds = %47
%55 = load i32, i32* %6
%56 = icmp ne i32 %55, 0
%57 = xor i1 %56, true
%58 = zext i1 %57 to i32
br label %59
59: ; preds = %54, %52
%60 = phi i32 [ %53, %52 ], [ %58, %54 ]
store i32 %60, i32* %3
br label %61
61: ; preds = %59, %42
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
define i32 @matchclass(i32 %0, i32 %1) {
%3 = trunc i32 %1 to i8
%4 = tail call i32 @tolower(i8 zeroext %3)
switch i32 %4, label %29 [
i32 97, label %5
i32 99, label %8
i32 100, label %11
i32 108, label %14
i32 112, label %17
i32 115, label %20
i32 117, label %23
i32 119, label %26
]
5: ; preds = %2
%6 = trunc i32 %0 to i8
%7 = tail call i32 @isalpha(i8 zeroext %6)
br label %32
8: ; preds = %2
%9 = trunc i32 %0 to i8
%10 = tail call i32 @iscntrl(i8 zeroext %9)
br label %32
11: ; preds = %2
%12 = trunc i32 %0 to i8
%13 = tail call i32 @isdigit(i8 zeroext %12)
br label %32
14: ; preds = %2
%15 = trunc i32 %0 to i8
%16 = tail call i32 @islower(i8 zeroext %15)
br label %32
17: ; preds = %2
%18 = trunc i32 %0 to i8
%19 = tail call i32 @ispunct(i8 zeroext %18)
br label %32
20: ; preds = %2
%21 = trunc i32 %0 to i8
%22 = tail call i32 @isspace(i8 zeroext %21)
br label %32
23: ; preds = %2
%24 = trunc i32 %0 to i8
%25 = tail call i32 @isupper(i8 zeroext %24)
br label %32
26: ; preds = %2
%27 = trunc i32 %0 to i8
%28 = tail call i32 @isalnum(i8 zeroext %27)
br label %32
29: ; preds = %2
%30 = icmp eq i32 %1, %0
%31 = zext i1 %30 to i32
br label %39
32: ; preds = %26, %23, %20, %17, %14, %11, %8, %5
%33 = phi i32 [ %28, %26 ], [ %25, %23 ], [ %22, %20 ], [ %19, %17 ], [ %16, %14 ], [ %13, %11 ], [ %10, %8 ], [ %7, %5 ]
%34 = tail call i32 @islower(i8 zeroext %3)
%35 = icmp eq i32 %34, 0
%36 = icmp eq i32 %33, 0
%37 = zext i1 %36 to i32
%38 = select i1 %35, i32 %37, i32 %33
br label %39
39: ; preds = %32, %29
%40 = phi i32 [ %31, %29 ], [ %38, %32 ]
ret i32 %40
}