#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);
scalar_t__ tolower(char);
void RegulateName(char *name) {
  char *ptr;
  for (ptr = name; *ptr != '\0'; ptr++) {
    if (!isalnum(*ptr) && (*ptr != '.') && (*ptr != '-'))
      *ptr = '_';
    else
      *ptr = (char)tolower(*ptr);
  }
}


x86 assembly (clang, -O0):
<RegulateName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11af <RegulateName+0x8f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%eax
jne    1185 <RegulateName+0x65>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
je     1185 <RegulateName+0x65>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     1185 <RegulateName+0x65>
mov    -0x10(%rbp),%rax
movb   $0x5f,(%rax)
jmp    1199 <RegulateName+0x79>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <tolower@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
jmp    119e <RegulateName+0x7e>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1134 <RegulateName+0x14>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RegulateName>:
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     1161 <RegulateName+0x41>
mov    %rdi,%rbx
jmp    1146 <RegulateName+0x26>
nopl   0x0(%rax)
movsbl %cl,%edi
call   1040 <tolower@plt>
mov    %al,(%rbx)
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1161 <RegulateName+0x41>
movsbl %al,%edi
call   1030 <isalnum@plt>
movzbl (%rbx),%ecx
test   %eax,%eax
jne    1130 <RegulateName+0x10>
lea    -0x2d(%rcx),%edx
mov    $0x5f,%al
cmp    $0x1,%dl
ja     1138 <RegulateName+0x18>
jmp    1130 <RegulateName+0x10>
pop    %rbx
ret

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

LLVM IR (-O2):
define void @RegulateName(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %21, label %4
4: ; preds = %1, %16
%5 = phi i8 [ %19, %16 ], [ %2, %1 ]
%6 = phi i8* [ %18, %16 ], [ %0, %1 ]
%7 = tail call i32 @isalnum(i8 signext %5)
%8 = icmp ne i32 %7, 0
%9 = load i8, i8* %6
%10 = add i8 %9, -45
%11 = icmp ult i8 %10, 2
%12 = select i1 %8, i1 true, i1 %11
br i1 %12, label %13, label %16
13: ; preds = %4
%14 = tail call i64 @tolower(i8 signext %9)
%15 = trunc i64 %14 to i8
br label %16
16: ; preds = %4, %13
%17 = phi i8 [ %15, %13 ], [ 95, %4 ]
store i8 %17, i8* %6
%18 = getelementptr inbounds i8, i8* %6, i64 1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %4
21: ; preds = %16, %1
ret void
}