#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);
int /*<<< orphan*/ isalpha(int);
int invalid_pname(const char *str) {
  if (!str || !isalpha((int)*str))
    return 1;
  while (*++str)
    if (!isalnum((int)*str))
      return 1;
  return 0;
}


x86 assembly (clang, -O0):
<invalid_pname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     114c <invalid_pname+0x2c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%eax
jne    1158 <invalid_pname+0x38>
movl   $0x1,-0x4(%rbp)
jmp    11a3 <invalid_pname+0x83>
jmp    115d <invalid_pname+0x3d>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
cmpb   $0x0,0x1(%rax)
je     119c <invalid_pname+0x7c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%eax
jne    1197 <invalid_pname+0x77>
movl   $0x1,-0x4(%rbp)
jmp    11a3 <invalid_pname+0x83>
jmp    115d <invalid_pname+0x3d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<invalid_pname>:
push   %rbp
push   %rbx
push   %rax
mov    $0x1,%ebp
test   %rdi,%rdi
je     1158 <invalid_pname+0x38>
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1040 <isalpha@plt>
test   %eax,%eax
je     1158 <invalid_pname+0x38>
add    $0x1,%rbx
movsbl (%rbx),%edi
test   %edi,%edi
je     1156 <invalid_pname+0x36>
call   1030 <isalnum@plt>
add    $0x1,%rbx
test   %eax,%eax
jne    1140 <invalid_pname+0x20>
jmp    1158 <invalid_pname+0x38>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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