#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 /*<<< orphan*/ isalpha(char);
int /*<<< orphan*/ isdigit(char);
int /*<<< orphan*/ ispunct(char);
int loop(char a, int x) {
  switch (x) {
  case 1:
    if ((isdigit(a) || isalpha(a) || ispunct(a)) && (a != '(' && a != ')')) {
      return 1;
    }
    break;
  case 2:
    if (isalpha(a))
      return 1;
    break;
  case 3:
    if (isalpha(a) || isdigit(a))
      return 1;
    break;
  case 4:
    if (isdigit(a))
      return 1;
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<loop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     1246 <loop+0x116>
mov    -0x18(%rbp),%rax
lea    0xe9f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsbl -0x5(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11a0 <loop+0x70>
movsbl -0x5(%rbp),%edi
call   1050 <isalpha@plt>
cmp    $0x0,%eax
jne    11a0 <loop+0x70>
movsbl -0x5(%rbp),%edi
call   1040 <ispunct@plt>
cmp    $0x0,%eax
je     11c6 <loop+0x96>
movsbl -0x5(%rbp),%eax
cmp    $0x28,%eax
je     11c6 <loop+0x96>
movsbl -0x5(%rbp),%eax
cmp    $0x29,%eax
je     11c6 <loop+0x96>
movl   $0x1,-0x4(%rbp)
jmp    124d <loop+0x11d>
jmp    1246 <loop+0x116>
movsbl -0x5(%rbp),%edi
call   1050 <isalpha@plt>
cmp    $0x0,%eax
je     11e9 <loop+0xb9>
movl   $0x1,-0x4(%rbp)
jmp    124d <loop+0x11d>
jmp    1246 <loop+0x116>
movsbl -0x5(%rbp),%edi
call   1050 <isalpha@plt>
cmp    $0x0,%eax
jne    1212 <loop+0xe2>
movsbl -0x5(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
je     121e <loop+0xee>
movl   $0x1,-0x4(%rbp)
jmp    124d <loop+0x11d>
jmp    1246 <loop+0x116>
movsbl -0x5(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
je     1241 <loop+0x111>
movl   $0x1,-0x4(%rbp)
jmp    124d <loop+0x11d>
jmp    1246 <loop+0x116>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loop>:
push   %rbp
push   %rbx
push   %rax
add    $0xffffffff,%esi
cmp    $0x3,%esi
ja     11b0 <loop+0x80>
mov    %edi,%ebx
lea    0xebc(%rip),%rax
movslq (%rax,%rsi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
movsbl %bl,%ebp
mov    %ebp,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
jne    1166 <loop+0x36>
mov    %ebp,%edi
call   1050 <isalpha@plt>
test   %eax,%eax
je     11bb <loop+0x8b>
and    $0xfe,%bl
mov    $0x1,%ebp
cmp    $0x28,%bl
je     11b0 <loop+0x80>
jmp    11b2 <loop+0x82>
movsbl %bl,%edi
call   1050 <isalpha@plt>
jmp    11a7 <loop+0x77>
movsbl %bl,%ebx
mov    %ebx,%edi
call   1050 <isalpha@plt>
mov    $0x1,%ebp
test   %eax,%eax
jne    11b2 <loop+0x82>
mov    %ebx,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
jne    11b2 <loop+0x82>
jmp    11b0 <loop+0x80>
movsbl %bl,%edi
call   1030 <isdigit@plt>
mov    $0x1,%ebp
test   %eax,%eax
jne    11b2 <loop+0x82>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %ebp,%edi
call   1040 <ispunct@plt>
and    $0xfe,%bl
cmp    $0x28,%bl
jne    11a7 <loop+0x77>
jmp    11b0 <loop+0x80>

LLVM IR (-O0):
define i32 @loop(i8 signext %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32
store i8 %0, i8* %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
switch i32 %6, label %51 [
i32 1, label %7
i32 2, label %29
i32 3, label %35
i32 4, label %45
]
7: ; preds = %2
%8 = load i8, i8* %4
%9 = call i32 @isdigit(i8 signext %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %19, label %11
11: ; preds = %7
%12 = load i8, i8* %4
%13 = call i32 @isalpha(i8 signext %12)
%14 = icmp ne i32 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %11
%16 = load i8, i8* %4
%17 = call i32 @ispunct(i8 signext %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %28
19: ; preds = %15, %11, %7
%20 = load i8, i8* %4
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 40
br i1 %22, label %23, label %28
23: ; preds = %19
%24 = load i8, i8* %4
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 41
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 1, i32* %3
br label %52
28: ; preds = %23, %19, %15
br label %51
29: ; preds = %2
%30 = load i8, i8* %4
%31 = call i32 @isalpha(i8 signext %30)
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %29
store i32 1, i32* %3
br label %52
34: ; preds = %29
br label %51
35: ; preds = %2
%36 = load i8, i8* %4
%37 = call i32 @isalpha(i8 signext %36)
%38 = icmp ne i32 %37, 0
br i1 %38, label %43, label %39
39: ; preds = %35
%40 = load i8, i8* %4
%41 = call i32 @isdigit(i8 signext %40)
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %39, %35
store i32 1, i32* %3
br label %52
44: ; preds = %39
br label %51
45: ; preds = %2
%46 = load i8, i8* %4
%47 = call i32 @isdigit(i8 signext %46)
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %45
store i32 1, i32* %3
br label %52
50: ; preds = %45
br label %51
51: ; preds = %2, %50, %44, %34, %28
store i32 0, i32* %3
br label %52
52: ; preds = %51, %49, %43, %33, %27
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
define i32 @loop(i8 signext %0, i32 %1) {
switch i32 %1, label %30 [
i32 1, label %3
i32 2, label %18
i32 3, label %21
i32 4, label %27
]
3: ; preds = %2
%4 = tail call i32 @isdigit(i8 signext %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %3
%7 = tail call i32 @isalpha(i8 signext %0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %6
%10 = tail call i32 @ispunct(i8 signext %0)
%11 = icmp eq i32 %10, 0
%12 = and i8 %0, -2
%13 = icmp eq i8 %12, 40
%14 = or i1 %13, %11
br i1 %14, label %30, label %31
15: ; preds = %6, %3
%16 = and i8 %0, -2
%17 = icmp eq i8 %16, 40
br i1 %17, label %30, label %31
18: ; preds = %2
%19 = tail call i32 @isalpha(i8 signext %0)
%20 = icmp eq i32 %19, 0
br i1 %20, label %30, label %31
21: ; preds = %2
%22 = tail call i32 @isalpha(i8 signext %0)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %31
24: ; preds = %21
%25 = tail call i32 @isdigit(i8 signext %0)
%26 = icmp eq i32 %25, 0
br i1 %26, label %30, label %31
27: ; preds = %2
%28 = tail call i32 @isdigit(i8 signext %0)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %15, %27, %24, %18, %9, %2
br label %31
31: ; preds = %15, %27, %21, %24, %18, %9, %30
%32 = phi i32 [ 0, %30 ], [ 1, %9 ], [ 1, %15 ], [ 1, %18 ], [ 1, %24 ], [ 1, %21 ], [ 1, %27 ]
ret i32 %32
}