#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 */
scalar_t__ isalnum(int);
scalar_t__ safestrchr(char *, int);
void Clean_name(char *s) {
  int c;
  if (s) {
    for (; (c = (int)(*(unsigned const char *)(s))); ++s) {
      if (!(isalnum(c) || safestrchr("-_.", c)))
        *s = '_';
    }
  }
}


x86 assembly (clang, -O0):
<Clean_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     119c <Clean_name+0x7c>
jmp    113c <Clean_name+0x1c>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
je     1197 <Clean_name+0x77>
mov    -0xc(%rbp),%edi
call   1040 <isalnum@plt>
cmp    $0x0,%rax
jne    1181 <Clean_name+0x61>
mov    -0xc(%rbp),%esi
lea    0xe95(%rip),%rdi
call   1030 <safestrchr@plt>
cmp    $0x0,%rax
jne    1181 <Clean_name+0x61>
mov    -0x8(%rbp),%rax
movb   $0x5f,(%rax)
jmp    1186 <Clean_name+0x66>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    113c <Clean_name+0x1c>
jmp    119c <Clean_name+0x7c>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Clean_name>:
push   %rbp
push   %r14
push   %rbx
test   %rdi,%rdi
je     116f <Clean_name+0x4f>
mov    %rdi,%rbx
mov    (%rdi),%al
test   %al,%al
je     116f <Clean_name+0x4f>
add    $0x1,%rbx
lea    0xec3(%rip),%r14
jmp    114b <Clean_name+0x2b>
nop
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     116f <Clean_name+0x4f>
movzbl %al,%ebp
mov    %ebp,%edi
call   1040 <isalnum@plt>
test   %rax,%rax
jne    1140 <Clean_name+0x20>
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <safestrchr@plt>
test   %rax,%rax
jne    1140 <Clean_name+0x20>
movb   $0x5f,-0x1(%rbx)
jmp    1140 <Clean_name+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"-_.\00"
define void @Clean_name(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %27
6: ; preds = %1
br label %7
7: ; preds = %23, %6
%8 = load i8*, i8** %2
%9 = load i8, i8* %8
%10 = zext i8 %9 to i32
store i32 %10, i32* %3
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %26
12: ; preds = %7
%13 = load i32, i32* %3
%14 = call i64 @isalnum(i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %22, label %16
16: ; preds = %12
%17 = load i32, i32* %3
%18 = call i64 @safestrchr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %16
%21 = load i8*, i8** %2
store i8 95, i8* %21
br label %22
22: ; preds = %20, %16, %12
br label %23
23: ; preds = %22
%24 = load i8*, i8** %2
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %2
br label %7
26: ; preds = %7
br label %27
27: ; preds = %26, %1
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"-_.\00"
define void @Clean_name(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %20, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %20, label %6
6: ; preds = %3, %16
%7 = phi i8 [ %18, %16 ], [ %4, %3 ]
%8 = phi i8* [ %17, %16 ], [ %0, %3 ]
%9 = zext i8 %7 to i32
%10 = tail call i64 @isalnum(i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %6
%13 = tail call i64 @safestrchr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %12
store i8 95, i8* %8
br label %16
16: ; preds = %6, %12, %15
%17 = getelementptr inbounds i8, i8* %8, i64 1
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %6
20: ; preds = %16, %3, %1
ret void
}