#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__ strchr(char const *, unsigned char const);
int has_invalid_email_chars(const void *buffer, size_t length) {
  const unsigned char *s = buffer;
  int at_seen = 0;
  const char *valid_chars =
      "01234567890_-.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  for (; length && *s; length--, s++) {
    if ((*s & 0x80))
      continue;
    if (*s == '@')
      at_seen = 1;
    else if (!at_seen &&
             !(strchr(valid_chars, *s) || strchr("!#$%&'*+/=?^`{|}~", *s)))
      return 1;
    else if (at_seen && !strchr(valid_chars, *s))
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<has_invalid_email_chars>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x31(%rbp)
je     115a <has_invalid_email_chars+0x4a>
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    116a <has_invalid_email_chars+0x5a>
jmp    1249 <has_invalid_email_chars+0x139>
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     1184 <has_invalid_email_chars+0x74>
jmp    122c <has_invalid_email_chars+0x11c>
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x40,%eax
jne    11a0 <has_invalid_email_chars+0x90>
movl   $0x1,-0x24(%rbp)
jmp    1227 <has_invalid_email_chars+0x117>
cmpl   $0x0,-0x24(%rbp)
jne    11ed <has_invalid_email_chars+0xdd>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rax
movzbl (%rax),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
jne    11ed <has_invalid_email_chars+0xdd>
mov    -0x20(%rbp),%rax
lea    0xe74(%rip),%rdi
movzbl (%rax),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
jne    11ed <has_invalid_email_chars+0xdd>
movl   $0x1,-0x4(%rbp)
jmp    1250 <has_invalid_email_chars+0x140>
cmpl   $0x0,-0x24(%rbp)
je     121d <has_invalid_email_chars+0x10d>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rax
movzbl (%rax),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
jne    121d <has_invalid_email_chars+0x10d>
movl   $0x1,-0x4(%rbp)
jmp    1250 <has_invalid_email_chars+0x140>
jmp    1222 <has_invalid_email_chars+0x112>
jmp    1227 <has_invalid_email_chars+0x117>
jmp    122c <has_invalid_email_chars+0x11c>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    113a <has_invalid_email_chars+0x2a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<has_invalid_email_chars>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     11a6 <has_invalid_email_chars+0x96>
mov    %rsi,%r13
mov    %rdi,%r14
xor    %ebx,%ebx
lea    0xecd(%rip),%r15
xor    %ebp,%ebp
jmp    114f <has_invalid_email_chars+0x3f>
nopw   0x0(%rax,%rax,1)
mov    %ebp,%r12d
add    $0x1,%rbx
mov    %r12d,%ebp
cmp    %rbx,%r13
je     11a6 <has_invalid_email_chars+0x96>
movzbl (%r14,%rbx,1),%eax
test   %al,%al
je     11a6 <has_invalid_email_chars+0x96>
js     1140 <has_invalid_email_chars+0x30>
mov    $0x1,%r12d
cmp    $0x40,%al
je     1143 <has_invalid_email_chars+0x33>
movzbl %al,%esi
mov    %r15,%rdi
call   1030 <strchr@plt>
test   %ebp,%ebp
je     1180 <has_invalid_email_chars+0x70>
mov    $0x1,%r12d
test   %rax,%rax
jne    1143 <has_invalid_email_chars+0x33>
jmp    11a9 <has_invalid_email_chars+0x99>
xor    %r12d,%r12d
test   %rax,%rax
jne    1143 <has_invalid_email_chars+0x33>
movzbl (%r14,%rbx,1),%esi
lea    0xeaf(%rip),%rdi
call   1030 <strchr@plt>
test   %rax,%rax
jne    1143 <has_invalid_email_chars+0x33>
mov    $0x1,%r12d
jmp    11a9 <has_invalid_email_chars+0x99>
xor    %r12d,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [67 x i8] c"01234567890_-.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\00"
@.str.1 = [18 x i8] c"!#$%&'*+/=?^`{|}~\00"
define i32 @has_invalid_email_chars(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %4
store i64 %1, i64* %5
%9 = load i8*, i8** %4
store i8* %9, i8** %6
store i32 0, i32* %7
store i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0), i8** %8
br label %10
10: ; preds = %61, %2
%11 = load i64, i64* %5
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load i8*, i8** %6
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br label %18
18: ; preds = %13, %10
%19 = phi i1 [ false, %10 ], [ %17, %13 ]
br i1 %19, label %20, label %66
20: ; preds = %18
%21 = load i8*, i8** %6
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = and i32 %23, 128
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %20
br label %61
27: ; preds = %20
%28 = load i8*, i8** %6
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = icmp eq i32 %30, 64
br i1 %31, label %32, label %33
32: ; preds = %27
store i32 1, i32* %7
br label %60
33: ; preds = %27
%34 = load i32, i32* %7
%35 = icmp ne i32 %34, 0
br i1 %35, label %48, label %36
36: ; preds = %33
%37 = load i8*, i8** %8
%38 = load i8*, i8** %6
%39 = load i8, i8* %38
%40 = call i64 @strchr(i8* %37, i8 zeroext %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %48, label %42
42: ; preds = %36
%43 = load i8*, i8** %6
%44 = load i8, i8* %43
%45 = call i64 @strchr(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %44)
%46 = icmp ne i64 %45, 0
br i1 %46, label %48, label %47
47: ; preds = %42
store i32 1, i32* %3
br label %67
48: ; preds = %42, %36, %33
%49 = load i32, i32* %7
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %58
51: ; preds = %48
%52 = load i8*, i8** %8
%53 = load i8*, i8** %6
%54 = load i8, i8* %53
%55 = call i64 @strchr(i8* %52, i8 zeroext %54)
%56 = icmp ne i64 %55, 0
br i1 %56, label %58, label %57
57: ; preds = %51
store i32 1, i32* %3
br label %67
58: ; preds = %51, %48
br label %59
59: ; preds = %58
br label %60
60: ; preds = %59, %32
br label %61
61: ; preds = %60, %26
%62 = load i64, i64* %5
%63 = add i64 %62, -1
store i64 %63, i64* %5
%64 = load i8*, i8** %6
%65 = getelementptr inbounds i8, i8* %64, i32 1
store i8* %65, i8** %6
br label %10
66: ; preds = %18
store i32 0, i32* %3
br label %67
67: ; preds = %66, %57, %47
%68 = load i32, i32* %3
ret i32 %68
}

LLVM IR (-O2):
@.str = [67 x i8] c"01234567890_-.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\00"
@.str.1 = [18 x i8] c"!#$%&'*+/=?^`{|}~\00"
define i32 @has_invalid_email_chars(i8* nocapture %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %29, label %4
4: ; preds = %2, %24
%5 = phi i32 [ %25, %24 ], [ 0, %2 ]
%6 = phi i8* [ %27, %24 ], [ %0, %2 ]
%7 = phi i64 [ %26, %24 ], [ %1, %2 ]
%8 = load i8, i8* %6
%9 = icmp eq i8 %8, 0
br i1 %9, label %29, label %10
10: ; preds = %4
%11 = icmp sgt i8 %8, -1
br i1 %11, label %12, label %24
12: ; preds = %10
%13 = icmp eq i8 %8, 64
br i1 %13, label %24, label %14
14: ; preds = %12
%15 = icmp eq i32 %5, 0
%16 = tail call i64 @strchr(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0), i8 zeroext %8)
%17 = icmp eq i64 %16, 0
br i1 %15, label %18, label %23
18: ; preds = %14
br i1 %17, label %19, label %24
19: ; preds = %18
%20 = load i8, i8* %6
%21 = tail call i64 @strchr(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %29, label %24
23: ; preds = %14
br i1 %17, label %29, label %24
24: ; preds = %18, %19, %12, %23, %10
%25 = phi i32 [ %5, %10 ], [ 1, %23 ], [ 1, %12 ], [ 0, %19 ], [ 0, %18 ]
%26 = add i64 %7, -1
%27 = getelementptr inbounds i8, i8* %6, i64 1
%28 = icmp eq i64 %26, 0
br i1 %28, label %29, label %4
29: ; preds = %19, %23, %24, %4, %2
%30 = phi i32 [ 0, %2 ], [ 0, %4 ], [ 0, %24 ], [ 1, %23 ], [ 1, %19 ]
ret i32 %30
}