#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*/ isalpha(char);
int /*<<< orphan*/ isdigit(char);
int is_object_name(char *name, int len) {
  char p = name[0];
  if (!isalpha(p) && p != '_')
    return 0;
  int i = 0;
  while (i < len) {
    if (!isalpha(p) && !isdigit(p) && p != '_')
      return 0;
    i++;
    p = name[i];
  }
  return 1;
}


x86 assembly (clang, -O0):
<is_object_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x15(%rbp)
movsbl -0x15(%rbp),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%eax
jne    1163 <is_object_name+0x43>
movsbl -0x15(%rbp),%eax
cmp    $0x5f,%eax
je     1163 <is_object_name+0x43>
movl   $0x0,-0x4(%rbp)
jmp    11d6 <is_object_name+0xb6>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11cf <is_object_name+0xaf>
movsbl -0x15(%rbp),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%eax
jne    11b3 <is_object_name+0x93>
movsbl -0x15(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11b3 <is_object_name+0x93>
movsbl -0x15(%rbp),%eax
cmp    $0x5f,%eax
je     11b3 <is_object_name+0x93>
movl   $0x0,-0x4(%rbp)
jmp    11d6 <is_object_name+0xb6>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x15(%rbp)
jmp    116a <is_object_name+0x4a>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_object_name>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %rdi,%r12
movsbl (%rdi),%r13d
mov    %r13d,%edi
call   1040 <isalpha@plt>
cmp    $0x5f,%r13d
je     114a <is_object_name+0x2a>
xor    %r14d,%r14d
test   %eax,%eax
je     1192 <is_object_name+0x72>
mov    $0x1,%r14d
test   %r15d,%r15d
jle    1192 <is_object_name+0x72>
mov    %r15d,%r15d
xor    %ebp,%ebp
jmp    116f <is_object_name+0x4f>
nopl   0x0(%rax)
movzbl 0x1(%r12,%rbp,1),%r13d
add    $0x1,%rbp
cmp    %rbp,%r15
je     1192 <is_object_name+0x72>
movsbl %r13b,%ebx
mov    %ebx,%edi
call   1040 <isalpha@plt>
test   %eax,%eax
jne    1160 <is_object_name+0x40>
mov    %ebx,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
jne    1160 <is_object_name+0x40>
cmp    $0x5f,%r13b
je     1160 <is_object_name+0x40>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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