#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 /*<<< orphan*/ printf(char *, char, char, int, int);
int indexofany(char source[], char targets[]) {
  int sourceindex, targetindex;
  char sourcechar, targetchar;
  sourceindex = 0;
  while ((sourcechar = source[sourceindex++]) != '\0') {
    targetindex = 0;
    printf("SC:\t%c\tTC:\t%c\tSI:\t%d\tTI:\t%d\n", sourcechar, targetchar,
           sourceindex, targetindex);
    while ((targetchar = targets[targetindex++]) != '\0') {
      printf("SC:\t%c\tTC:\t%c\tSI:\t%d\tTI:\t%d\t*inner*\n", sourcechar,
             targetchar, sourceindex, targetindex);
      if (sourcechar == targetchar)
        return sourceindex - 1;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<indexofany>:
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,-0x21(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
je     11dc <indexofany+0xcc>
movl   $0x0,-0x20(%rbp)
mov    -0x21(%rbp),%dl
mov    -0x22(%rbp),%al
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
lea    0xe9a(%rip),%rdi
movsbl %dl,%esi
movsbl %al,%edx
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x20(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x22(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
je     11d7 <indexofany+0xc7>
mov    -0x21(%rbp),%dl
mov    -0x22(%rbp),%al
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
lea    0xe74(%rip),%rdi
movsbl %dl,%esi
movsbl %al,%edx
call   1030 <printf@plt>
movsbl -0x21(%rbp),%eax
movsbl -0x22(%rbp),%ecx
cmp    %ecx,%eax
jne    11d2 <indexofany+0xc2>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11e3 <indexofany+0xd3>
jmp    1171 <indexofany+0x61>
jmp    1127 <indexofany+0x17>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<indexofany>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,0x8(%rsp)
mov    (%rdi),%dl
mov    $0xffffffff,%eax
test   %dl,%dl
je     11ca <indexofany+0xba>
mov    %rsi,%rbx
xor    %esi,%esi
mov    $0x1,%ecx
mov    $0x1,%ebp
lea    0xeb8(%rip),%rdi
lea    0xece(%rip),%r13
mov    %esi,0x4(%rsp)
mov    %ecx,%eax
mov    %rax,0x10(%rsp)
movsbl %dl,%r12d
mov    %r12d,%esi
xor    %edx,%edx
mov    %ebp,%ecx
xor    %r8d,%r8d
call   1030 <printf@plt>
xor    %r14d,%r14d
movzbl (%rbx,%r14,1),%r15d
test   %r15b,%r15b
je     11a0 <indexofany+0x90>
add    $0x1,%r14
movsbl %r15b,%edx
mov    %r13,%rdi
mov    %r12d,%esi
mov    %ebp,%ecx
mov    %r14d,%r8d
call   1030 <printf@plt>
cmp    %r15b,%r12b
jne    1170 <indexofany+0x60>
jmp    11c6 <indexofany+0xb6>
nopl   0x0(%rax)
mov    0x10(%rsp),%rsi
lea    0x1(%rsi),%ecx
mov    0x8(%rsp),%rax
mov    (%rax,%rbp,1),%dl
add    $0x1,%rbp
test   %dl,%dl
lea    0xe43(%rip),%rdi
jne    114f <indexofany+0x3f>
mov    $0xffffffff,%eax
jmp    11ca <indexofany+0xba>
mov    0x4(%rsp),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"SC:\09%c\09TC:\09%c\09SI:\09%d\09TI:\09%d\0A\00"
@.str.1 = [37 x i8] c"SC:\09%c\09TC:\09%c\09SI:\09%d\09TI:\09%d\09*inner*\0A\00"
define i32 @indexofany(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
%9 = alloca i8
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 0, i32* %6
br label %10
10: ; preds = %49, %2
%11 = load i8*, i8** %4
%12 = load i32, i32* %6
%13 = add nsw i32 %12, 1
store i32 %13, i32* %6
%14 = sext i32 %12 to i64
%15 = getelementptr inbounds i8, i8* %11, i64 %14
%16 = load i8, i8* %15
store i8 %16, i8* %8
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %50
19: ; preds = %10
store i32 0, i32* %7
%20 = load i8, i8* %8
%21 = load i8, i8* %9
%22 = load i32, i32* %6
%23 = load i32, i32* %7
%24 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8 signext %20, i8 signext %21, i32 %22, i32 %23)
br label %25
25: ; preds = %48, %19
%26 = load i8*, i8** %5
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
%29 = sext i32 %27 to i64
%30 = getelementptr inbounds i8, i8* %26, i64 %29
%31 = load i8, i8* %30
store i8 %31, i8* %9
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %49
34: ; preds = %25
%35 = load i8, i8* %8
%36 = load i8, i8* %9
%37 = load i32, i32* %6
%38 = load i32, i32* %7
%39 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8 signext %35, i8 signext %36, i32 %37, i32 %38)
%40 = load i8, i8* %8
%41 = sext i8 %40 to i32
%42 = load i8, i8* %9
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %41, %43
br i1 %44, label %45, label %48
45: ; preds = %34
%46 = load i32, i32* %6
%47 = sub nsw i32 %46, 1
store i32 %47, i32* %3
br label %51
48: ; preds = %34
br label %25
49: ; preds = %25
br label %10
50: ; preds = %10
store i32 -1, i32* %3
br label %51
51: ; preds = %50, %45
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
@.str = [29 x i8] c"SC:\09%c\09TC:\09%c\09SI:\09%d\09TI:\09%d\0A\00"
@.str.1 = [37 x i8] c"SC:\09%c\09TC:\09%c\09SI:\09%d\09TI:\09%d\09*inner*\0A\00"
define i32 @indexofany(i8* nocapture %0, i8* nocapture %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %28, label %11
5: ; preds = %18
%6 = add nuw i64 %12, 1
%7 = add nuw nsw i32 %14, 1
%8 = getelementptr inbounds i8, i8* %0, i64 %12
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %28, label %11
11: ; preds = %2, %5
%12 = phi i64 [ %6, %5 ], [ 1, %2 ]
%13 = phi i8 [ %9, %5 ], [ %3, %2 ]
%14 = phi i32 [ %7, %5 ], [ 1, %2 ]
%15 = phi i32 [ %14, %5 ], [ 0, %2 ]
%16 = trunc i64 %12 to i32
%17 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8 signext %13, i8 signext 0, i32 %16, i32 0)
br label %18
18: ; preds = %24, %11
%19 = phi i64 [ %20, %24 ], [ 0, %11 ]
%20 = add nuw i64 %19, 1
%21 = getelementptr inbounds i8, i8* %1, i64 %19
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %5, label %24
24: ; preds = %18
%25 = trunc i64 %20 to i32
%26 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8 signext %13, i8 signext %22, i32 %16, i32 %25)
%27 = icmp eq i8 %13, %22
br i1 %27, label %28, label %18
28: ; preds = %5, %24, %2
%29 = phi i32 [ -1, %2 ], [ %15, %24 ], [ -1, %5 ]
ret i32 %29
}