#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 */
typedef size_t ssize_t;

/* Variables and functions */
scalar_t__ strchr(char const *, char const);
ssize_t any(const char *str, const char *pattern) {
  ssize_t i = 0;
  for (i = 0; str[i] != '\0'; i++)
    if (strchr(pattern, str[i]))
      return i;
  return -1;
}


x86 assembly (clang, -O0):
<any>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1187 <any+0x77>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     1171 <any+0x61>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    118f <any+0x7f>
jmp    1176 <any+0x66>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1130 <any+0x20>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<any>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    (%rdi),%al
mov    $0xffffffffffffffff,%r14
test   %al,%al
je     1153 <any+0x43>
mov    %rsi,%r15
mov    %rdi,%r12
xor    %ebx,%ebx
nopl   (%rax)
movsbl %al,%esi
mov    %r15,%rdi
call   1030 <strchr@plt>
test   %rax,%rax
jne    1150 <any+0x40>
movzbl 0x1(%r12,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <any+0x20>
jmp    1153 <any+0x43>
mov    %rbx,%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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