#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 mstring_get_length(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int mstring_find_start(char *in, char find, int start) {
  int size = mstring_get_length(in);
  int curr;
  char buff[size];
  strcpy(buff, in);
  for (curr = start; curr != size; curr++) {
    char c = buff[curr];
    if (c == find) {
      return curr;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<mstring_find_start>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <mstring_get_length@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x40(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     11c5 <mstring_find_start+0xa5>
mov    -0x40(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x31(%rbp)
movsbl -0x31(%rbp),%eax
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
jne    11b2 <mstring_find_start+0x92>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x38(%rbp)
jmp    11d3 <mstring_find_start+0xb3>
jmp    11b7 <mstring_find_start+0x97>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1176 <mstring_find_start+0x56>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x38(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mstring_find_start>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r12d
mov    %esi,%r14d
mov    %rdi,%r13
call   1040 <mstring_get_length@plt>
mov    %eax,%r15d
mov    %eax,%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
mov    $0xffffffff,%eax
cmp    %r12d,%r15d
je     1187 <mstring_find_start+0x67>
movslq %r12d,%rcx
add    %rcx,%rbx
nopl   (%rax)
cmp    %r14b,(%rbx)
je     1184 <mstring_find_start+0x64>
add    $0x1,%r12d
add    $0x1,%rbx
cmp    %r12d,%r15d
jne    1170 <mstring_find_start+0x50>
jmp    1187 <mstring_find_start+0x67>
mov    %r12d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @mstring_find_start(i8* %0, i8 signext %1, i32 %2) {
%4 = tail call i32 @mstring_get_length(i8* %0)
%5 = zext i32 %4 to i64
%6 = alloca i8, i64 %5
%7 = call i32 @strcpy(i8* %6, i8* %0)
%8 = icmp eq i32 %4, %2
br i1 %8, label %22, label %9
9: ; preds = %3
%10 = sext i32 %2 to i64
br label %11
11: ; preds = %9, %16
%12 = phi i64 [ %10, %9 ], [ %17, %16 ]
%13 = getelementptr inbounds i8, i8* %6, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, %1
br i1 %15, label %20, label %16
16: ; preds = %11
%17 = add nsw i64 %12, 1
%18 = trunc i64 %17 to i32
%19 = icmp eq i32 %4, %18
br i1 %19, label %22, label %11
20: ; preds = %11
%21 = trunc i64 %12 to i32
br label %22
22: ; preds = %16, %20, %3
%23 = phi i32 [ -1, %3 ], [ %21, %20 ], [ -1, %16 ]
ret i32 %23
}