#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*/ error(int /*<<< orphan*/, int /*<<< orphan*/, char *,
                         char *);
int /*<<< orphan*/ isalpha(int);
int /*<<< orphan*/ isdigit(int);
int okname(char *cp0) {
  int c;
  char *cp;
  cp = cp0;
  do {
    c = *cp;
    if (c & 0200)
      goto bad;
    if (!isalpha(c) && !isdigit(c) && c != '_' && c != '-')
      goto bad;
  } while (*++cp);
  return (1);
bad:
  error(0, 0, "%s: invalid user name", 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,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     1164 <okname+0x34>
jmp    11c9 <okname+0x99>
mov    -0x14(%rbp),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%eax
jne    119f <okname+0x6f>
mov    -0x14(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    119f <okname+0x6f>
cmpl   $0x5f,-0x14(%rbp)
je     119f <okname+0x6f>
cmpl   $0x2d,-0x14(%rbp)
je     119f <okname+0x6f>
jmp    11c9 <okname+0x99>
jmp    11a4 <okname+0x74>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
cmpb   $0x0,0x1(%rax)
jne    1144 <okname+0x14>
movl   $0x1,-0x4(%rbp)
jmp    11e4 <okname+0xb4>
mov    -0x10(%rbp),%rcx
xor    %esi,%esi
lea    0xe2a(%rip),%rdx
mov    %esi,%edi
call   1050 <error@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     1188 <okname+0x68>
test   $0x80,%bl
jne    1171 <okname+0x51>
movsbl %bl,%ebp
mov    %ebp,%edi
call   1030 <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>
lea    0xe88(%rip),%rdx
xor    %ebp,%ebp
xor    %edi,%edi
xor    %esi,%esi
mov    %r14,%rcx
call   1040 <error@plt>
jmp    118d <okname+0x6d>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"%s: invalid user name\00"
define i32 @okname(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
store i8* %6, i8** %5
br label %7
7: ; preds = %31, %1
%8 = load i8*, i8** %5
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
store i32 %10, i32* %4
%11 = load i32, i32* %4
%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* %4
%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* %4
%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* %4
%25 = icmp ne i32 %24, 95
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load i32, i32* %4
%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** %5
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %5
%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 %40
37: ; preds = %29, %14
%38 = load i8*, i8** %3
%39 = call i32 @error(i32 0, i32 0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %38)
store i32 0, i32* %2
br label %40
40: ; preds = %37, %36
%41 = load i32, i32* %2
ret i32 %41
}

LLVM IR (-O2):
@.str = [22 x i8] c"%s: invalid user name\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 %23, label %3
21: ; preds = %16, %3
%22 = tail call i32 @error(i32 0, i32 0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %23
23: ; preds = %17, %21
%24 = phi i32 [ 0, %21 ], [ 1, %17 ]
ret i32 %24
}