#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_lname(char *lname) {
  int i, len;
  if (lname == NULL)
    return 1;
  if ((len = strlen(lname)) < 2)
    return 0;
  for (i = 0; i < len; i++) {
    if (!isalnum(lname[i]))
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<valid_lname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1143 <valid_lname+0x23>
movl   $0x1,-0x4(%rbp)
jmp    11b7 <valid_lname+0x97>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x2,%eax
jge    1164 <valid_lname+0x44>
movl   $0x0,-0x4(%rbp)
jmp    11b7 <valid_lname+0x97>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11b0 <valid_lname+0x90>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isalnum@plt>
cmp    $0x0,%eax
jne    119d <valid_lname+0x7d>
movl   $0x0,-0x4(%rbp)
jmp    11b7 <valid_lname+0x97>
jmp    11a2 <valid_lname+0x82>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116b <valid_lname+0x4b>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<valid_lname>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     1167 <valid_lname+0x47>
mov    %rdi,%r12
call   1030 <strlen@plt>
xor    %r14d,%r14d
cmp    $0x2,%eax
jl     116d <valid_lname+0x4d>
mov    %eax,%r15d
xor    %r14d,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movsbl (%r12,%rbx,1),%edi
call   1040 <isalnum@plt>
test   %eax,%eax
je     116d <valid_lname+0x4d>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1150 <valid_lname+0x30>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @valid_lname(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %17, label %3
3: ; preds = %1
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp slt i32 %4, 2
br i1 %5, label %17, label %6
6: ; preds = %3
%7 = zext i32 %4 to i64
br label %10
8: ; preds = %10
%9 = icmp eq i64 %16, %7
br i1 %9, label %17, label %10
10: ; preds = %6, %8
%11 = phi i64 [ 0, %6 ], [ %16, %8 ]
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = tail call i32 @isalnum(i8 signext %13)
%15 = icmp eq i32 %14, 0
%16 = add nuw nsw i64 %11, 1
br i1 %15, label %17, label %8
17: ; preds = %10, %8, %3, %1
%18 = phi i32 [ 1, %1 ], [ 0, %3 ], [ 0, %10 ], [ 1, %8 ]
ret i32 %18
}