#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 *, int /*<<< orphan*/);
int any(char *s1, char *s2) {
  int i = 0;
  while (*s1) {
    if (contains(s2, *(s1++)))
      return i;
    i++;
  }
  return -1;
}


x86 assembly (clang, -O0):
<any>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1172 <any+0x62>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%esi
call   1030 <contains@plt>
cmp    $0x0,%rax
je     1164 <any+0x54>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1179 <any+0x69>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1127 <any+0x17>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<any>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%al
mov    $0xffffffff,%r14d
test   %al,%al
je     1152 <any+0x42>
mov    %rsi,%r15
mov    %rdi,%rbp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsbl %al,%esi
mov    %r15,%rdi
call   1030 <contains@plt>
test   %rax,%rax
jne    114f <any+0x3f>
movzbl 0x1(%rbp,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <any+0x20>
jmp    1152 <any+0x42>
mov    %ebx,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @any(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 0, i32* %6
br label %7
7: ; preds = %21, %2
%8 = load i8*, i8** %4
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %24
11: ; preds = %7
%12 = load i8*, i8** %5
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %4
%15 = load i8, i8* %13
%16 = sext i8 %15 to i32
%17 = call i64 @contains(i8* %12, i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %11
%20 = load i32, i32* %6
store i32 %20, i32* %3
br label %25
21: ; preds = %11
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
store i32 %23, i32* %6
br label %7
24: ; preds = %7
store i32 -1, i32* %3
br label %25
25: ; preds = %24, %19
%26 = load i32, i32* %3
ret i32 %26
}

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