#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(int);
int strlen(char *);
int es_name(char *name) {
  int len = strlen(name);
  int i;
  for (i = 0; i < len; i++) {
    int n = name[i];
    if (!isalnum(n) && n != 32 && n != 45 && n != 95 && n != 46)
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<es_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b2 <es_name+0x92>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1040 <isalnum@plt>
cmp    $0x0,%eax
jne    119f <es_name+0x7f>
cmpl   $0x20,-0x1c(%rbp)
je     119f <es_name+0x7f>
cmpl   $0x2d,-0x1c(%rbp)
je     119f <es_name+0x7f>
cmpl   $0x5f,-0x1c(%rbp)
je     119f <es_name+0x7f>
cmpl   $0x2e,-0x1c(%rbp)
je     119f <es_name+0x7f>
movl   $0x0,-0x4(%rbp)
jmp    11b9 <es_name+0x99>
jmp    11a4 <es_name+0x84>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113f <es_name+0x1f>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<es_name>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
test   %eax,%eax
jle    1183 <es_name+0x63>
mov    %eax,%r15d
xor    %ebx,%ebx
movabs $0x8000000000006001,%r12
jmp    1159 <es_name+0x39>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbx
cmp    %rbx,%r15
je     1183 <es_name+0x63>
movzbl (%r14,%rbx,1),%ebp
movsbl %bpl,%edi
call   1040 <isalnum@plt>
test   %eax,%eax
jne    1150 <es_name+0x30>
xor    %eax,%eax
add    $0xe0,%bpl
cmp    $0x3f,%bpl
ja     1188 <es_name+0x68>
movzbl %bpl,%ecx
bt     %rcx,%r12
jb     1150 <es_name+0x30>
jmp    1188 <es_name+0x68>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @es_name(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %18
4: ; preds = %1
%5 = zext i32 %2 to i64
br label %6
6: ; preds = %4, %15
%7 = phi i64 [ 0, %4 ], [ %16, %15 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = tail call i32 @isalnum(i32 %10)
%12 = freeze i32 %11
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %6
switch i8 %9, label %18 [
i8 95, label %15
i8 46, label %15
i8 45, label %15
i8 32, label %15
]
15: ; preds = %14, %14, %14, %14, %6
%16 = add nuw nsw i64 %7, 1
%17 = icmp eq i64 %16, %5
br i1 %17, label %18, label %6
18: ; preds = %14, %15, %1
%19 = phi i32 [ 1, %1 ], [ 1, %15 ], [ 0, %14 ]
ret i32 %19
}