#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 *, char const);
int contains_illegals(const char *string, const char *illegals, int len) {
  for (; *string && len--; string++)
    if ((*string < ' ' && *string != '\005' && !(*string & 0x80)) ||
        strchr(illegals, *string))
      return 1;
  return 0;
}


x86 assembly (clang, -O0):
<contains_illegals>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1d(%rbp)
je     114c <contains_illegals+0x3c>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    $0x0,%eax
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    115c <contains_illegals+0x4c>
jmp    11cd <contains_illegals+0xbd>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jge    1191 <contains_illegals+0x81>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5,%eax
je     1191 <contains_illegals+0x81>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     11ab <contains_illegals+0x9b>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movsbl (%rax),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     11b7 <contains_illegals+0xa7>
movl   $0x1,-0x4(%rbp)
jmp    11d4 <contains_illegals+0xc4>
jmp    11bc <contains_illegals+0xac>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1123 <contains_illegals+0x13>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<contains_illegals>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     115b <contains_illegals+0x4b>
mov    %rsi,%r14
mov    %rdi,%r12
mov    %edx,%r15d
xor    %ebx,%ebx
mov    $0x1,%ebp
xchg   %ax,%ax
cmp    %ebx,%r15d
je     115b <contains_illegals+0x4b>
cmp    $0x1f,%al
ja     113d <contains_illegals+0x2d>
cmp    $0x5,%al
jne    115d <contains_illegals+0x4d>
movsbl %al,%esi
mov    %r14,%rdi
call   1030 <strchr@plt>
test   %rax,%rax
jne    115d <contains_illegals+0x4d>
movzbl 0x1(%r12,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <contains_illegals+0x20>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @contains_illegals(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
br label %8
8: ; preds = %43, %3
%9 = load i8*, i8** %5
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = load i32, i32* %7
%15 = add nsw i32 %14, -1
store i32 %15, i32* %7
%16 = icmp ne i32 %14, 0
br label %17
17: ; preds = %13, %8
%18 = phi i1 [ false, %8 ], [ %16, %13 ]
br i1 %18, label %19, label %46
19: ; preds = %17
%20 = load i8*, i8** %5
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp slt i32 %22, 32
br i1 %23, label %24, label %35
24: ; preds = %19
%25 = load i8*, i8** %5
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 5
br i1 %28, label %29, label %35
29: ; preds = %24
%30 = load i8*, i8** %5
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = and i32 %32, 128
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %41
35: ; preds = %29, %24, %19
%36 = load i8*, i8** %6
%37 = load i8*, i8** %5
%38 = load i8, i8* %37
%39 = call i64 @strchr(i8* %36, i8 signext %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %35, %29
store i32 1, i32* %4
br label %47
42: ; preds = %35
br label %43
43: ; preds = %42
%44 = load i8*, i8** %5
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %5
br label %8
46: ; preds = %17
store i32 0, i32* %4
br label %47
47: ; preds = %46, %41
%48 = load i32, i32* %4
ret i32 %48
}

LLVM IR (-O2):
define i32 @contains_illegals(i8* nocapture %0, i8* %1, i32 %2) {
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %23, label %9
6: ; preds = %19
%7 = load i8, i8* %22
%8 = icmp eq i8 %7, 0
br i1 %8, label %23, label %9
9: ; preds = %3, %6
%10 = phi i8 [ %7, %6 ], [ %4, %3 ]
%11 = phi i32 [ %13, %6 ], [ %2, %3 ]
%12 = phi i8* [ %22, %6 ], [ %0, %3 ]
%13 = add nsw i32 %11, -1
%14 = icmp eq i32 %11, 0
br i1 %14, label %23, label %15
15: ; preds = %9
%16 = icmp ne i8 %10, 5
%17 = icmp ult i8 %10, 32
%18 = and i1 %17, %16
br i1 %18, label %23, label %19
19: ; preds = %15
%20 = tail call i64 @strchr(i8* %1, i8 signext %10)
%21 = icmp eq i64 %20, 0
%22 = getelementptr inbounds i8, i8* %12, i64 1
br i1 %21, label %6, label %23
23: ; preds = %15, %19, %6, %9, %3
%24 = phi i32 [ 0, %3 ], [ 0, %9 ], [ 0, %6 ], [ 1, %19 ], [ 1, %15 ]
ret i32 %24
}