#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 */
typedef size_t u_int;

/* Variables and functions */
int /*<<< orphan*/ *strchr(char *, char const);
int validate(const char text[]) {
  u_int i;
  static char allowed_char[] = {
      ' ', '#', '&', '~', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4',
      '5', '6', '7', '8', '9', ':', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F',
      'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
      'U', 'V', 'W', 'X', 'Y', 'Z', '[', ']', '_', 'a', 'b', 'c', 'd', 'e',
      'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
      't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '}', '\0'};
  for (i = 0; text[i] != '\0'; i++) {
    if (strchr(allowed_char, text[i]) == NULL) {
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<validate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     117d <validate+0x6d>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
lea    0x2ee8(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
jne    1167 <validate+0x57>
movl   $0x1,-0x4(%rbp)
jmp    1184 <validate+0x74>
jmp    116c <validate+0x5c>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1124 <validate+0x14>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validate>:
push   %rbp
push   %r14
push   %rbx
mov    (%rdi),%al
xor    %r14d,%r14d
test   %al,%al
je     1153 <validate+0x43>
mov    %rdi,%rbx
add    $0x1,%rbx
lea    0x2f05(%rip),%rbp
nopl   0x0(%rax,%rax,1)
movsbl %al,%esi
mov    %rbp,%rdi
call   1030 <strchr@plt>
test   %rax,%rax
je     114d <validate+0x3d>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <validate+0x20>
jmp    1153 <validate+0x43>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@validate.allowed_char = internal global [80 x i8] c" #&~+,-./0123456789:?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]_abcdefghijklmnopqrstuvwxyz{}\00"
define i32 @validate(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %3
store i64 0, i64* %4
br label %5
5: ; preds = %21, %1
%6 = load i8*, i8** %3
%7 = load i64, i64* %4
%8 = getelementptr inbounds i8, i8* %6, i64 %7
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %24
12: ; preds = %5
%13 = load i8*, i8** %3
%14 = load i64, i64* %4
%15 = getelementptr inbounds i8, i8* %13, i64 %14
%16 = load i8, i8* %15
%17 = call i32* @strchr(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @validate.allowed_char, i64 0, i64 0), i8 signext %16)
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %20
19: ; preds = %12
store i32 1, i32* %2
br label %25
20: ; preds = %12
br label %21
21: ; preds = %20
%22 = load i64, i64* %4
%23 = add i64 %22, 1
store i64 %23, i64* %4
br label %5
24: ; preds = %5
store i32 0, i32* %2
br label %25
25: ; preds = %24, %19
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@validate.allowed_char = internal global [80 x i8] c" #&~+,-./0123456789:?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]_abcdefghijklmnopqrstuvwxyz{}\00"
define i32 @validate(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %14, label %8
4: ; preds = %8
%5 = getelementptr inbounds i8, i8* %0, i64 %13
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
br i1 %7, label %14, label %8
8: ; preds = %1, %4
%9 = phi i8 [ %6, %4 ], [ %2, %1 ]
%10 = phi i64 [ %13, %4 ], [ 0, %1 ]
%11 = tail call i32* @strchr(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @validate.allowed_char, i64 0, i64 0), i8 signext %9)
%12 = icmp eq i32* %11, null
%13 = add i64 %10, 1
br i1 %12, label %14, label %4
14: ; preds = %8, %4, %1
%15 = phi i32 [ 0, %1 ], [ 0, %4 ], [ 1, %8 ]
ret i32 %15
}