#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 */
scalar_t__ isalnum(char const);
int /*<<< orphan*/ isalpha(char const);
int /*<<< orphan*/ strchr(char *, char const);
int ok_attr_name(const char *attrname) {
  const char *scan;
  if (!isalpha(*attrname) && (*attrname != '_')) {
    return 0;
  }
  for (scan = attrname; *scan; scan++) {
    if (isalnum(*scan)) {
      continue;
    }
    if (!strchr("'?!`/-_.@#$^&~=+<>()%", *scan)) {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<ok_attr_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isalpha@plt>
cmp    $0x0,%eax
jne    116d <ok_attr_name+0x3d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     116d <ok_attr_name+0x3d>
movl   $0x0,-0x4(%rbp)
jmp    11e2 <ok_attr_name+0xb2>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     11db <ok_attr_name+0xab>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isalnum@plt>
cmp    $0x0,%rax
je     119d <ok_attr_name+0x6d>
jmp    11ca <ok_attr_name+0x9a>
mov    -0x18(%rbp),%rax
lea    0xe58(%rip),%rdi
movsbl (%rax),%esi
call   1030 <strchr@plt>
cmp    $0x0,%eax
jne    11c5 <ok_attr_name+0x95>
movl   $0x0,-0x4(%rbp)
jmp    11e2 <ok_attr_name+0xb2>
jmp    11ca <ok_attr_name+0x9a>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1175 <ok_attr_name+0x45>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ok_attr_name>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1050 <isalpha@plt>
mov    (%rbx),%cl
test   %eax,%eax
je     1150 <ok_attr_name+0x20>
test   %cl,%cl
jne    1159 <ok_attr_name+0x29>
mov    $0x1,%eax
jmp    119a <ok_attr_name+0x6a>
xor    %eax,%eax
cmp    $0x5f,%cl
mov    $0x5f,%cl
jne    119a <ok_attr_name+0x6a>
add    $0x1,%rbx
lea    0xe9c(%rip),%r14
jmp    117b <ok_attr_name+0x4b>
cs nopw 0x0(%rax,%rax,1)
movzbl (%rbx),%ecx
add    $0x1,%rbx
test   %cl,%cl
je     1149 <ok_attr_name+0x19>
movsbl %cl,%edi
call   1040 <isalnum@plt>
test   %rax,%rax
jne    1170 <ok_attr_name+0x40>
movsbl -0x1(%rbx),%esi
mov    %r14,%rdi
call   1030 <strchr@plt>
test   %eax,%eax
jne    1170 <ok_attr_name+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [22 x i8] c"'?!`/-_.@#$^&~=+<>()%\00"
define i32 @ok_attr_name(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = load i8, i8* %5
%7 = call i32 @isalpha(i8 signext %6)
%8 = icmp ne i32 %7, 0
br i1 %8, label %15, label %9
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 95
br i1 %13, label %14, label %15
14: ; preds = %9
store i32 0, i32* %2
br label %38
15: ; preds = %9, %1
%16 = load i8*, i8** %3
store i8* %16, i8** %4
br label %17
17: ; preds = %34, %15
%18 = load i8*, i8** %4
%19 = load i8, i8* %18
%20 = icmp ne i8 %19, 0
br i1 %20, label %21, label %37
21: ; preds = %17
%22 = load i8*, i8** %4
%23 = load i8, i8* %22
%24 = call i64 @isalnum(i8 signext %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %21
br label %34
27: ; preds = %21
%28 = load i8*, i8** %4
%29 = load i8, i8* %28
%30 = call i32 @strchr(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8 signext %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %33, label %32
32: ; preds = %27
store i32 0, i32* %2
br label %38
33: ; preds = %27
br label %34
34: ; preds = %33, %26
%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, %14
%39 = load i32, i32* %2
ret i32 %39
}

LLVM IR (-O2):
@.str = [22 x i8] c"'?!`/-_.@#$^&~=+<>()%\00"
define i32 @ok_attr_name(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 %25
8: ; preds = %1
%9 = icmp eq i8 %5, 0
br i1 %9, label %25, label %10
10: ; preds = %6, %8
%11 = phi i8 [ 95, %6 ], [ %5, %8 ]
br label %12
12: ; preds = %10, %21
%13 = phi i8 [ %23, %21 ], [ %11, %10 ]
%14 = phi i8* [ %22, %21 ], [ %0, %10 ]
%15 = tail call i64 @isalnum(i8 signext %13)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = load i8, i8* %14
%19 = tail call i32 @strchr(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8 signext %18)
%20 = icmp eq i32 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %17, %12
%22 = getelementptr inbounds i8, i8* %14, i64 1
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %12
25: ; preds = %17, %21, %8, %6
%26 = phi i32 [ 0, %6 ], [ 1, %8 ], [ 0, %17 ], [ 1, %21 ]
ret i32 %26
}