#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);
bool isName(const char *s, size_t length) {
  if (!isalpha(s[0]) && s[0] != '_')
    return false;
  for (size_t i = 1; i < length; i++) {
    if (!isalnum(s[i]) && s[i] != '_')
      return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<isName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%eax
jne    1161 <isName+0x41>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     1161 <isName+0x41>
movl   $0x0,-0x4(%rbp)
jmp    11cf <isName+0xaf>
movq   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11c8 <isName+0xa8>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%eax
jne    11b2 <isName+0x92>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5f,%eax
je     11b2 <isName+0x92>
movl   $0x0,-0x4(%rbp)
jmp    11cf <isName+0xaf>
jmp    11b7 <isName+0x97>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1169 <isName+0x49>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isName>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
movsbl (%rdi),%edi
call   1040 <isalpha@plt>
test   %eax,%eax
jne    1143 <isName+0x23>
xor    %eax,%eax
cmpb   $0x5f,(%r12)
jne    119e <isName+0x7e>
cmp    $0x2,%r14
jb     1192 <isName+0x72>
mov    $0x1,%r15d
sub    %r14,%r15
mov    $0x1,%bpl
mov    $0x2,%ebx
jmp    1179 <isName+0x59>
nopl   0x0(%rax)
cmp    %r14,%rbx
setb   %bpl
lea    (%r15,%rbx,1),%rax
add    $0x1,%rax
add    $0x1,%rbx
cmp    $0x2,%rax
je     1194 <isName+0x74>
movsbl -0x1(%r12,%rbx,1),%edi
call   1030 <isalnum@plt>
test   %eax,%eax
jne    1160 <isName+0x40>
cmpb   $0x5f,-0x1(%r12,%rbx,1)
je     1160 <isName+0x40>
jmp    1194 <isName+0x74>
xor    %ebp,%ebp
not    %bpl
movzbl %bpl,%eax
and    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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