#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(unsigned char);
int /*<<< orphan*/ isvalidkeychar(char const);
int isvalidkey(const char *start) {
  if (!isalnum((unsigned char)*start)) {
    return 0;
  }
  for (start++; *start != ':' && *start != '\0'; start++) {
    if (!isvalidkeychar(*start)) {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<isvalidkey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1040 <isalnum@plt>
cmp    $0x0,%eax
jne    114d <isvalidkey+0x2d>
movl   $0x0,-0x4(%rbp)
jmp    11cc <isvalidkey+0xac>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x3a,%ecx
mov    %al,-0x11(%rbp)
je     117e <isvalidkey+0x5e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    118e <isvalidkey+0x6e>
jmp    11c5 <isvalidkey+0xa5>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isvalidkeychar@plt>
cmp    $0x0,%eax
jne    11af <isvalidkey+0x8f>
movl   $0x0,-0x4(%rbp)
jmp    11cc <isvalidkey+0xac>
jmp    11b4 <isvalidkey+0x94>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1159 <isvalidkey+0x39>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isvalidkey>:
push   %rbx
mov    %rdi,%rbx
movzbl (%rdi),%edi
call   1040 <isalnum@plt>
test   %eax,%eax
je     1161 <isvalidkey+0x41>
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%rbx),%ecx
mov    $0x1,%eax
test   %cl,%cl
je     1163 <isvalidkey+0x43>
cmp    $0x3a,%cl
je     1163 <isvalidkey+0x43>
movsbl %cl,%edi
call   1030 <isvalidkeychar@plt>
add    $0x1,%rbx
test   %eax,%eax
jne    1140 <isvalidkey+0x20>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @isvalidkey(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 @isalnum(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 %35
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 = %31, %9
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 58
br i1 %16, label %17, label %22
17: ; preds = %12
%18 = load i8*, i8** %3
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br label %22
22: ; preds = %17, %12
%23 = phi i1 [ false, %12 ], [ %21, %17 ]
br i1 %23, label %24, label %34
24: ; preds = %22
%25 = load i8*, i8** %3
%26 = load i8, i8* %25
%27 = call i32 @isvalidkeychar(i8 signext %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %30, label %29
29: ; preds = %24
store i32 0, i32* %2
br label %35
30: ; preds = %24
br label %31
31: ; preds = %30
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %3
br label %12
34: ; preds = %22
store i32 1, i32* %2
br label %35
35: ; preds = %34, %29, %8
%36 = load i32, i32* %2
ret i32 %36
}

LLVM IR (-O2):
define i32 @isvalidkey(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = tail call i32 @isalnum(i8 zeroext %2)
%4 = icmp eq i32 %3, 0
br i1 %4, label %12, label %5
5: ; preds = %1, %9
%6 = phi i8* [ %7, %9 ], [ %0, %1 ]
%7 = getelementptr inbounds i8, i8* %6, i64 1
%8 = load i8, i8* %7
switch i8 %8, label %9 [
i8 58, label %12
i8 0, label %12
]
9: ; preds = %5
%10 = tail call i32 @isvalidkeychar(i8 signext %8)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %5
12: ; preds = %5, %5, %9, %1
%13 = phi i32 [ 0, %1 ], [ 1, %5 ], [ 1, %5 ], [ 0, %9 ]
ret i32 %13
}