#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);
scalar_t__ isalnum(char);
int ValidateFileName(char *Name) {
  char *ptr = Name;
  int counter = 0;
  assert(ptr != 0);
  while (*ptr) {
    if ((isalnum(*ptr) || (*ptr == '_') || (*ptr == '+') || ((*ptr == '.')) ||
         ((*ptr == '/')) || ((*ptr == '-') && (counter > 0)))) {
      ptr++;
      counter++;
    } else
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<ValidateFileName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     11f5 <ValidateFileName+0xd5>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%rax
jne    11ca <ValidateFileName+0xaa>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     11ca <ValidateFileName+0xaa>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
je     11ca <ValidateFileName+0xaa>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
je     11ca <ValidateFileName+0xaa>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     11ca <ValidateFileName+0xaa>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11e4 <ValidateFileName+0xc4>
cmpl   $0x0,-0x1c(%rbp)
jle    11e4 <ValidateFileName+0xc4>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f0 <ValidateFileName+0xd0>
movl   $0x0,-0x4(%rbp)
jmp    11fc <ValidateFileName+0xdc>
jmp    114d <ValidateFileName+0x2d>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ValidateFileName>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1040 <assert@plt>
mov    (%r14),%al
test   %al,%al
je     118d <ValidateFileName+0x6d>
xor    %ebx,%ebx
movabs $0x10000000000019,%r15
jmp    115e <ValidateFileName+0x3e>
nopl   0x0(%rax,%rax,1)
movzbl 0x1(%r14,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
je     118d <ValidateFileName+0x6d>
movsbl %al,%edi
call   1030 <isalnum@plt>
test   %rax,%rax
jne    1150 <ValidateFileName+0x30>
movzbl (%r14,%rbx,1),%ecx
lea    -0x2b(%rcx),%eax
cmp    $0x34,%al
ja     1180 <ValidateFileName+0x60>
movzbl %al,%eax
bt     %rax,%r15
jb     1150 <ValidateFileName+0x30>
xor    %eax,%eax
cmp    $0x2d,%cl
jne    1192 <ValidateFileName+0x72>
test   %ebx,%ebx
jne    1150 <ValidateFileName+0x30>
jmp    1192 <ValidateFileName+0x72>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @ValidateFileName(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 = icmp eq i8 %5, 0
br i1 %6, label %24, label %7
7: ; preds = %1, %19
%8 = phi i8 [ %22, %19 ], [ %5, %1 ]
%9 = phi i32 [ %21, %19 ], [ 0, %1 ]
%10 = phi i8* [ %20, %19 ], [ %0, %1 ]
%11 = tail call i64 @isalnum(i8 signext %8)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %7
%14 = load i8, i8* %10
switch i8 %14, label %15 [
i8 95, label %19
i8 43, label %19
i8 46, label %19
i8 47, label %19
]
15: ; preds = %13
%16 = icmp eq i8 %14, 45
%17 = icmp ne i32 %9, 0
%18 = select i1 %16, i1 %17, i1 false
br i1 %18, label %19, label %24
19: ; preds = %13, %13, %13, %13, %15, %7
%20 = getelementptr inbounds i8, i8* %10, i64 1
%21 = add nuw nsw i32 %9, 1
%22 = load i8, i8* %20
%23 = icmp eq i8 %22, 0
br i1 %23, label %24, label %7
24: ; preds = %15, %19, %1
%25 = phi i32 [ 1, %1 ], [ 1, %19 ], [ 0, %15 ]
ret i32 %25
}