#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 len = strlen(str);
  size_t mlen = strlen(matrix);
  for (unsigned int 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,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x20(%rbp),%rax
jae    11a1 <has_valid_chars+0x81>
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    (%rax,%rcx,1),%al
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
movsbl %al,%edi
call   1040 <contains@plt>
cmp    $0x0,%rax
jne    118e <has_valid_chars+0x6e>
movl   $0x0,-0x4(%rbp)
jmp    11a8 <has_valid_chars+0x88>
jmp    1193 <has_valid_chars+0x73>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1151 <has_valid_chars+0x31>
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,%r15
call   1030 <strlen@plt>
mov    %rax,%r13
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %r13,%r13
je     117f <has_valid_chars+0x5f>
mov    %rax,%rbx
mov    $0x1,%ebp
xor    %r12d,%r12d
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl (%r15,%rax,1),%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1040 <contains@plt>
test   %rax,%rax
je     1185 <has_valid_chars+0x65>
mov    %ebp,%eax
add    $0x1,%ebp
cmp    %rax,%r13
ja     1160 <has_valid_chars+0x40>
mov    $0x1,%r12d
mov    %r12d,%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 i32
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* %6
%11 = load i8*, i8** %5
%12 = call i64 @strlen(i8* %11)
store i64 %12, i64* %7
store i32 0, i32* %8
br label %13
13: ; preds = %30, %2
%14 = load i32, i32* %8
%15 = zext i32 %14 to i64
%16 = load i64, i64* %6
%17 = icmp ult i64 %15, %16
br i1 %17, label %18, label %33
18: ; preds = %13
%19 = load i8*, i8** %4
%20 = load i32, i32* %8
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = load i8*, i8** %5
%25 = load i64, i64* %7
%26 = call i64 @contains(i8 signext %23, i8* %24, i64 %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %18
store i32 0, i32* %3
br label %34
29: ; preds = %18
br label %30
30: ; preds = %29
%31 = load i32, i32* %8
%32 = add i32 %31, 1
store i32 %32, i32* %8
br label %13
33: ; preds = %13
store i32 1, i32* %3
br label %34
34: ; preds = %33, %28
%35 = load i32, i32* %3
ret i32 %35
}

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 %17, label %9
6: ; preds = %9
%7 = zext i32 %16 to i64
%8 = icmp ugt i64 %3, %7
br i1 %8, label %9, label %17
9: ; preds = %2, %6
%10 = phi i64 [ %7, %6 ], [ 0, %2 ]
%11 = phi i32 [ %16, %6 ], [ 0, %2 ]
%12 = getelementptr inbounds i8, i8* %0, i64 %10
%13 = load i8, i8* %12
%14 = tail call i64 @contains(i8 signext %13, i8* %1, i64 %4)
%15 = icmp eq i64 %14, 0
%16 = add i32 %11, 1
br i1 %15, label %17, label %6
17: ; preds = %6, %9, %2
%18 = phi i32 [ 1, %2 ], [ 0, %9 ], [ 1, %6 ]
ret i32 %18
}