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


x86 assembly (clang, -O0):
<Is_clean_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11a2 <Is_clean_name+0x82>
jmp    113c <Is_clean_name+0x1c>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     119d <Is_clean_name+0x7d>
mov    -0x14(%rbp),%edi
call   1040 <isalnum@plt>
cmp    $0x0,%rax
jne    1187 <Is_clean_name+0x67>
mov    -0x14(%rbp),%esi
lea    0xe95(%rip),%rdi
call   1030 <safestrchr@plt>
cmp    $0x0,%rax
jne    1187 <Is_clean_name+0x67>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11aa <Is_clean_name+0x8a>
jmp    118c <Is_clean_name+0x6c>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    113c <Is_clean_name+0x1c>
jmp    11a2 <Is_clean_name+0x82>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Is_clean_name>:
push   %rbp
push   %r14
push   %rbx
test   %rdi,%rdi
je     116c <Is_clean_name+0x4c>
mov    %rdi,%rbx
mov    (%rdi),%al
test   %al,%al
je     116c <Is_clean_name+0x4c>
lea    0xec7(%rip),%r14
jmp    114c <Is_clean_name+0x2c>
nopl   0x0(%rax,%rax,1)
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     116c <Is_clean_name+0x4c>
movzbl %al,%ebp
mov    %ebp,%edi
call   1040 <isalnum@plt>
test   %rax,%rax
jne    1140 <Is_clean_name+0x20>
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <safestrchr@plt>
test   %rax,%rax
jne    1140 <Is_clean_name+0x20>
jmp    116e <Is_clean_name+0x4e>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"-_.\00"
define i8* @Is_clean_name(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %19, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %19, label %6
6: ; preds = %3, %15
%7 = phi i8 [ %17, %15 ], [ %4, %3 ]
%8 = phi i8* [ %16, %15 ], [ %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 %15
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 %19, label %15
15: ; preds = %6, %12
%16 = getelementptr inbounds i8, i8* %8, i64 1
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %6
19: ; preds = %12, %15, %3, %1
%20 = phi i8* [ null, %1 ], [ null, %3 ], [ %8, %12 ], [ null, %15 ]
ret i8* %20
}