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


x86 assembly (clang, -O0):
<Pattern_internal_match_class>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1090 <tolower@plt>
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x17,%eax
ja     128c <Pattern_internal_match_class+0xdc>
mov    -0x18(%rbp),%rax
lea    0xe1d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%edi
call   10a0 <isalpha@plt>
mov    %eax,-0x10(%rbp)
jmp    12a2 <Pattern_internal_match_class+0xf2>
mov    -0x8(%rbp),%edi
call   1050 <iscntrl@plt>
mov    %eax,-0x10(%rbp)
jmp    12a2 <Pattern_internal_match_class+0xf2>
mov    -0x8(%rbp),%edi
call   1030 <isdigit@plt>
mov    %eax,-0x10(%rbp)
jmp    12a2 <Pattern_internal_match_class+0xf2>
mov    -0x8(%rbp),%edi
call   10d0 <isgraph@plt>
mov    %eax,-0x10(%rbp)
jmp    12a2 <Pattern_internal_match_class+0xf2>
mov    -0x8(%rbp),%edi
call   1040 <islower@plt>
mov    %eax,-0x10(%rbp)
jmp    12a2 <Pattern_internal_match_class+0xf2>
mov    -0x8(%rbp),%edi
call   1070 <ispunct@plt>
mov    %eax,-0x10(%rbp)
jmp    12a2 <Pattern_internal_match_class+0xf2>
mov    -0x8(%rbp),%edi
call   1080 <isspace@plt>
mov    %eax,-0x10(%rbp)
jmp    12a2 <Pattern_internal_match_class+0xf2>
mov    -0x8(%rbp),%edi
call   10b0 <isupper@plt>
mov    %eax,-0x10(%rbp)
jmp    12a2 <Pattern_internal_match_class+0xf2>
mov    -0x8(%rbp),%edi
call   1060 <isalnum@plt>
mov    %eax,-0x10(%rbp)
jmp    12a2 <Pattern_internal_match_class+0xf2>
mov    -0x8(%rbp),%edi
call   10c0 <isxdigit@plt>
mov    %eax,-0x10(%rbp)
jmp    12a2 <Pattern_internal_match_class+0xf2>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    12d5 <Pattern_internal_match_class+0x125>
mov    -0xc(%rbp),%edi
call   1040 <islower@plt>
cmp    $0x0,%eax
je     12be <Pattern_internal_match_class+0x10e>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    12cf <Pattern_internal_match_class+0x11f>
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):
<Pattern_internal_match_class>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %edi,%ebx
mov    %esi,%edi
call   1080 <tolower@plt>
add    $0xffffff9f,%eax
cmp    $0x17,%eax
ja     11d1 <Pattern_internal_match_class+0x31>
lea    0xe41(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %ebx,%edi
call   1090 <isalpha@plt>
jmp    122f <Pattern_internal_match_class+0x8f>
xor    %eax,%eax
cmp    %ebx,%r14d
sete   %al
jmp    1247 <Pattern_internal_match_class+0xa7>
mov    %ebx,%edi
call   1040 <iscntrl@plt>
jmp    122f <Pattern_internal_match_class+0x8f>
add    $0xffffffd0,%ebx
xor    %ebp,%ebp
cmp    $0xa,%ebx
setb   %bpl
jmp    1231 <Pattern_internal_match_class+0x91>
mov    %ebx,%edi
call   10c0 <isgraph@plt>
jmp    122f <Pattern_internal_match_class+0x8f>
mov    %ebx,%edi
call   1030 <islower@plt>
jmp    122f <Pattern_internal_match_class+0x8f>
mov    %ebx,%edi
call   1060 <ispunct@plt>
jmp    122f <Pattern_internal_match_class+0x8f>
mov    %ebx,%edi
call   1070 <isspace@plt>
jmp    122f <Pattern_internal_match_class+0x8f>
mov    %ebx,%edi
call   10a0 <isupper@plt>
jmp    122f <Pattern_internal_match_class+0x8f>
mov    %ebx,%edi
call   1050 <isalnum@plt>
jmp    122f <Pattern_internal_match_class+0x8f>
mov    %ebx,%edi
call   10b0 <isxdigit@plt>
mov    %eax,%ebp
mov    %r14d,%edi
call   1030 <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 @Pattern_internal_match_class(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 = call i32 @tolower(i32 %7)
switch i32 %8, label %39 [
i32 97, label %9
i32 99, label %12
i32 100, label %15
i32 103, label %18
i32 108, label %21
i32 112, label %24
i32 115, label %27
i32 117, label %30
i32 119, label %33
i32 120, label %36
]
9: ; preds = %2
%10 = load i32, i32* %4
%11 = call i32 @isalpha(i32 %10)
store i32 %11, i32* %6
br label %44
12: ; preds = %2
%13 = load i32, i32* %4
%14 = call i32 @iscntrl(i32 %13)
store i32 %14, i32* %6
br label %44
15: ; preds = %2
%16 = load i32, i32* %4
%17 = call i32 @isdigit(i32 %16)
store i32 %17, i32* %6
br label %44
18: ; preds = %2
%19 = load i32, i32* %4
%20 = call i32 @isgraph(i32 %19)
store i32 %20, i32* %6
br label %44
21: ; preds = %2
%22 = load i32, i32* %4
%23 = call i32 @islower(i32 %22)
store i32 %23, i32* %6
br label %44
24: ; preds = %2
%25 = load i32, i32* %4
%26 = call i32 @ispunct(i32 %25)
store i32 %26, i32* %6
br label %44
27: ; preds = %2
%28 = load i32, i32* %4
%29 = call i32 @isspace(i32 %28)
store i32 %29, i32* %6
br label %44
30: ; preds = %2
%31 = load i32, i32* %4
%32 = call i32 @isupper(i32 %31)
store i32 %32, i32* %6
br label %44
33: ; preds = %2
%34 = load i32, i32* %4
%35 = call i32 @isalnum(i32 %34)
store i32 %35, i32* %6
br label %44
36: ; preds = %2
%37 = load i32, i32* %4
%38 = call i32 @isxdigit(i32 %37)
store i32 %38, i32* %6
br label %44
39: ; preds = %2
%40 = load i32, i32* %5
%41 = load i32, i32* %4
%42 = icmp eq i32 %40, %41
%43 = zext i1 %42 to i32
store i32 %43, i32* %3
br label %57
44: ; preds = %36, %33, %30, %27, %24, %21, %18, %15, %12, %9
%45 = load i32, i32* %5
%46 = call i32 @islower(i32 %45)
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %44
%49 = load i32, i32* %6
br label %55
50: ; preds = %44
%51 = load i32, i32* %6
%52 = icmp ne i32 %51, 0
%53 = xor i1 %52, true
%54 = zext i1 %53 to i32
br label %55
55: ; preds = %50, %48
%56 = phi i32 [ %49, %48 ], [ %54, %50 ]
store i32 %56, i32* %3
br label %57
57: ; preds = %55, %39
%58 = load i32, i32* %3
ret i32 %58
}

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