#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*/ safestring(char const *);
int safefilename(const char *path) {
  if (!safestring(path))
    return 0;
  for (; *path; path++) {
    if (*path == '.' || *path == '/')
      return 0;
    if (*path == '%' || *path == '\\')
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<safefilename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <safestring@plt>
cmp    $0x0,%eax
jne    113a <safefilename+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    11c1 <safefilename+0xb1>
jmp    113f <safefilename+0x2f>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11ba <safefilename+0xaa>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
je     116c <safefilename+0x5c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1178 <safefilename+0x68>
movl   $0x0,-0x4(%rbp)
jmp    11c1 <safefilename+0xb1>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
je     1198 <safefilename+0x88>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    11a4 <safefilename+0x94>
movl   $0x0,-0x4(%rbp)
jmp    11c1 <safefilename+0xb1>
jmp    11a9 <safefilename+0x99>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    113f <safefilename+0x2f>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<safefilename>:
push   %rbx
mov    %rdi,%rbx
call   1030 <safestring@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
je     1155 <safefilename+0x45>
movabs $0x80000000000601,%rcx
nopl   0x0(%rax,%rax,1)
movzbl (%rbx),%edx
lea    -0x25(%rdx),%esi
cmp    $0x37,%sil
ja     1146 <safefilename+0x36>
movzbl %sil,%esi
bt     %rsi,%rcx
jb     1155 <safefilename+0x45>
test   %dl,%dl
je     1150 <safefilename+0x40>
add    $0x1,%rbx
jmp    1130 <safefilename+0x20>
mov    $0x1,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @safefilename(i8* %0) {
%2 = tail call i32 @safestring(i8* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %10, label %4
4: ; preds = %1, %7
%5 = phi i8* [ %8, %7 ], [ %0, %1 ]
%6 = load i8, i8* %5
switch i8 %6, label %7 [
i8 0, label %10
i8 46, label %9
i8 47, label %9
i8 37, label %9
i8 92, label %9
]
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %5, i64 1
br label %4
9: ; preds = %4, %4, %4, %4
br label %10
10: ; preds = %4, %9, %1
%11 = phi i32 [ 0, %1 ], [ 0, %9 ], [ 1, %4 ]
ret i32 %11
}