#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 strlen(char *);
int fnMatchAny(char s1[], char s2[]) {
  int i, j;
  for (i = 0; i < strlen(s1); i++) {
    for (j = 0; j < strlen(s2); j++) {
      if (s1[i] == s2[j])
        return i;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<fnMatchAny>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jge    11b7 <fnMatchAny+0xa7>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jge    11a4 <fnMatchAny+0x94>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x18(%rbp),%rcx
movslq -0x20(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    1191 <fnMatchAny+0x81>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11be <fnMatchAny+0xae>
jmp    1196 <fnMatchAny+0x86>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114a <fnMatchAny+0x3a>
jmp    11a9 <fnMatchAny+0x99>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1127 <fnMatchAny+0x17>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fnMatchAny>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r15
call   1030 <strlen@plt>
mov    $0xffffffff,%r14d
test   %eax,%eax
jle    1192 <fnMatchAny+0x82>
xor    %r12d,%r12d
jmp    1153 <fnMatchAny+0x43>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r12
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%r12
jge    1192 <fnMatchAny+0x82>
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1140 <fnMatchAny+0x30>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%r15,%r12,1),%eax
cmp    (%rbx,%rbp,1),%al
je     118f <fnMatchAny+0x7f>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     1170 <fnMatchAny+0x60>
jmp    1140 <fnMatchAny+0x30>
mov    %r12d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @fnMatchAny(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 0, i32* %6
br label %8
8: ; preds = %40, %2
%9 = load i32, i32* %6
%10 = load i8*, i8** %4
%11 = call i32 @strlen(i8* %10)
%12 = icmp slt i32 %9, %11
br i1 %12, label %13, label %43
13: ; preds = %8
store i32 0, i32* %7
br label %14
14: ; preds = %36, %13
%15 = load i32, i32* %7
%16 = load i8*, i8** %5
%17 = call i32 @strlen(i8* %16)
%18 = icmp slt i32 %15, %17
br i1 %18, label %19, label %39
19: ; preds = %14
%20 = load i8*, i8** %4
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = load i8*, i8** %5
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %25, %31
br i1 %32, label %33, label %35
33: ; preds = %19
%34 = load i32, i32* %6
store i32 %34, i32* %3
br label %44
35: ; preds = %19
br label %36
36: ; preds = %35
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %14
39: ; preds = %14
br label %40
40: ; preds = %39
%41 = load i32, i32* %6
%42 = add nsw i32 %41, 1
store i32 %42, i32* %6
br label %8
43: ; preds = %8
store i32 -1, i32* %3
br label %44
44: ; preds = %43, %33
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
define i32 @fnMatchAny(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %29
5: ; preds = %2, %22
%6 = phi i64 [ %23, %22 ], [ 0, %2 ]
%7 = tail call i32 @strlen(i8* %1)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %22
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %0, i64 %6
br label %15
11: ; preds = %15
%12 = tail call i32 @strlen(i8* %1)
%13 = sext i32 %12 to i64
%14 = icmp slt i64 %21, %13
br i1 %14, label %15, label %22
15: ; preds = %9, %11
%16 = phi i64 [ 0, %9 ], [ %21, %11 ]
%17 = load i8, i8* %10
%18 = getelementptr inbounds i8, i8* %1, i64 %16
%19 = load i8, i8* %18
%20 = icmp eq i8 %17, %19
%21 = add nuw nsw i64 %16, 1
br i1 %20, label %27, label %11
22: ; preds = %11, %5
%23 = add nuw nsw i64 %6, 1
%24 = tail call i32 @strlen(i8* %0)
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %23, %25
br i1 %26, label %5, label %29
27: ; preds = %15
%28 = trunc i64 %6 to i32
br label %29
29: ; preds = %22, %27, %2
%30 = phi i32 [ -1, %2 ], [ %28, %27 ], [ -1, %22 ]
ret i32 %30
}