#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 */
scalar_t__ isalnum(unsigned char);
int /*<<< orphan*/ isalpha(unsigned char);
bool saslc__dict_valid_key(const char *key) {
  if (!isalpha((unsigned char)*key))
    return false;
  key++;
  while (isalnum((unsigned char)*key) || *key == '_')
    key++;
  return *key == '\0';
}


x86 assembly (clang, -O0):
<saslc__dict_valid_key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%eax
jne    114d <saslc__dict_valid_key+0x2d>
movl   $0x0,-0x4(%rbp)
jmp    11bd <saslc__dict_valid_key+0x9d>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1030 <isalnum@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x11(%rbp)
jne    1187 <saslc__dict_valid_key+0x67>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1197 <saslc__dict_valid_key+0x77>
jmp    11a8 <saslc__dict_valid_key+0x88>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1159 <saslc__dict_valid_key+0x39>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<saslc__dict_valid_key>:
push   %rbx
mov    %rdi,%rbx
movzbl (%rdi),%edi
call   1040 <isalpha@plt>
test   %eax,%eax
je     1152 <saslc__dict_valid_key+0x32>
add    $0x1,%rbx
movzbl (%rbx),%edi
call   1030 <isalnum@plt>
test   %rax,%rax
jne    1130 <saslc__dict_valid_key+0x10>
movzbl (%rbx),%ecx
cmp    $0x5f,%cl
je     1130 <saslc__dict_valid_key+0x10>
xor    %eax,%eax
test   %cl,%cl
sete   %al
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

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

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