#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 const);
int /*<<< orphan*/ isalpha(char const);
int S_validate_identifier(const char *identifier) {
  const char *ptr = identifier;
  if (!isalpha(*ptr) && *ptr != '_') {
    return 0;
  }
  for (; *ptr != 0; ptr++) {
    if (!isalnum(*ptr) && *ptr != '_') {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<S_validate_identifier>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%eax
jne    1165 <S_validate_identifier+0x45>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     1165 <S_validate_identifier+0x45>
movl   $0x0,-0x4(%rbp)
jmp    11c8 <S_validate_identifier+0xa8>
jmp    116a <S_validate_identifier+0x4a>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11c1 <S_validate_identifier+0xa1>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%eax
jne    11ab <S_validate_identifier+0x8b>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     11ab <S_validate_identifier+0x8b>
movl   $0x0,-0x4(%rbp)
jmp    11c8 <S_validate_identifier+0xa8>
jmp    11b0 <S_validate_identifier+0x90>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    116a <S_validate_identifier+0x4a>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<S_validate_identifier>:
push   %rbx
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1040 <isalpha@plt>
mov    (%rbx),%cl
test   %eax,%eax
je     113d <S_validate_identifier+0x1d>
test   %cl,%cl
jne    1146 <S_validate_identifier+0x26>
mov    $0x1,%eax
pop    %rbx
ret
xor    %eax,%eax
cmp    $0x5f,%cl
mov    $0x5f,%cl
jne    113b <S_validate_identifier+0x1b>
add    $0x1,%rbx
jmp    115b <S_validate_identifier+0x3b>
nopl   0x0(%rax)
movzbl (%rbx),%ecx
add    $0x1,%rbx
test   %cl,%cl
je     1136 <S_validate_identifier+0x16>
movsbl %cl,%edi
call   1030 <isalnum@plt>
test   %eax,%eax
jne    1150 <S_validate_identifier+0x30>
cmpb   $0x5f,-0x1(%rbx)
je     1150 <S_validate_identifier+0x30>
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @S_validate_identifier(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = tail call i32 @isalpha(i8 signext %2)
%4 = icmp eq i32 %3, 0
%5 = load i8, i8* %0
br i1 %4, label %6, label %8
6: ; preds = %1
%7 = icmp eq i8 %5, 95
br i1 %7, label %10, label %24
8: ; preds = %1
%9 = icmp eq i8 %5, 0
br i1 %9, label %24, label %10
10: ; preds = %6, %8
%11 = phi i8 [ 95, %6 ], [ %5, %8 ]
br label %12
12: ; preds = %10, %20
%13 = phi i8 [ %22, %20 ], [ %11, %10 ]
%14 = phi i8* [ %21, %20 ], [ %0, %10 ]
%15 = tail call i32 @isalnum(i8 signext %13)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load i8, i8* %14
%19 = icmp eq i8 %18, 95
br i1 %19, label %20, label %24
20: ; preds = %12, %17
%21 = getelementptr inbounds i8, i8* %14, i64 1
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %24, label %12
24: ; preds = %17, %20, %8, %6
%25 = phi i32 [ 0, %6 ], [ 1, %8 ], [ 0, %17 ], [ 1, %20 ]
ret i32 %25
}