#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 */
int indexof(char *, char);
int any(char s1[], char s2[]) {
  int i = 0;
  char c;
  while ((c = s1[i++]) != '\0') {
    int idx = indexof(s2, c);
    if (idx != -1) {
      return --i;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<any>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x1d(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
je     117b <any+0x6b>
mov    -0x18(%rbp),%rdi
movsbl -0x1d(%rbp),%esi
call   1030 <indexof@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
je     1176 <any+0x66>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
mov    %eax,-0x4(%rbp)
jmp    1182 <any+0x72>
jmp    1127 <any+0x17>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<any>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0xffffffff,%ebp
nop
movzbl (%rbx),%eax
test   %al,%al
je     1140 <any+0x30>
movsbl %al,%esi
mov    %r14,%rdi
call   1030 <indexof@plt>
add    $0x1,%ebp
add    $0x1,%rbx
cmp    $0xffffffff,%eax
je     1120 <any+0x10>
jmp    1145 <any+0x35>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
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
%7 = alloca i8
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 0, i32* %6
br label %9
9: ; preds = %27, %2
%10 = load i8*, i8** %4
%11 = load i32, i32* %6
%12 = add nsw i32 %11, 1
store i32 %12, i32* %6
%13 = sext i32 %11 to i64
%14 = getelementptr inbounds i8, i8* %10, i64 %13
%15 = load i8, i8* %14
store i8 %15, i8* %7
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %9
%19 = load i8*, i8** %5
%20 = load i8, i8* %7
%21 = call i32 @indexof(i8* %19, i8 signext %20)
store i32 %21, i32* %8
%22 = load i32, i32* %8
%23 = icmp ne i32 %22, -1
br i1 %23, label %24, label %27
24: ; preds = %18
%25 = load i32, i32* %6
%26 = add nsw i32 %25, -1
store i32 %26, i32* %6
store i32 %26, i32* %3
br label %29
27: ; preds = %18
br label %9
28: ; preds = %9
store i32 -1, i32* %3
br label %29
29: ; preds = %28, %24
%30 = load i32, i32* %3
ret i32 %30
}

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