#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(int);
scalar_t__ isspace(int);
int strlen(char const *);
int /*<<< orphan*/ tolower(int);
const char *userdb_checkid(const char *src, char dest[75]) {
  int c;
  char *q;
  q = dest;
  if (strlen(src) > 75)
    return "too long";
  c = *src++;
  if (!isalnum(c))
    return "doesn't start with an alphanumeric";
  do {
    if (!isalnum(c) && c != '.')
      return "contains non-alphanums before any @";
    *q++ = c;
  } while ((c = *src++) != 0 && c != '@');
  if (c == '@') {
    do {
      if (isspace(c))
        return "contains spaces";
      *q++ = tolower(c);
    } while ((c = *src++) != 0);
  }
  if (q < dest + 75)
    *q = 0;
  return 0;
}


x86 assembly (clang, -O0):
<userdb_checkid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x4b,%eax
jle    117a <userdb_checkid+0x3a>
lea    0xe8f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12c1 <userdb_checkid+0x181>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1040 <isalnum@plt>
cmp    $0x0,%eax
jne    11b0 <userdb_checkid+0x70>
lea    0xe62(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12c1 <userdb_checkid+0x181>
jmp    11b5 <userdb_checkid+0x75>
mov    -0x1c(%rbp),%edi
call   1040 <isalnum@plt>
cmp    $0x0,%eax
jne    11e0 <userdb_checkid+0xa0>
cmpl   $0x2e,-0x1c(%rbp)
je     11e0 <userdb_checkid+0xa0>
lea    0xe55(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12c1 <userdb_checkid+0x181>
mov    -0x1c(%rbp),%eax
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x28(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%ecx
mov    %ecx,-0x1c(%rbp)
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x29(%rbp)
je     1223 <userdb_checkid+0xe3>
cmpl   $0x40,-0x1c(%rbp)
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11b5 <userdb_checkid+0x75>
cmpl   $0x40,-0x1c(%rbp)
jne    129d <userdb_checkid+0x15d>
jmp    123d <userdb_checkid+0xfd>
mov    -0x1c(%rbp),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
je     125f <userdb_checkid+0x11f>
lea    0xdfa(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12c1 <userdb_checkid+0x181>
mov    -0x1c(%rbp),%edi
call   1060 <tolower@plt>
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x28(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jne    123d <userdb_checkid+0xfd>
jmp    129d <userdb_checkid+0x15d>
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
add    $0x4b,%rcx
cmp    %rcx,%rax
jae    12b9 <userdb_checkid+0x179>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<userdb_checkid>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
call   1030 <strlen@plt>
cmp    $0x4b,%eax
jle    1167 <userdb_checkid+0x27>
lea    0xe9e(%rip),%r15
jmp    121b <userdb_checkid+0xdb>
movsbl (%r12),%ebp
mov    %ebp,%edi
call   1040 <isalnum@plt>
test   %eax,%eax
je     11b9 <userdb_checkid+0x79>
xor    %ebx,%ebx
lea    0xeac(%rip),%r15
jmp    11a7 <userdb_checkid+0x67>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0x1(%rbx),%r13
mov    %bpl,(%r14,%rbx,1)
movsbl 0x1(%r12,%rbx,1),%ebp
mov    %r13,%rbx
test   $0xbf,%bpl
je     11c2 <userdb_checkid+0x82>
mov    %ebp,%edi
call   1040 <isalnum@plt>
cmp    $0x2e,%ebp
je     1190 <userdb_checkid+0x50>
test   %eax,%eax
jne    1190 <userdb_checkid+0x50>
jmp    121b <userdb_checkid+0xdb>
lea    0xe49(%rip),%r15
jmp    121b <userdb_checkid+0xdb>
cmp    $0x40,%bpl
jne    120a <userdb_checkid+0xca>
mov    $0x40,%ebp
lea    0xe7c(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%edi
call   1050 <isspace@plt>
test   %rax,%rax
jne    121b <userdb_checkid+0xdb>
mov    %ebp,%edi
call   1060 <tolower@plt>
lea    0x1(%r13),%rcx
mov    %al,(%r14,%r13,1)
movsbl 0x1(%r12,%r13,1),%ebp
mov    %rcx,%r13
test   %ebp,%ebp
jne    11e0 <userdb_checkid+0xa0>
jmp    120d <userdb_checkid+0xcd>
mov    %r13,%rcx
cmp    $0x4a,%rcx
jg     1218 <userdb_checkid+0xd8>
movb   $0x0,(%r14,%rcx,1)
xor    %r15d,%r15d
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"too long\00"
@.str.1 = [35 x i8] c"doesn't start with an alphanumeric\00"
@.str.2 = [36 x i8] c"contains non-alphanums before any @\00"
@.str.3 = [16 x i8] c"contains spaces\00"
define i8* @userdb_checkid(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %5
store i8* %8, i8** %7
%9 = load i8*, i8** %4
%10 = call i32 @strlen(i8* %9)
%11 = icmp sgt i32 %10, 75
br i1 %11, label %12, label %13
12: ; preds = %2
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %3
br label %77
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %4
%16 = load i8, i8* %14
%17 = sext i8 %16 to i32
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = call i32 @isalnum(i32 %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %13
store i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %77
22: ; preds = %13
br label %23
23: ; preds = %45, %22
%24 = load i32, i32* %6
%25 = call i32 @isalnum(i32 %24)
%26 = icmp ne i32 %25, 0
br i1 %26, label %31, label %27
27: ; preds = %23
%28 = load i32, i32* %6
%29 = icmp ne i32 %28, 46
br i1 %29, label %30, label %31
30: ; preds = %27
store i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %77
31: ; preds = %27, %23
%32 = load i32, i32* %6
%33 = trunc i32 %32 to i8
%34 = load i8*, i8** %7
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %7
store i8 %33, i8* %34
br label %36
36: ; preds = %31
%37 = load i8*, i8** %4
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %4
%39 = load i8, i8* %37
%40 = sext i8 %39 to i32
store i32 %40, i32* %6
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %36
%43 = load i32, i32* %6
%44 = icmp ne i32 %43, 64
br label %45
45: ; preds = %42, %36
%46 = phi i1 [ false, %36 ], [ %44, %42 ]
br i1 %46, label %23, label %47
47: ; preds = %45
%48 = load i32, i32* %6
%49 = icmp eq i32 %48, 64
br i1 %49, label %50, label %69
50: ; preds = %47
br label %51
51: ; preds = %62, %50
%52 = load i32, i32* %6
%53 = call i64 @isspace(i32 %52)
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %56
55: ; preds = %51
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %77
56: ; preds = %51
%57 = load i32, i32* %6
%58 = call i32 @tolower(i32 %57)
%59 = trunc i32 %58 to i8
%60 = load i8*, i8** %7
%61 = getelementptr inbounds i8, i8* %60, i32 1
store i8* %61, i8** %7
store i8 %59, i8* %60
br label %62
62: ; preds = %56
%63 = load i8*, i8** %4
%64 = getelementptr inbounds i8, i8* %63, i32 1
store i8* %64, i8** %4
%65 = load i8, i8* %63
%66 = sext i8 %65 to i32
store i32 %66, i32* %6
%67 = icmp ne i32 %66, 0
br i1 %67, label %51, label %68
68: ; preds = %62
br label %69
69: ; preds = %68, %47
%70 = load i8*, i8** %7
%71 = load i8*, i8** %5
%72 = getelementptr inbounds i8, i8* %71, i64 75
%73 = icmp ult i8* %70, %72
br i1 %73, label %74, label %76
74: ; preds = %69
%75 = load i8*, i8** %7
store i8 0, i8* %75
br label %76
76: ; preds = %74, %69
store i8* null, i8** %3
br label %77
77: ; preds = %76, %55, %30, %21, %12
%78 = load i8*, i8** %3
ret i8* %78
}

LLVM IR (-O2):
@.str = [9 x i8] c"too long\00"
@.str.1 = [35 x i8] c"doesn't start with an alphanumeric\00"
@.str.2 = [36 x i8] c"contains non-alphanums before any @\00"
@.str.3 = [16 x i8] c"contains spaces\00"
define i8* @userdb_checkid(i8* %0, i8* nocapture writeonly %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp sgt i32 %3, 75
br i1 %4, label %51, label %5
5: ; preds = %2
%6 = load i8, i8* %0
%7 = sext i8 %6 to i32
%8 = tail call i32 @isalnum(i32 %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %51, label %10
10: ; preds = %5
%11 = getelementptr inbounds i8, i8* %0, i64 1
br label %12
12: ; preds = %10, %20
%13 = phi i8* [ %24, %20 ], [ %11, %10 ]
%14 = phi i32 [ %26, %20 ], [ %7, %10 ]
%15 = phi i64 [ %23, %20 ], [ 0, %10 ]
%16 = tail call i32 @isalnum(i32 %14)
%17 = icmp eq i32 %16, 0
%18 = icmp ne i32 %14, 46
%19 = and i1 %18, %17
br i1 %19, label %51, label %20
20: ; preds = %12
%21 = getelementptr inbounds i8, i8* %1, i64 %15
%22 = trunc i32 %14 to i8
%23 = add nuw nsw i64 %15, 1
store i8 %22, i8* %21
%24 = getelementptr inbounds i8, i8* %13, i64 1
%25 = load i8, i8* %13
%26 = sext i8 %25 to i32
%27 = and i8 %25, -65
%28 = icmp eq i8 %27, 0
br i1 %28, label %29, label %12
29: ; preds = %20
%30 = icmp eq i8 %25, 64
br i1 %30, label %31, label %46
31: ; preds = %29, %37
%32 = phi i8* [ %42, %37 ], [ %24, %29 ]
%33 = phi i32 [ %44, %37 ], [ 64, %29 ]
%34 = phi i64 [ %41, %37 ], [ %23, %29 ]
%35 = tail call i64 @isspace(i32 %33)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %51
37: ; preds = %31
%38 = getelementptr inbounds i8, i8* %1, i64 %34
%39 = tail call i32 @tolower(i32 %33)
%40 = trunc i32 %39 to i8
%41 = add nuw nsw i64 %34, 1
store i8 %40, i8* %38
%42 = getelementptr inbounds i8, i8* %32, i64 1
%43 = load i8, i8* %32
%44 = sext i8 %43 to i32
%45 = icmp eq i8 %43, 0
br i1 %45, label %46, label %31
46: ; preds = %37, %29
%47 = phi i64 [ %23, %29 ], [ %41, %37 ]
%48 = icmp slt i64 %47, 75
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = getelementptr inbounds i8, i8* %1, i64 %47
store i8 0, i8* %50
br label %51
51: ; preds = %12, %31, %46, %49, %5, %2
%52 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), %5 ], [ null, %49 ], [ null, %46 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), %31 ], [ getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), %12 ]
ret i8* %52
}