#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*/ isalnum(char);
int strlen(char *);
int test_ID(char *id) {
  int len;
  len = strlen(id);
  if ((len < 1) || (len > 2))
    return 1;
  for (; len > 0; len--) {
    if (!isalnum(id[len - 1]) && (id[len - 1] != '_'))
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<test_ID>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jl     114c <test_ID+0x2c>
cmpl   $0x2,-0x14(%rbp)
jle    1158 <test_ID+0x38>
movl   $0x1,-0x4(%rbp)
jmp    11c6 <test_ID+0xa6>
jmp    115d <test_ID+0x3d>
cmpl   $0x0,-0x14(%rbp)
jle    11bf <test_ID+0x9f>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isalnum@plt>
cmp    $0x0,%eax
jne    11ac <test_ID+0x8c>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5f,%eax
je     11ac <test_ID+0x8c>
movl   $0x1,-0x4(%rbp)
jmp    11c6 <test_ID+0xa6>
jmp    11b1 <test_ID+0x91>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    115d <test_ID+0x3d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_ID>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
call   1030 <strlen@plt>
lea    -0x3(%rax),%ecx
mov    $0x1,%r14d
cmp    $0xfffffffe,%ecx
jb     1177 <test_ID+0x57>
mov    %eax,%ebp
add    $0x1,%rbp
jmp    115a <test_ID+0x3a>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0xffffffffffffffff,%rbp
cmp    $0x1,%rbp
jbe    1174 <test_ID+0x54>
lea    -0x2(%rbp),%ebx
movsbl (%r15,%rbx,1),%edi
call   1040 <isalnum@plt>
test   %eax,%eax
jne    1150 <test_ID+0x30>
cmpb   $0x5f,(%r15,%rbx,1)
je     1150 <test_ID+0x30>
jmp    1177 <test_ID+0x57>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @test_ID(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strlen(i8* %5)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 1
br i1 %8, label %12, label %9
9: ; preds = %1
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 2
br i1 %11, label %12, label %13
12: ; preds = %9, %1
store i32 1, i32* %2
br label %41
13: ; preds = %9
br label %14
14: ; preds = %37, %13
%15 = load i32, i32* %4
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %40
17: ; preds = %14
%18 = load i8*, i8** %3
%19 = load i32, i32* %4
%20 = sub nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %18, i64 %21
%23 = load i8, i8* %22
%24 = call i32 @isalnum(i8 signext %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %36, label %26
26: ; preds = %17
%27 = load i8*, i8** %3
%28 = load i32, i32* %4
%29 = sub nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %27, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 95
br i1 %34, label %35, label %36
35: ; preds = %26
store i32 1, i32* %2
br label %41
36: ; preds = %26, %17
br label %37
37: ; preds = %36
%38 = load i32, i32* %4
%39 = add nsw i32 %38, -1
store i32 %39, i32* %4
br label %14
40: ; preds = %14
store i32 0, i32* %2
br label %41
41: ; preds = %40, %35, %12
%42 = load i32, i32* %2
ret i32 %42
}

LLVM IR (-O2):
define i32 @test_ID(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add i32 %2, -3
%4 = icmp ult i32 %3, -2
br i1 %4, label %20, label %5
5: ; preds = %1
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %18
%8 = phi i64 [ %6, %5 ], [ %9, %18 ]
%9 = add nsw i64 %8, -1
%10 = and i64 %9, 4294967295
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = tail call i32 @isalnum(i8 signext %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %7
%16 = load i8, i8* %11
%17 = icmp eq i8 %16, 95
br i1 %17, label %18, label %20
18: ; preds = %7, %15
%19 = icmp ugt i64 %8, 1
br i1 %19, label %7, label %20
20: ; preds = %15, %18, %1
%21 = phi i32 [ 1, %1 ], [ 1, %15 ], [ 0, %18 ]
ret i32 %21
}