#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*/ CFCUtil_isdigit(char);
int /*<<< orphan*/ CFCUtil_islower(char);
size_t strlen(char const *);
int S_validate_function_name(const char *name) {
  size_t len = strlen(name);
  if (!len) {
    return 0;
  }
  for (size_t i = 0; i < len; i++) {
    char c = name[i];
    if (!CFCUtil_islower(c) && !CFCUtil_isdigit(c) && c != '_') {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<S_validate_function_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1160 <S_validate_function_name+0x30>
movl   $0x0,-0x4(%rbp)
jmp    11de <S_validate_function_name+0xae>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11d7 <S_validate_function_name+0xa7>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x21(%rbp)
movsbl -0x21(%rbp),%edi
call   1050 <CFCUtil_islower@plt>
cmp    $0x0,%eax
jne    11c1 <S_validate_function_name+0x91>
movsbl -0x21(%rbp),%edi
call   1040 <CFCUtil_isdigit@plt>
cmp    $0x0,%eax
jne    11c1 <S_validate_function_name+0x91>
movsbl -0x21(%rbp),%eax
cmp    $0x5f,%eax
je     11c1 <S_validate_function_name+0x91>
movl   $0x0,-0x4(%rbp)
jmp    11de <S_validate_function_name+0xae>
jmp    11c6 <S_validate_function_name+0x96>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1168 <S_validate_function_name+0x38>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<S_validate_function_name>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <strlen@plt>
test   %rax,%rax
je     11aa <S_validate_function_name+0x7a>
mov    %rax,%r15
mov    %rax,%r12
neg    %r12
mov    $0x1,%r13b
mov    $0x1,%ebx
jmp    1179 <S_validate_function_name+0x49>
nopl   0x0(%rax,%rax,1)
cmp    %r15,%rbx
setb   %r13b
lea    (%r12,%rbx,1),%rax
add    $0x1,%rax
add    $0x1,%rbx
cmp    $0x1,%rax
je     119e <S_validate_function_name+0x6e>
movzbl -0x1(%r14,%rbx,1),%eax
movsbl %al,%ebp
mov    %ebp,%edi
call   1050 <CFCUtil_islower@plt>
test   %eax,%eax
jne    1160 <S_validate_function_name+0x30>
mov    %ebp,%edi
call   1040 <CFCUtil_isdigit@plt>
cmp    $0x5f,%bpl
je     1160 <S_validate_function_name+0x30>
test   %eax,%eax
jne    1160 <S_validate_function_name+0x30>
not    %r13b
movzbl %r13b,%eax
and    $0x1,%eax
jmp    11ac <S_validate_function_name+0x7c>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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