#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__ contains(char const, char const *, size_t);
size_t strlen(char const *);
int has_valid_chars(const char *str, const char *matrix) {
  size_t i, len, mlen;
  len = strlen(str);
  mlen = strlen(matrix);
  for (i = 0; i < len; i++)
    if (contains(str[i], matrix, mlen) == 0)
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<has_valid_chars>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    11a7 <has_valid_chars+0x87>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x18(%rbp),%rsi
mov    -0x30(%rbp),%rdx
movsbl %al,%edi
call   1040 <contains@plt>
cmp    $0x0,%rax
jne    1191 <has_valid_chars+0x71>
movl   $0x0,-0x4(%rbp)
jmp    11ae <has_valid_chars+0x8e>
jmp    1196 <has_valid_chars+0x76>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1152 <has_valid_chars+0x32>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<has_valid_chars>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
call   1030 <strlen@plt>
mov    %rax,%r13
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    $0x1,%r15d
test   %r13,%r13
je     1183 <has_valid_chars+0x63>
mov    %rax,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl (%r12,%rbp,1),%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1040 <contains@plt>
test   %rax,%rax
je     1180 <has_valid_chars+0x60>
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1160 <has_valid_chars+0x40>
jmp    1183 <has_valid_chars+0x63>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @has_valid_chars(i8* nocapture %0, i8* %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%5 = icmp eq i64 %3, 0
br i1 %5, label %15, label %8
6: ; preds = %8
%7 = icmp eq i64 %14, %3
br i1 %7, label %15, label %8
8: ; preds = %2, %6
%9 = phi i64 [ %14, %6 ], [ 0, %2 ]
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
%12 = tail call i64 @contains(i8 signext %11, i8* %1, i64 %4)
%13 = icmp eq i64 %12, 0
%14 = add nuw i64 %9, 1
br i1 %13, label %15, label %6
15: ; preds = %8, %6, %2
%16 = phi i32 [ 1, %2 ], [ 1, %6 ], [ 0, %8 ]
ret i32 %16
}