#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 strlen(char const *);
int ValidSegName(const char *Name) {
  if ((*Name != '_' && !IsAlpha(*Name)) || strlen(Name) > 80) {
    return 0;
  }
  while (*++Name) {
    if (*Name != '_' && !IsAlNum(*Name)) {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<ValidSegName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     1161 <ValidSegName+0x31>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1050 <IsAlpha@plt>
cmp    $0x0,%eax
je     1173 <ValidSegName+0x43>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x50,%eax
jle    117f <ValidSegName+0x4f>
movl   $0x0,-0x4(%rbp)
jmp    11da <ValidSegName+0xaa>
jmp    1184 <ValidSegName+0x54>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
cmpb   $0x0,0x1(%rax)
je     11d3 <ValidSegName+0xa3>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     11ce <ValidSegName+0x9e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <IsAlNum@plt>
cmp    $0x0,%eax
jne    11ce <ValidSegName+0x9e>
movl   $0x0,-0x4(%rbp)
jmp    11da <ValidSegName+0xaa>
jmp    1184 <ValidSegName+0x54>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ValidSegName>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%al
cmp    $0x5f,%al
je     1148 <ValidSegName+0x18>
movsbl %al,%edi
call   1050 <IsAlpha@plt>
test   %eax,%eax
je     117d <ValidSegName+0x4d>
mov    %rbx,%rdi
call   1030 <strlen@plt>
xor    %ebp,%ebp
cmp    $0x50,%eax
jg     1186 <ValidSegName+0x56>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x5f,%al
je     1160 <ValidSegName+0x30>
test   %al,%al
je     1181 <ValidSegName+0x51>
movsbl %al,%edi
call   1040 <IsAlNum@plt>
test   %eax,%eax
jne    1160 <ValidSegName+0x30>
jmp    1186 <ValidSegName+0x56>
xor    %ebp,%ebp
jmp    1186 <ValidSegName+0x56>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @ValidSegName(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 95
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i32 @IsAlpha(i8 signext %2)
%6 = icmp eq i32 %5, 0
br i1 %6, label %18, label %7
7: ; preds = %4, %1
%8 = tail call i32 @strlen(i8* %0)
%9 = icmp sgt i32 %8, 80
br i1 %9, label %18, label %10
10: ; preds = %7, %14
%11 = phi i8* [ %12, %14 ], [ %0, %7 ]
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = load i8, i8* %12
switch i8 %13, label %15 [
i8 0, label %18
i8 95, label %14
]
14: ; preds = %10, %15
br label %10
15: ; preds = %10
%16 = tail call i32 @IsAlNum(i8 signext %13)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %14
18: ; preds = %10, %15, %4, %7
%19 = phi i32 [ 0, %7 ], [ 0, %4 ], [ 1, %10 ], [ 0, %15 ]
ret i32 %19
}