#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 */
typedef int wctype_t;

/* Variables and functions */
int /*<<< orphan*/ strcmp(char const *, char const *);
wctype_t wctype(const char *s) {
  int i;
  const char *p;
  static const char names[] = "alnum\0"
                              "alpha\0"
                              "blank\0"
                              "cntrl\0"
                              "digit\0"
                              "graph\0"
                              "lower\0"
                              "print\0"
                              "punct\0"
                              "space\0"
                              "upper\0"
                              "xdigit";
  for (i = 1, p = names; *p; i++, p += 6)
    if (*s == *p && !strcmp(s, p))
      return i;
  return 0;
}


x86 assembly (clang, -O0):
<wctype>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
lea    0xed6(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     1191 <wctype+0x81>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    -0x20(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    1172 <wctype+0x62>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1172 <wctype+0x62>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1198 <wctype+0x88>
jmp    1177 <wctype+0x67>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x20(%rbp)
jmp    112e <wctype+0x1e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wctype>:
push   %rbx
mov    (%rdi),%al
add    $0x9f,%al
cmp    $0x17,%al
ja     126e <wctype+0x15e>
mov    %rdi,%rbx
movzbl %al,%eax
lea    0xed6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf26(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1272 <wctype+0x162>
lea    0xf15(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
jne    126e <wctype+0x15e>
mov    $0x2,%eax
pop    %rbx
ret
lea    0xefd(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
jne    126e <wctype+0x15e>
mov    $0x3,%eax
pop    %rbx
ret
lea    0xee5(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
jne    126e <wctype+0x15e>
mov    $0x4,%eax
pop    %rbx
ret
lea    0xecd(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
jne    126e <wctype+0x15e>
mov    $0x5,%eax
pop    %rbx
ret
lea    0xeb5(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
jne    126e <wctype+0x15e>
mov    $0x6,%eax
pop    %rbx
ret
lea    0xe9d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
jne    126e <wctype+0x15e>
mov    $0x7,%eax
pop    %rbx
ret
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1279 <wctype+0x169>
lea    0xe7c(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
jne    126e <wctype+0x15e>
mov    $0x9,%eax
pop    %rbx
ret
lea    0xe68(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
jne    126e <wctype+0x15e>
mov    $0xa,%eax
pop    %rbx
ret
lea    0xe54(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
jne    126e <wctype+0x15e>
mov    $0xb,%eax
pop    %rbx
ret
lea    0xe40(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1280 <wctype+0x170>
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret
mov    $0x8,%eax
pop    %rbx
ret
mov    $0xc,%eax
pop    %rbx
ret

LLVM IR (-O0):
@wctype.names = internal constant [73 x i8] c"alnum\00alpha\00blank\00cntrl\00digit\00graph\00lower\00print\00punct\00space\00upper\00xdigit\00"
define i32 @wctype(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %3
store i32 1, i32* %4
store i8* getelementptr inbounds ([73 x i8], [73 x i8]* @wctype.names, i64 0, i64 0), i8** %5
br label %6
6: ; preds = %26, %1
%7 = load i8*, i8** %5
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 0
br i1 %9, label %10, label %31
10: ; preds = %6
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = load i8*, i8** %5
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %13, %16
br i1 %17, label %18, label %25
18: ; preds = %10
%19 = load i8*, i8** %3
%20 = load i8*, i8** %5
%21 = call i32 @strcmp(i8* %19, i8* %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %18
%24 = load i32, i32* %4
store i32 %24, i32* %2
br label %32
25: ; preds = %18, %10
br label %26
26: ; preds = %25
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
%29 = load i8*, i8** %5
%30 = getelementptr inbounds i8, i8* %29, i64 6
store i8* %30, i8** %5
br label %6
31: ; preds = %6
store i32 0, i32* %2
br label %32
32: ; preds = %31, %23
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
@wctype.names = internal constant [73 x i8] c"alnum\00alpha\00blank\00cntrl\00digit\00graph\00lower\00print\00punct\00space\00upper\00xdigit\00"
define i32 @wctype(i8* nocapture %0) {
%2 = load i8, i8* %0
switch i8 %2, label %39 [
i8 97, label %3
i8 98, label %9
i8 99, label %12
i8 100, label %15
i8 103, label %18
i8 108, label %21
i8 112, label %24
i8 115, label %30
i8 117, label %33
i8 120, label %36
]
3: ; preds = %1
%4 = tail call i32 @strcmp(i8* %0, i8* dereferenceable(6) getelementptr inbounds ([73 x i8], [73 x i8]* @wctype.names, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br i1 %5, label %40, label %6
6: ; preds = %3
%7 = tail call i32 @strcmp(i8* %0, i8* dereferenceable(6) getelementptr inbounds ([73 x i8], [73 x i8]* @wctype.names, i64 0, i64 6))
%8 = icmp eq i32 %7, 0
br i1 %8, label %40, label %39
9: ; preds = %1
%10 = tail call i32 @strcmp(i8* %0, i8* dereferenceable(6) getelementptr inbounds ([73 x i8], [73 x i8]* @wctype.names, i64 0, i64 12))
%11 = icmp eq i32 %10, 0
br i1 %11, label %40, label %39
12: ; preds = %1
%13 = tail call i32 @strcmp(i8* %0, i8* dereferenceable(6) getelementptr inbounds ([73 x i8], [73 x i8]* @wctype.names, i64 0, i64 18))
%14 = icmp eq i32 %13, 0
br i1 %14, label %40, label %39
15: ; preds = %1
%16 = tail call i32 @strcmp(i8* %0, i8* dereferenceable(6) getelementptr inbounds ([73 x i8], [73 x i8]* @wctype.names, i64 0, i64 24))
%17 = icmp eq i32 %16, 0
br i1 %17, label %40, label %39
18: ; preds = %1
%19 = tail call i32 @strcmp(i8* %0, i8* dereferenceable(6) getelementptr inbounds ([73 x i8], [73 x i8]* @wctype.names, i64 0, i64 30))
%20 = icmp eq i32 %19, 0
br i1 %20, label %40, label %39
21: ; preds = %1
%22 = tail call i32 @strcmp(i8* %0, i8* dereferenceable(6) getelementptr inbounds ([73 x i8], [73 x i8]* @wctype.names, i64 0, i64 36))
%23 = icmp eq i32 %22, 0
br i1 %23, label %40, label %39
24: ; preds = %1
%25 = tail call i32 @strcmp(i8* %0, i8* dereferenceable(6) getelementptr inbounds ([73 x i8], [73 x i8]* @wctype.names, i64 0, i64 42))
%26 = icmp eq i32 %25, 0
br i1 %26, label %40, label %27
27: ; preds = %24
%28 = tail call i32 @strcmp(i8* %0, i8* dereferenceable(6) getelementptr inbounds ([73 x i8], [73 x i8]* @wctype.names, i64 0, i64 48))
%29 = icmp eq i32 %28, 0
br i1 %29, label %40, label %39
30: ; preds = %1
%31 = tail call i32 @strcmp(i8* %0, i8* dereferenceable(6) getelementptr inbounds ([73 x i8], [73 x i8]* @wctype.names, i64 0, i64 54))
%32 = icmp eq i32 %31, 0
br i1 %32, label %40, label %39
33: ; preds = %1
%34 = tail call i32 @strcmp(i8* %0, i8* dereferenceable(6) getelementptr inbounds ([73 x i8], [73 x i8]* @wctype.names, i64 0, i64 60))
%35 = icmp eq i32 %34, 0
br i1 %35, label %40, label %39
36: ; preds = %1
%37 = tail call i32 @strcmp(i8* %0, i8* dereferenceable(7) getelementptr inbounds ([73 x i8], [73 x i8]* @wctype.names, i64 0, i64 66))
%38 = icmp eq i32 %37, 0
br i1 %38, label %40, label %39
39: ; preds = %1, %6, %9, %12, %15, %18, %27, %21, %30, %33, %36
br label %40
40: ; preds = %39, %36, %33, %30, %27, %24, %21, %18, %15, %12, %9, %6, %3
%41 = phi i32 [ 1, %3 ], [ 2, %6 ], [ 3, %9 ], [ 4, %12 ], [ 5, %15 ], [ 6, %18 ], [ 7, %21 ], [ 8, %24 ], [ 9, %27 ], [ 10, %30 ], [ 11, %33 ], [ 12, %36 ], [ 0, %39 ]
ret i32 %41
}