#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);
unsigned char is_valid_tag(const char *tagname) {
  if (!isalpha(*tagname))
    return 0;
  for (++tagname; *tagname; ++tagname)
    if (!isalnum(*tagname) && *tagname != '_')
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<is_valid_tag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%eax
jne    114a <is_valid_tag+0x2a>
movb   $0x0,-0x1(%rbp)
jmp    11ab <is_valid_tag+0x8b>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11a7 <is_valid_tag+0x87>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%eax
jne    1191 <is_valid_tag+0x71>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     1191 <is_valid_tag+0x71>
movb   $0x0,-0x1(%rbp)
jmp    11ab <is_valid_tag+0x8b>
jmp    1196 <is_valid_tag+0x76>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1156 <is_valid_tag+0x36>
movb   $0x1,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_valid_tag>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1040 <isalpha@plt>
test   %eax,%eax
je     116d <is_valid_tag+0x4d>
mov    0x1(%rbx),%al
mov    $0x1,%bpl
test   %al,%al
je     116f <is_valid_tag+0x4f>
add    $0x2,%rbx
jmp    115b <is_valid_tag+0x3b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     116f <is_valid_tag+0x4f>
movsbl %al,%edi
call   1030 <isalnum@plt>
test   %eax,%eax
jne    1150 <is_valid_tag+0x30>
cmpb   $0x5f,-0x1(%rbx)
je     1150 <is_valid_tag+0x30>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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