#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*/ isalnum(char);
int strlen(char *);
int ScreenIdentString(char *string) {
  char *c;
  int len = strlen(string);
  if (len == 0 || len > 255)
    return 0;
  c = &string[0];
  while (*c) {
    if (*c != '_' && *c != '-' && !isalnum(*c))
      return 0;
    c++;
  }
  return 1;
}


x86 assembly (clang, -O0):
<ScreenIdentString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     114f <ScreenIdentString+0x2f>
cmpl   $0xff,-0x1c(%rbp)
jle    115b <ScreenIdentString+0x3b>
movl   $0x0,-0x4(%rbp)
jmp    11c9 <ScreenIdentString+0xa9>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     11c2 <ScreenIdentString+0xa2>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     11b1 <ScreenIdentString+0x91>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     11b1 <ScreenIdentString+0x91>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isalnum@plt>
cmp    $0x0,%eax
jne    11b1 <ScreenIdentString+0x91>
movl   $0x0,-0x4(%rbp)
jmp    11c9 <ScreenIdentString+0xa9>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1163 <ScreenIdentString+0x43>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ScreenIdentString>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <strlen@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     1166 <ScreenIdentString+0x46>
cmp    $0xff,%eax
jle    1144 <ScreenIdentString+0x24>
jmp    1166 <ScreenIdentString+0x46>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x2d,%al
je     1140 <ScreenIdentString+0x20>
cmp    $0x5f,%al
je     1140 <ScreenIdentString+0x20>
test   %al,%al
je     1161 <ScreenIdentString+0x41>
movsbl %al,%edi
call   1040 <isalnum@plt>
test   %eax,%eax
jne    1140 <ScreenIdentString+0x20>
jmp    1166 <ScreenIdentString+0x46>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @ScreenIdentString(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp eq i32 %2, 0
%4 = icmp sgt i32 %2, 255
%5 = or i1 %3, %4
br i1 %5, label %14, label %6
6: ; preds = %1, %12
%7 = phi i8* [ %13, %12 ], [ %0, %1 ]
%8 = load i8, i8* %7
switch i8 %8, label %9 [
i8 0, label %14
i8 95, label %12
i8 45, label %12
]
9: ; preds = %6
%10 = tail call i32 @isalnum(i8 signext %8)
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %6, %6, %9
%13 = getelementptr inbounds i8, i8* %7, i64 1
br label %6
14: ; preds = %6, %9, %1
%15 = phi i32 [ 0, %1 ], [ 1, %6 ], [ 0, %9 ]
ret i32 %15
}