#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__ strchr(char *, char);
int valid_fname(char *str) {
  char ch;
  while ((ch = *str++) != '\0') {
    if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') ||
        strchr("0123456789-_", ch) != 0) {
      ;
    } else {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<valid_fname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x11(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
je     11a0 <valid_fname+0x90>
movsbl -0x11(%rbp),%eax
cmp    $0x41,%eax
jl     1156 <valid_fname+0x46>
movsbl -0x11(%rbp),%eax
cmp    $0x5a,%eax
jle    118a <valid_fname+0x7a>
movsbl -0x11(%rbp),%eax
cmp    $0x61,%eax
jl     1170 <valid_fname+0x60>
movsbl -0x11(%rbp),%eax
cmp    $0x7a,%eax
jle    118a <valid_fname+0x7a>
lea    0xe89(%rip),%rdi
movsbl -0x11(%rbp),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     118f <valid_fname+0x7f>
jmp    119b <valid_fname+0x8b>
movl   $0x0,-0x4(%rbp)
jmp    11a7 <valid_fname+0x97>
jmp    111c <valid_fname+0xc>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<valid_fname>:
push   %rbp
push   %r14
push   %rbx
mov    (%rdi),%al
mov    $0x1,%r14d
test   %al,%al
je     115b <valid_fname+0x4b>
mov    %rdi,%rbx
add    $0x1,%rbx
lea    0xed2(%rip),%rbp
jmp    113b <valid_fname+0x2b>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     115b <valid_fname+0x4b>
mov    %eax,%ecx
and    $0xdf,%cl
add    $0xbf,%cl
cmp    $0x1a,%cl
jb     1130 <valid_fname+0x20>
movsbl %al,%esi
mov    %rbp,%rdi
call   1030 <strchr@plt>
test   %rax,%rax
jne    1130 <valid_fname+0x20>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"0123456789-_\00"
define i32 @valid_fname(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8
store i8* %0, i8** %3
br label %5
5: ; preds = %33, %1
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i32 1
store i8* %7, i8** %3
%8 = load i8, i8* %6
store i8 %8, i8* %4
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %34
11: ; preds = %5
%12 = load i8, i8* %4
%13 = sext i8 %12 to i32
%14 = icmp sge i32 %13, 65
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i8, i8* %4
%17 = sext i8 %16 to i32
%18 = icmp sle i32 %17, 90
br i1 %18, label %31, label %19
19: ; preds = %15, %11
%20 = load i8, i8* %4
%21 = sext i8 %20 to i32
%22 = icmp sge i32 %21, 97
br i1 %22, label %23, label %27
23: ; preds = %19
%24 = load i8, i8* %4
%25 = sext i8 %24 to i32
%26 = icmp sle i32 %25, 122
br i1 %26, label %31, label %27
27: ; preds = %23, %19
%28 = load i8, i8* %4
%29 = call i64 @strchr(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8 signext %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %27, %23, %15
br label %33
32: ; preds = %27
store i32 0, i32* %2
br label %35
33: ; preds = %31
br label %5
34: ; preds = %5
store i32 1, i32* %2
br label %35
35: ; preds = %34, %32
%36 = load i32, i32* %2
ret i32 %36
}

LLVM IR (-O2):
@.str = [13 x i8] c"0123456789-_\00"
define i32 @valid_fname(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %17, label %4
4: ; preds = %1, %14
%5 = phi i8 [ %15, %14 ], [ %2, %1 ]
%6 = phi i8* [ %7, %14 ], [ %0, %1 ]
%7 = getelementptr inbounds i8, i8* %6, i64 1
%8 = and i8 %5, -33
%9 = add i8 %8, -65
%10 = icmp ult i8 %9, 26
br i1 %10, label %14, label %11
11: ; preds = %4
%12 = tail call i64 @strchr(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8 signext %5)
%13 = icmp eq i64 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11, %4
%15 = load i8, i8* %7
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %4
17: ; preds = %11, %14, %1
%18 = phi i32 [ 1, %1 ], [ 1, %14 ], [ 0, %11 ]
ret i32 %18
}