#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 */
char toupper(int /*<<< orphan*/);
bool xscom_check_dirname(const char *n) {
  while (*n) {
    char c = toupper(*(n++));
    if ((c < 'A' || c > 'Z') && (c < '0' || c > '9'))
      return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<xscom_check_dirname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1188 <xscom_check_dirname+0x78>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x41,%eax
jl     115d <xscom_check_dirname+0x4d>
movsbl -0x11(%rbp),%eax
cmp    $0x5a,%eax
jle    1183 <xscom_check_dirname+0x73>
movsbl -0x11(%rbp),%eax
cmp    $0x30,%eax
jl     1177 <xscom_check_dirname+0x67>
movsbl -0x11(%rbp),%eax
cmp    $0x39,%eax
jle    1183 <xscom_check_dirname+0x73>
movl   $0x0,-0x4(%rbp)
jmp    118f <xscom_check_dirname+0x7f>
jmp    111c <xscom_check_dirname+0xc>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xscom_check_dirname>:
push   %rbx
mov    %rdi,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%rbx),%edi
test   %edi,%edi
je     1142 <xscom_check_dirname+0x32>
add    $0x1,%rbx
call   1030 <toupper@plt>
lea    -0x41(%rax),%ecx
cmp    $0x1a,%cl
jb     1120 <xscom_check_dirname+0x10>
add    $0xd0,%al
cmp    $0xa,%al
jb     1120 <xscom_check_dirname+0x10>
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @xscom_check_dirname(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8
store i8* %0, i8** %3
br label %5
5: ; preds = %31, %1
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = icmp ne i8 %7, 0
br i1 %8, label %9, label %32
9: ; preds = %5
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i32 1
store i8* %11, i8** %3
%12 = load i8, i8* %10
%13 = sext i8 %12 to i32
%14 = call signext i8 @toupper(i32 %13)
store i8 %14, i8* %4
%15 = load i8, i8* %4
%16 = sext i8 %15 to i32
%17 = icmp slt i32 %16, 65
br i1 %17, label %22, label %18
18: ; preds = %9
%19 = load i8, i8* %4
%20 = sext i8 %19 to i32
%21 = icmp sgt i32 %20, 90
br i1 %21, label %22, label %31
22: ; preds = %18, %9
%23 = load i8, i8* %4
%24 = sext i8 %23 to i32
%25 = icmp slt i32 %24, 48
br i1 %25, label %30, label %26
26: ; preds = %22
%27 = load i8, i8* %4
%28 = sext i8 %27 to i32
%29 = icmp sgt i32 %28, 57
br i1 %29, label %30, label %31
30: ; preds = %26, %22
store i32 0, i32* %2
br label %33
31: ; preds = %26, %18
br label %5
32: ; preds = %5
store i32 1, i32* %2
br label %33
33: ; preds = %32, %30
%34 = load i32, i32* %2
ret i32 %34
}

LLVM IR (-O2):
define i32 @xscom_check_dirname(i8* nocapture %0) {
br label %2
2: ; preds = %6, %1
%3 = phi i8* [ %0, %1 ], [ %7, %6 ]
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 0
br i1 %5, label %15, label %6
6: ; preds = %2
%7 = getelementptr inbounds i8, i8* %3, i64 1
%8 = sext i8 %4 to i32
%9 = tail call signext i8 @toupper(i32 %8)
%10 = add i8 %9, -65
%11 = icmp ult i8 %10, 26
%12 = add i8 %9, -48
%13 = icmp ult i8 %12, 10
%14 = or i1 %11, %13
br i1 %14, label %2, label %15
15: ; preds = %2, %6
%16 = phi i32 [ 0, %6 ], [ 1, %2 ]
ret i32 %16
}