#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(char const);
int /*<<< orphan*/ *strchr(char const *, char);
int strlen(char const *);
int chatdat_valid_string(const char *string) {
  if (string == NULL)
    return 0;
  if (strchr(string, '#') != NULL)
    return 0;
  if (strchr(string, '$') != NULL)
    return 0;
  int i;
  for (i = 0; i < strlen(string); i++) {
    if (!isalnum(string[i]))
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<chatdat_valid_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1153 <chatdat_valid_string+0x23>
movl   $0x0,-0x4(%rbp)
jmp    11fe <chatdat_valid_string+0xce>
mov    -0x10(%rbp),%rdi
mov    $0x23,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     1177 <chatdat_valid_string+0x47>
movl   $0x0,-0x4(%rbp)
jmp    11fe <chatdat_valid_string+0xce>
mov    -0x10(%rbp),%rdi
mov    $0x24,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     119b <chatdat_valid_string+0x6b>
movl   $0x0,-0x4(%rbp)
jmp    11fe <chatdat_valid_string+0xce>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    11f7 <chatdat_valid_string+0xc7>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <isalnum@plt>
cmp    $0x0,%eax
jne    11e4 <chatdat_valid_string+0xb4>
movl   $0x0,-0x4(%rbp)
jmp    11fe <chatdat_valid_string+0xce>
jmp    11e9 <chatdat_valid_string+0xb9>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a2 <chatdat_valid_string+0x72>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chatdat_valid_string>:
push   %rbp
push   %r14
push   %rbx
xor    %r14d,%r14d
test   %rdi,%rdi
je     1160 <chatdat_valid_string+0x30>
mov    %rdi,%rbx
mov    $0x23,%esi
call   1040 <strchr@plt>
test   %rax,%rax
jne    1160 <chatdat_valid_string+0x30>
mov    %rbx,%rdi
mov    $0x24,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1168 <chatdat_valid_string+0x38>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    $0x1,%r14d
test   %eax,%eax
jle    1160 <chatdat_valid_string+0x30>
xor    %ebp,%ebp
nopl   0x0(%rax)
movsbl (%rbx,%rbp,1),%edi
call   1050 <isalnum@plt>
test   %eax,%eax
je     11a2 <chatdat_valid_string+0x72>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     1180 <chatdat_valid_string+0x50>
jmp    1160 <chatdat_valid_string+0x30>
xor    %r14d,%r14d
jmp    1160 <chatdat_valid_string+0x30>

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

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