#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*/ isalpha(int);
int /*<<< orphan*/ isdigit(int);
int /*<<< orphan*/ warnx(char *, char *);
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 != '-' && c != '.')
      goto bad;
  } while (*++cp);
  return (1);
bad:
  warnx("%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    11d3 <okname+0xa3>
mov    -0x14(%rbp),%edi
call   1050 <isalpha@plt>
cmp    $0x0,%eax
jne    11a9 <okname+0x79>
mov    -0x14(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11a9 <okname+0x79>
cmpl   $0x5f,-0x14(%rbp)
je     11a9 <okname+0x79>
cmpl   $0x2d,-0x14(%rbp)
je     11a9 <okname+0x79>
cmpl   $0x2e,-0x14(%rbp)
je     11a9 <okname+0x79>
jmp    11d3 <okname+0xa3>
jmp    11ae <okname+0x7e>
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    11ea <okname+0xba>
mov    -0x10(%rbp),%rsi
lea    0xe22(%rip),%rdi
call   1040 <warnx@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   %r12
push   %rbx
mov    %rdi,%r14
mov    (%rdi),%bl
lea    0x1(%rdi),%r12
movabs $0x4000000000003,%r15
jmp    114d <okname+0x2d>
nopl   (%rax)
movzbl (%r12),%ebx
add    $0x1,%r12
test   %bl,%bl
je     118c <okname+0x6c>
test   $0x80,%bl
jne    1179 <okname+0x59>
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>
add    $0xd3,%bl
cmp    $0x32,%bl
ja     1179 <okname+0x59>
movzbl %bl,%eax
bt     %rax,%r15
jb     1140 <okname+0x20>
lea    0xe80(%rip),%rdi
mov    %r14,%rsi
call   1030 <warnx@plt>
xor    %eax,%eax
jmp    1191 <okname+0x71>
mov    $0x1,%eax
pop    %rbx
pop    %r12
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 = %34, %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 %40
15: ; preds = %7
%16 = load i32, i32* %4
%17 = call i32 @isalpha(i32 %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %33, 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 %33, label %23
23: ; preds = %19
%24 = load i32, i32* %4
%25 = icmp ne i32 %24, 95
br i1 %25, label %26, label %33
26: ; preds = %23
%27 = load i32, i32* %4
%28 = icmp ne i32 %27, 45
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load i32, i32* %4
%31 = icmp ne i32 %30, 46
br i1 %31, label %32, label %33
32: ; preds = %29
br label %40
33: ; preds = %29, %26, %23, %19, %15
br label %34
34: ; preds = %33
%35 = load i8*, i8** %5
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %5
%37 = load i8, i8* %36
%38 = icmp ne i8 %37, 0
br i1 %38, label %7, label %39
39: ; preds = %34
store i32 1, i32* %2
br label %43
40: ; preds = %32, %14
%41 = load i8*, i8** %3
%42 = call i32 @warnx(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %41)
store i32 0, i32* %2
br label %43
43: ; preds = %40, %39
%44 = load i32, i32* %2
ret i32 %44
}

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 46, label %17
i8 45, label %17
]
17: ; preds = %16, %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 @warnx(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
}