#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__ strEquals(int /*<<< orphan*/, char *);
int strlen(char *);
int /*<<< orphan*/ substr(char *, int, int);
int find(char *s, char *sub, int start) {
  int i;
  for (i = start; i < strlen(s); i++) {
    if (strEquals(substr(s, i, strlen(sub)), sub))
      return i;
  }
  return -1;
}


x86 assembly (clang, -O0):
<find>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jge    11bd <find+0x8d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    %eax,%edx
call   1050 <substr@plt>
mov    %eax,%edi
mov    -0x18(%rbp),%rsi
call   1030 <strEquals@plt>
cmp    $0x0,%rax
je     11aa <find+0x7a>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c4 <find+0x94>
jmp    11af <find+0x7f>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1149 <find+0x19>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %rsi,%r15
mov    %rdi,%rbp
call   1040 <strlen@plt>
mov    $0xffffffff,%r14d
cmp    %ebx,%eax
jle    1187 <find+0x57>
xchg   %ax,%ax
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1050 <substr@plt>
mov    %eax,%edi
mov    %r15,%rsi
call   1030 <strEquals@plt>
test   %rax,%rax
jne    1184 <find+0x54>
add    $0x1,%ebx
mov    %rbp,%rdi
call   1040 <strlen@plt>
cmp    %eax,%ebx
jl     1150 <find+0x20>
jmp    1187 <find+0x57>
mov    %ebx,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @find(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp sgt i32 %4, %2
br i1 %5, label %6, label %16
6: ; preds = %3, %12
%7 = phi i32 [ %13, %12 ], [ %2, %3 ]
%8 = tail call i32 @strlen(i8* %1)
%9 = tail call i32 @substr(i8* %0, i32 %7, i32 %8)
%10 = tail call i64 @strEquals(i32 %9, i8* %1)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %6
%13 = add nsw i32 %7, 1
%14 = tail call i32 @strlen(i8* %0)
%15 = icmp slt i32 %13, %14
br i1 %15, label %6, label %16
16: ; preds = %6, %12, %3
%17 = phi i32 [ -1, %3 ], [ -1, %12 ], [ %7, %6 ]
ret i32 %17
}