#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*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ isalnum(char);
int abac_clean_name(char *string) {
  int i;
  assert(string != NULL);
  if (!isalnum(string[0]))
    return 0;
  for (i = 1; string[i] != '\0'; ++i)
    if (!isalnum(string[i]) && string[i] != '-' && string[i] != '_' &&
        string[i] != ':')
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<abac_clean_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%eax
jne    115f <abac_clean_name+0x3f>
movl   $0x0,-0x4(%rbp)
jmp    11fa <abac_clean_name+0xda>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11f3 <abac_clean_name+0xd3>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%eax
jne    11e0 <abac_clean_name+0xc0>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2d,%eax
je     11e0 <abac_clean_name+0xc0>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5f,%eax
je     11e0 <abac_clean_name+0xc0>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3a,%eax
je     11e0 <abac_clean_name+0xc0>
movl   $0x0,-0x4(%rbp)
jmp    11fa <abac_clean_name+0xda>
jmp    11e5 <abac_clean_name+0xc5>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1166 <abac_clean_name+0x46>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<abac_clean_name>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1040 <assert@plt>
movsbl (%rbx),%edi
call   1030 <isalnum@plt>
xor    %r14d,%r14d
test   %eax,%eax
je     1192 <abac_clean_name+0x72>
mov    0x1(%rbx),%al
test   %al,%al
je     118c <abac_clean_name+0x6c>
add    $0x2,%rbx
movabs $0x4000000002001,%rbp
jmp    116b <abac_clean_name+0x4b>
nopl   0x0(%rax,%rax,1)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     118c <abac_clean_name+0x6c>
movsbl %al,%edi
call   1030 <isalnum@plt>
test   %eax,%eax
jne    1160 <abac_clean_name+0x40>
movzbl -0x1(%rbx),%eax
add    $0xd3,%al
cmp    $0x32,%al
ja     1192 <abac_clean_name+0x72>
movzbl %al,%eax
bt     %rax,%rbp
jb     1160 <abac_clean_name+0x40>
jmp    1192 <abac_clean_name+0x72>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @abac_clean_name(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = call i32 @isalnum(i8 signext %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %1
store i32 0, i32* %2
br label %62
15: ; preds = %1
store i32 1, i32* %4
br label %16
16: ; preds = %58, %15
%17 = load i8*, i8** %3
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %61
24: ; preds = %16
%25 = load i8*, i8** %3
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = call i32 @isalnum(i8 signext %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %57, label %32
32: ; preds = %24
%33 = load i8*, i8** %3
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 45
br i1 %39, label %40, label %57
40: ; preds = %32
%41 = load i8*, i8** %3
%42 = load i32, i32* %4
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp ne i32 %46, 95
br i1 %47, label %48, label %57
48: ; preds = %40
%49 = load i8*, i8** %3
%50 = load i32, i32* %4
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %49, i64 %51
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp ne i32 %54, 58
br i1 %55, label %56, label %57
56: ; preds = %48
store i32 0, i32* %2
br label %62
57: ; preds = %48, %40, %32, %24
br label %58
58: ; preds = %57
%59 = load i32, i32* %4
%60 = add nsw i32 %59, 1
store i32 %60, i32* %4
br label %16
61: ; preds = %16
store i32 1, i32* %2
br label %62
62: ; preds = %61, %56, %14
%63 = load i32, i32* %2
ret i32 %63
}

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