#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*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strlwr(char *);
char *strstr(char *, char *);
char *strupr(char *);
char tolower(char);
char toupper(char);
int SearchString(char content[], char subStr[]) {
  char *aux = NULL, auxstr[strlen(subStr)];
  int i = 0, result = 0;
  strcpy(auxstr, subStr);
  aux = strstr(content, auxstr);
  if (aux == NULL) {
    aux = strstr(content, strupr(auxstr));
    if (aux == NULL) {
      strlwr(auxstr);
      for (i = 0; i < strlen(subStr); i++) {
        auxstr[i] = toupper(auxstr[i]);
        aux = strstr(content, auxstr);
        if (aux != NULL) {
          break;
        } else {
          auxstr[i] = tolower(auxstr[i]);
        }
      }
      if (aux == NULL) {
        return -1;
      }
    }
  }
  result = aux - content;
  if (result < 0) {
    result = 0;
  }
  return result;
}


x86 assembly (clang, -O0):
<SearchString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%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,-0x48(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x48(%rbp),%rsi
mov    -0x10(%rbp),%rdi
call   1090 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12d5 <SearchString+0x165>
mov    -0x48(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
call   1080 <strupr@plt>
mov    -0x50(%rbp),%rdi
mov    %rax,%rsi
call   1090 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12d0 <SearchString+0x160>
mov    -0x48(%rbp),%rdi
call   1030 <strlwr@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
cmp    %ecx,%eax
jge    12ad <SearchString+0x13d>
mov    -0x48(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <toupper@plt>
mov    -0x48(%rbp),%rsi
mov    %al,%cl
movslq -0x34(%rbp),%rax
mov    %cl,(%rsi,%rax,1)
mov    -0x10(%rbp),%rdi
call   1090 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     127c <SearchString+0x10c>
jmp    12ad <SearchString+0x13d>
mov    -0x48(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1070 <tolower@plt>
mov    %al,%dl
mov    -0x48(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    129f <SearchString+0x12f>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1225 <SearchString+0xb5>
cmpq   $0x0,-0x20(%rbp)
jne    12cb <SearchString+0x15b>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    1301 <SearchString+0x191>
jmp    12d0 <SearchString+0x160>
jmp    12d5 <SearchString+0x165>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jge    12f4 <SearchString+0x184>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SearchString>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1060 <strlen@plt>
mov    %eax,%eax
mov    %rsp,%r13
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    %r13,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1090 <strstr@plt>
mov    %rax,%r12
test   %rax,%rax
jne    11d8 <SearchString+0x68>
mov    %r13,%rdi
call   1080 <strupr@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1090 <strstr@plt>
mov    %rax,%r12
test   %rax,%rax
je     11f3 <SearchString+0x83>
xor    %eax,%eax
sub    %ebx,%r12d
cmovs  %eax,%r12d
mov    %r12d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r13,%rdi
call   1030 <strlwr@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    $0xffffffff,%r12d
test   %eax,%eax
jle    11e1 <SearchString+0x71>
mov    %rbx,-0x30(%rbp)
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl 0x0(%r13,%r14,1),%edi
call   1050 <toupper@plt>
mov    %eax,%ebx
mov    %al,0x0(%r13,%r14,1)
mov    -0x30(%rbp),%rdi
mov    %r13,%rsi
call   1090 <strstr@plt>
test   %rax,%rax
jne    1268 <SearchString+0xf8>
movsbl %bl,%edi
call   1070 <tolower@plt>
mov    %al,0x0(%r13,%r14,1)
add    $0x1,%r14
mov    %r15,%rdi
call   1060 <strlen@plt>
cltq
cmp    %rax,%r14
jl     1220 <SearchString+0xb0>
jmp    11e1 <SearchString+0x71>
mov    %rax,%r12
mov    -0x30(%rbp),%rbx
jmp    11d8 <SearchString+0x68>

LLVM IR (-O0):
define i32 @SearchString(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* null, i8** %6
%12 = load i8*, i8** %5
%13 = call i32 @strlen(i8* %12)
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %7
%16 = alloca i8, i64 %14
store i64 %14, i64* %8
store i32 0, i32* %9
store i32 0, i32* %10
%17 = load i8*, i8** %5
%18 = call i32 @strcpy(i8* %16, i8* %17)
%19 = load i8*, i8** %4
%20 = call i8* @strstr(i8* %19, i8* %16)
store i8* %20, i8** %6
%21 = load i8*, i8** %6
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %69
23: ; preds = %2
%24 = load i8*, i8** %4
%25 = call i8* @strupr(i8* %16)
%26 = call i8* @strstr(i8* %24, i8* %25)
store i8* %26, i8** %6
%27 = load i8*, i8** %6
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %68
29: ; preds = %23
%30 = call i32 @strlwr(i8* %16)
store i32 0, i32* %9
br label %31
31: ; preds = %60, %29
%32 = load i32, i32* %9
%33 = load i8*, i8** %5
%34 = call i32 @strlen(i8* %33)
%35 = icmp slt i32 %32, %34
br i1 %35, label %36, label %63
36: ; preds = %31
%37 = load i32, i32* %9
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %16, i64 %38
%40 = load i8, i8* %39
%41 = call signext i8 @toupper(i8 signext %40)
%42 = load i32, i32* %9
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %16, i64 %43
store i8 %41, i8* %44
%45 = load i8*, i8** %4
%46 = call i8* @strstr(i8* %45, i8* %16)
store i8* %46, i8** %6
%47 = load i8*, i8** %6
%48 = icmp ne i8* %47, null
br i1 %48, label %49, label %50
49: ; preds = %36
br label %63
50: ; preds = %36
%51 = load i32, i32* %9
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %16, i64 %52
%54 = load i8, i8* %53
%55 = call signext i8 @tolower(i8 signext %54)
%56 = load i32, i32* %9
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %16, i64 %57
store i8 %55, i8* %58
br label %59
59: ; preds = %50
br label %60
60: ; preds = %59
%61 = load i32, i32* %9
%62 = add nsw i32 %61, 1
store i32 %62, i32* %9
br label %31
63: ; preds = %49, %31
%64 = load i8*, i8** %6
%65 = icmp eq i8* %64, null
br i1 %65, label %66, label %67
66: ; preds = %63
store i32 -1, i32* %3
store i32 1, i32* %11
br label %81
67: ; preds = %63
br label %68
68: ; preds = %67, %23
br label %69
69: ; preds = %68, %2
%70 = load i8*, i8** %6
%71 = load i8*, i8** %4
%72 = ptrtoint i8* %70 to i64
%73 = ptrtoint i8* %71 to i64
%74 = sub i64 %72, %73
%75 = trunc i64 %74 to i32
store i32 %75, i32* %10
%76 = load i32, i32* %10
%77 = icmp slt i32 %76, 0
br i1 %77, label %78, label %79
78: ; preds = %69
store i32 0, i32* %10
br label %79
79: ; preds = %78, %69
%80 = load i32, i32* %10
store i32 %80, i32* %3
store i32 1, i32* %11
br label %81
81: ; preds = %79, %66
%82 = load i8*, i8** %7
%83 = load i32, i32* %3
ret i32 %83
}

LLVM IR (-O2):
define i32 @SearchString(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = call i32 @strcpy(i8* %5, i8* %1)
%7 = call i8* @strstr(i8* dereferenceable(1) %0, i8* %5)
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %30
9: ; preds = %2
%10 = call i8* @strupr(i8* %5)
%11 = call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) %10)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %30
13: ; preds = %9
%14 = call i32 @strlwr(i8* %5)
%15 = call i32 @strlen(i8* %1)
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %38
17: ; preds = %13, %24
%18 = phi i64 [ %26, %24 ], [ 0, %13 ]
%19 = getelementptr inbounds i8, i8* %5, i64 %18
%20 = load i8, i8* %19
%21 = call signext i8 @toupper(i8 signext %20)
store i8 %21, i8* %19
%22 = call i8* @strstr(i8* dereferenceable(1) %0, i8* %5)
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %30
24: ; preds = %17
%25 = call signext i8 @tolower(i8 signext %21)
store i8 %25, i8* %19
%26 = add nuw nsw i64 %18, 1
%27 = call i32 @strlen(i8* %1)
%28 = sext i32 %27 to i64
%29 = icmp slt i64 %26, %28
br i1 %29, label %17, label %38
30: ; preds = %17, %9, %2
%31 = phi i8* [ %11, %9 ], [ %7, %2 ], [ %22, %17 ]
%32 = ptrtoint i8* %31 to i64
%33 = ptrtoint i8* %0 to i64
%34 = sub i64 %32, %33
%35 = trunc i64 %34 to i32
%36 = icmp sgt i32 %35, 0
%37 = select i1 %36, i32 %35, i32 0
br label %38
38: ; preds = %24, %13, %30
%39 = phi i32 [ %37, %30 ], [ -1, %13 ], [ -1, %24 ]
ret i32 %39
}