#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*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ isalpha(int);
int /*<<< orphan*/ isdigit(int);
int /*<<< orphan*/ stderr;
int okname(const char *cp0) {
  const char *cp = cp0;
  int c;
  do {
    c = *cp;
    if (c & 0200)
      goto bad;
    if (!isalpha(c) && !isdigit(c) && c != '_' && c != '-')
      goto bad;
  } while (*++cp);
  return (1);
bad:
  (void)fprintf(stderr, "mrcp: invalid user name %s\n", cp0);
  return 0;
}


x86 assembly (clang, -O0):
<okname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     1164 <okname+0x34>
jmp    11c9 <okname+0x99>
mov    -0x1c(%rbp),%edi
call   1050 <isalpha@plt>
cmp    $0x0,%eax
jne    119f <okname+0x6f>
mov    -0x1c(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    119f <okname+0x6f>
cmpl   $0x5f,-0x1c(%rbp)
je     119f <okname+0x6f>
cmpl   $0x2d,-0x1c(%rbp)
je     119f <okname+0x6f>
jmp    11c9 <okname+0x99>
jmp    11a4 <okname+0x74>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
cmpb   $0x0,0x1(%rax)
jne    1144 <okname+0x14>
movl   $0x1,-0x4(%rbp)
jmp    11e9 <okname+0xb9>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe23(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<okname>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%bl
lea    0x1(%rdi),%r15
jmp    114c <okname+0x2c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%r15),%ebx
add    $0x1,%r15
test   %bl,%bl
je     118d <okname+0x6d>
test   $0x80,%bl
jne    1171 <okname+0x51>
movsbl %bl,%ebp
mov    %ebp,%edi
call   1040 <isalpha@plt>
add    $0xffffffc6,%ebp
cmp    $0xfffffff5,%ebp
ja     1140 <okname+0x20>
test   %eax,%eax
jne    1140 <okname+0x20>
cmp    $0x5f,%bl
je     1140 <okname+0x20>
cmp    $0x2d,%bl
je     1140 <okname+0x20>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
lea    0xe7f(%rip),%rsi
mov    %r14,%rdx
call   1030 <fprintf@plt>
xor    %eax,%eax
jmp    1192 <okname+0x72>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"mrcp: invalid user name %s\0A\00"
define i32 @okname(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
br label %7
7: ; preds = %31, %1
%8 = load i8*, i8** %4
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
store i32 %10, i32* %5
%11 = load i32, i32* %5
%12 = and i32 %11, 128
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %7
br label %37
15: ; preds = %7
%16 = load i32, i32* %5
%17 = call i32 @isalpha(i32 %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %30, label %19
19: ; preds = %15
%20 = load i32, i32* %5
%21 = call i32 @isdigit(i32 %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %30, label %23
23: ; preds = %19
%24 = load i32, i32* %5
%25 = icmp ne i32 %24, 95
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load i32, i32* %5
%28 = icmp ne i32 %27, 45
br i1 %28, label %29, label %30
29: ; preds = %26
br label %37
30: ; preds = %26, %23, %19, %15
br label %31
31: ; preds = %30
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %4
%34 = load i8, i8* %33
%35 = icmp ne i8 %34, 0
br i1 %35, label %7, label %36
36: ; preds = %31
store i32 1, i32* %2
br label %41
37: ; preds = %29, %14
%38 = load i32, i32* @stderr
%39 = load i8*, i8** %3
%40 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %39)
store i32 0, i32* %2
br label %41
41: ; preds = %37, %36
%42 = load i32, i32* %2
ret i32 %42
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"mrcp: invalid user name %s\0A\00"
define i32 @okname(i8* %0) {
%2 = load i8, i8* %0
br label %3
3: ; preds = %17, %1
%4 = phi i8 [ %19, %17 ], [ %2, %1 ]
%5 = phi i8* [ %18, %17 ], [ %0, %1 ]
%6 = sext i8 %4 to i32
%7 = and i32 %6, 128
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %21
9: ; preds = %3
%10 = tail call i32 @isalpha(i32 %6)
%11 = icmp eq i32 %10, 0
%12 = freeze i32 %6
%13 = add i32 %12, -58
%14 = icmp ult i32 %13, -10
%15 = and i1 %14, %11
br i1 %15, label %16, label %17
16: ; preds = %9
switch i8 %4, label %21 [
i8 95, label %17
i8 45, label %17
]
17: ; preds = %16, %16, %9
%18 = getelementptr inbounds i8, i8* %5, i64 1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %24, label %3
21: ; preds = %16, %3
%22 = load i32, i32* @stderr
%23 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %24
24: ; preds = %17, %21
%25 = phi i32 [ 0, %21 ], [ 1, %17 ]
ret i32 %25
}