#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*/ isValidKeyChar(char const);
int strlen(char const *);
int sam3aIsValidPubKey(const char *key) {
  if (key != NULL && strlen(key) == (516)) {
    for (int f = 0; f < (516); ++f)
      if (!isValidKeyChar(key[f]))
        return 0;
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<sam3aIsValidPubKey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11a4 <sam3aIsValidPubKey+0x84>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x204,%eax
jne    11a4 <sam3aIsValidPubKey+0x84>
movl   $0x0,-0x14(%rbp)
cmpl   $0x204,-0x14(%rbp)
jge    1198 <sam3aIsValidPubKey+0x78>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isValidKeyChar@plt>
cmp    $0x0,%eax
jne    1185 <sam3aIsValidPubKey+0x65>
movl   $0x0,-0x4(%rbp)
jmp    11ab <sam3aIsValidPubKey+0x8b>
jmp    118a <sam3aIsValidPubKey+0x6a>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1152 <sam3aIsValidPubKey+0x32>
movl   $0x1,-0x4(%rbp)
jmp    11ab <sam3aIsValidPubKey+0x8b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sam3aIsValidPubKey>:
push   %rbp
push   %r14
push   %rbx
xor    %r14d,%r14d
test   %rdi,%rdi
je     117c <sam3aIsValidPubKey+0x5c>
mov    %rdi,%rbx
call   1040 <strlen@plt>
cmp    $0x204,%eax
jne    117c <sam3aIsValidPubKey+0x5c>
movsbl (%rbx),%edi
call   1030 <isValidKeyChar@plt>
test   %eax,%eax
je     117c <sam3aIsValidPubKey+0x5c>
xor    %ecx,%ecx
nopl   0x0(%rax)
mov    %rcx,%rbp
cmp    $0x203,%rcx
je     116e <sam3aIsValidPubKey+0x4e>
movsbl 0x1(%rbx,%rbp,1),%edi
call   1030 <isValidKeyChar@plt>
lea    0x1(%rbp),%rcx
test   %eax,%eax
jne    1150 <sam3aIsValidPubKey+0x30>
xor    %r14d,%r14d
cmp    $0x203,%rbp
setae  %r14b
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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