#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(char *, char *);
int /*<<< orphan*/ isalpha(int);
int /*<<< orphan*/ isdigit(int);
int okname(char *name) {
  char *cp = name;
  int c;
  do {
    c = *cp;
    if (c & 0200)
      goto bad;
    if (!isalpha(c) && !isdigit(c) && c != '_' && c != '-')
      goto bad;
    cp++;
  } while (*cp);
  return (1);
bad:
  error("invalid user name %s\n", name);
  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    11c4 <okname+0x94>
mov    -0x1c(%rbp),%edi
call   1040 <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    11c4 <okname+0x94>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1144 <okname+0x14>
movl   $0x1,-0x4(%rbp)
jmp    11db <okname+0xab>
mov    -0x10(%rbp),%rsi
lea    0xe31(%rip),%rdi
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     1184 <okname+0x64>
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),%rdi
mov    %r14,%rsi
call   1040 <error@plt>
xor    %eax,%eax
jmp    1189 <okname+0x69>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"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 = %33, %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 %38
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 %38
30: ; preds = %26, %23, %19, %15
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %4
br label %33
33: ; preds = %30
%34 = load i8*, i8** %4
%35 = load i8, i8* %34
%36 = icmp ne i8 %35, 0
br i1 %36, label %7, label %37
37: ; preds = %33
store i32 1, i32* %2
br label %41
38: ; preds = %29, %14
%39 = load i8*, i8** %3
%40 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %39)
store i32 0, i32* %2
br label %41
41: ; preds = %38, %37
%42 = load i32, i32* %2
ret i32 %42
}

LLVM IR (-O2):
@.str = [22 x i8] c"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 %23, label %3
21: ; preds = %16, %3
%22 = tail call i32 @error(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
}