#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(char);
int strlen(char *);
int valid_user(char *username) {
  int i;
  if (!username || !*username)
    return 0;
  i = strlen(username);
  if (i > 30 || i < 2)
    return 0;
  while (*username) {
    if (!isalnum(*username))
      return 0;
    username++;
  }
  return 1;
}


x86 assembly (clang, -O0):
<valid_user>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1144 <valid_user+0x24>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1150 <valid_user+0x30>
movl   $0x0,-0x4(%rbp)
jmp    11c7 <valid_user+0xa7>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1e,-0x14(%rbp)
jg     1170 <valid_user+0x50>
cmpl   $0x2,-0x14(%rbp)
jge    117c <valid_user+0x5c>
movl   $0x0,-0x4(%rbp)
jmp    11c7 <valid_user+0xa7>
jmp    1181 <valid_user+0x61>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11c0 <valid_user+0xa0>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isalnum@plt>
cmp    $0x0,%eax
jne    11af <valid_user+0x8f>
movl   $0x0,-0x4(%rbp)
jmp    11c7 <valid_user+0xa7>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1181 <valid_user+0x61>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<valid_user>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
test   %rdi,%rdi
je     116c <valid_user+0x4c>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     116c <valid_user+0x4c>
mov    %rbx,%rdi
call   1030 <strlen@plt>
add    $0xffffffe1,%eax
cmp    $0xffffffe3,%eax
jb     116c <valid_user+0x4c>
mov    (%rbx),%al
test   %al,%al
je     1167 <valid_user+0x47>
add    $0x1,%rbx
nopl   0x0(%rax)
movsbl %al,%edi
call   1040 <isalnum@plt>
test   %eax,%eax
je     116c <valid_user+0x4c>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1150 <valid_user+0x30>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @valid_user(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %7, %1
store i32 0, i32* %2
br label %36
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = call i32 @strlen(i8* %13)
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = icmp sgt i32 %15, 30
br i1 %16, label %20, label %17
17: ; preds = %12
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 2
br i1 %19, label %20, label %21
20: ; preds = %17, %12
store i32 0, i32* %2
br label %36
21: ; preds = %17
br label %22
22: ; preds = %32, %21
%23 = load i8*, i8** %3
%24 = load i8, i8* %23
%25 = icmp ne i8 %24, 0
br i1 %25, label %26, label %35
26: ; preds = %22
%27 = load i8*, i8** %3
%28 = load i8, i8* %27
%29 = call i32 @isalnum(i8 signext %28)
%30 = icmp ne i32 %29, 0
br i1 %30, label %32, label %31
31: ; preds = %26
store i32 0, i32* %2
br label %36
32: ; preds = %26
%33 = load i8*, i8** %3
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %3
br label %22
35: ; preds = %22
store i32 1, i32* %2
br label %36
36: ; preds = %35, %31, %20, %11
%37 = load i32, i32* %2
ret i32 %37
}

LLVM IR (-O2):
define i32 @valid_user(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %22, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %22, label %6
6: ; preds = %3
%7 = tail call i32 @strlen(i8* %0)
%8 = add i32 %7, -31
%9 = icmp ult i32 %8, -29
br i1 %9, label %22, label %10
10: ; preds = %6
%11 = load i8, i8* %0
%12 = icmp eq i8 %11, 0
br i1 %12, label %22, label %16
13: ; preds = %16
%14 = load i8, i8* %21
%15 = icmp eq i8 %14, 0
br i1 %15, label %22, label %16
16: ; preds = %10, %13
%17 = phi i8 [ %14, %13 ], [ %11, %10 ]
%18 = phi i8* [ %21, %13 ], [ %0, %10 ]
%19 = tail call i32 @isalnum(i8 signext %17)
%20 = icmp eq i32 %19, 0
%21 = getelementptr inbounds i8, i8* %18, i64 1
br i1 %20, label %22, label %13
22: ; preds = %16, %13, %10, %6, %1, %3
%23 = phi i32 [ 0, %3 ], [ 0, %1 ], [ 0, %6 ], [ 1, %10 ], [ 0, %16 ], [ 1, %13 ]
ret i32 %23
}