#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(unsigned char);
unsigned int strlen(char const *);
int strval(const char *str) {
  const char *bad = "!#$%^&*()+={}[]|\\<>,";
  unsigned int i = 0;
  unsigned int ibad = 0;
  for (i = 0; i < strlen(str); i++) {
    unsigned char c = str[i];
    if ((i == 0) && !(isalpha(c))) {
      return -1;
    }
    for (ibad = 0; ibad <= strlen(bad); ibad++) {
      if (str[i] == bad[ibad]) {
        return -1;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<strval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xecd(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jae    1210 <strval+0xf0>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,1),%al
mov    %al,-0x21(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    119d <strval+0x7d>
movzbl -0x21(%rbp),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%eax
jne    119d <strval+0x7d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1217 <strval+0xf7>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
ja     11fd <strval+0xdd>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%edx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    11ea <strval+0xca>
movl   $0xffffffff,-0x4(%rbp)
jmp    1217 <strval+0xf7>
jmp    11ef <strval+0xcf>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11a4 <strval+0x84>
jmp    1202 <strval+0xe2>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114c <strval+0x2c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strval>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
call   1030 <strlen@plt>
test   %eax,%eax
je     118d <strval+0x6d>
xor    %ecx,%ecx
lea    0xec4(%rip),%r14
mov    %ecx,%ebx
test   %ecx,%ecx
jne    1150 <strval+0x30>
movzbl (%r15,%rbx,1),%edi
call   1040 <isalpha@plt>
test   %eax,%eax
je     1191 <strval+0x71>
mov    %r14,%rdi
call   1030 <strlen@plt>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movzbl (%r15,%rbx,1),%eax
mov    %ebp,%ecx
cmp    (%rcx,%r14,1),%al
je     1191 <strval+0x71>
add    $0x1,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebp
jbe    1160 <strval+0x40>
add    $0x1,%ebx
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %ebx,%ecx
cmp    %eax,%ebx
jb     113c <strval+0x1c>
xor    %eax,%eax
jmp    1196 <strval+0x76>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"!#$%^&*()+={}[]|\\<>,\00"
define i32 @strval(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
store i8* %0, i8** %3
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8** %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %5
br label %8
8: ; preds = %52, %1
%9 = load i32, i32* %5
%10 = load i8*, i8** %3
%11 = call i32 @strlen(i8* %10)
%12 = icmp ult i32 %9, %11
br i1 %12, label %13, label %55
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = load i32, i32* %5
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
store i8 %18, i8* %7
%19 = load i32, i32* %5
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %13
%22 = load i8, i8* %7
%23 = call i32 @isalpha(i8 zeroext %22)
%24 = icmp ne i32 %23, 0
br i1 %24, label %26, label %25
25: ; preds = %21
store i32 -1, i32* %2
br label %56
26: ; preds = %21, %13
store i32 0, i32* %6
br label %27
27: ; preds = %48, %26
%28 = load i32, i32* %6
%29 = load i8*, i8** %4
%30 = call i32 @strlen(i8* %29)
%31 = icmp ule i32 %28, %30
br i1 %31, label %32, label %51
32: ; preds = %27
%33 = load i8*, i8** %3
%34 = load i32, i32* %5
%35 = zext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = load i8*, i8** %4
%40 = load i32, i32* %6
%41 = zext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %38, %44
br i1 %45, label %46, label %47
46: ; preds = %32
store i32 -1, i32* %2
br label %56
47: ; preds = %32
br label %48
48: ; preds = %47
%49 = load i32, i32* %6
%50 = add i32 %49, 1
store i32 %50, i32* %6
br label %27
51: ; preds = %27
br label %52
52: ; preds = %51
%53 = load i32, i32* %5
%54 = add i32 %53, 1
store i32 %54, i32* %5
br label %8
55: ; preds = %8
store i32 0, i32* %2
br label %56
56: ; preds = %55, %46, %25
%57 = load i32, i32* %2
ret i32 %57
}

LLVM IR (-O2):
@.str = [21 x i8] c"!#$%^&*()+={}[]|\\<>,\00"
define i32 @strval(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %30, label %4
4: ; preds = %1, %26
%5 = phi i32 [ %27, %26 ], [ 0, %1 ]
%6 = zext i32 %5 to i64
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = icmp eq i32 %5, 0
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = load i8, i8* %7
%11 = tail call i32 @isalpha(i8 zeroext %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %30, label %13
13: ; preds = %9, %4
%14 = tail call i32 @strlen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %18
15: ; preds = %18
%16 = tail call i32 @strlen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%17 = icmp ugt i32 %25, %16
br i1 %17, label %26, label %18
18: ; preds = %13, %15
%19 = phi i32 [ 0, %13 ], [ %25, %15 ]
%20 = load i8, i8* %7
%21 = zext i32 %19 to i64
%22 = getelementptr inbounds [21 x i8], [21 x i8]* @.str, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %20, %23
%25 = add i32 %19, 1
br i1 %24, label %30, label %15
26: ; preds = %15
%27 = add i32 %5, 1
%28 = tail call i32 @strlen(i8* %0)
%29 = icmp ult i32 %27, %28
br i1 %29, label %4, label %30
30: ; preds = %26, %9, %18, %1
%31 = phi i32 [ 0, %1 ], [ -1, %18 ], [ 0, %26 ], [ -1, %9 ]
ret i32 %31
}