#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 *, int);
int strlen(char *);
bool isInOrigString(char replace[], char stringOrig[]) {
  bool isContained = false;
  int replaceLength = strlen(replace);
  int origLength = strlen(stringOrig);
  int offset = 0;
  int index = 0;
  printf("replaceLength = %d \n", replaceLength);
  printf("origLength = %d \n", origLength);
  printf("difference = %d \n", origLength - replaceLength);
  while (offset <= (origLength - replaceLength)) {
    printf("offset = %d \n", offset);
    for (int i = 0; i < replaceLength; i++) {
      if (replace[i] == stringOrig[i + offset]) {
        index++;
      } else {
        index = 0;
      }
      printf("index = %d \n", index);
    }
    if (replaceLength == index) {
      isContained = true;
      return isContained;
    }
    offset++;
  }
  return isContained;
}


x86 assembly (clang, -O0):
<isInOrigString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x20(%rbp),%esi
lea    0xe99(%rip),%rdi
call   1040 <printf@plt>
mov    -0x24(%rbp),%esi
lea    0xe9f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x24(%rbp),%esi
sub    -0x20(%rbp),%esi
lea    0xe9f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    -0x20(%rbp),%ecx
cmp    %ecx,%eax
jg     1243 <isInOrigString+0x123>
mov    -0x28(%rbp),%esi
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1217 <isInOrigString+0xf7>
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x18(%rbp),%rcx
mov    -0x30(%rbp),%edx
add    -0x28(%rbp),%edx
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    11f3 <isInOrigString+0xd3>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11fa <isInOrigString+0xda>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%esi
lea    0xe43(%rip),%rdi
call   1040 <printf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11b4 <isInOrigString+0x94>
mov    -0x20(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jne    1235 <isInOrigString+0x115>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1249 <isInOrigString+0x129>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    118d <isInOrigString+0x6d>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isInOrigString>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
lea    0xeb3(%rip),%rdi
mov    %r12d,%esi
call   1040 <printf@plt>
lea    0xeb9(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
lea    0xebd(%rip),%rdi
mov    %ebp,%esi
sub    %r12d,%esi
call   1040 <printf@plt>
sub    %r12d,%ebp
js     121e <isInOrigString+0xfe>
mov    %r14,0x10(%rsp)
add    $0x1,%ebp
mov    %rbp,0x18(%rsp)
mov    %r12d,%r13d
lea    0xeb3(%rip),%r14
xor    %esi,%esi
xor    %r15d,%r15d
mov    %r12d,0x4(%rsp)
xchg   %ax,%ax
mov    %rbx,0x8(%rsp)
lea    0xe8d(%rip),%rdi
mov    %rsi,0x20(%rsp)
call   1040 <printf@plt>
test   %r12d,%r12d
jle    11fb <isInOrigString+0xdb>
xor    %r12d,%r12d
mov    0x10(%rsp),%rbx
mov    0x8(%rsp),%rbp
nopl   0x0(%rax,%rax,1)
movzbl (%rbx,%r12,1),%eax
add    $0x1,%r15d
cmp    0x0(%rbp,%r12,1),%al
mov    $0x0,%eax
cmovne %eax,%r15d
mov    %r14,%rdi
mov    %r15d,%esi
call   1040 <printf@plt>
add    $0x1,%r12
cmp    %r12,%r13
jne    11d0 <isInOrigString+0xb0>
mov    0x4(%rsp),%r12d
cmp    %r15d,%r12d
je     1222 <isInOrigString+0x102>
mov    0x20(%rsp),%rsi
add    $0x1,%rsi
mov    0x8(%rsp),%rbx
add    $0x1,%rbx
cmp    0x18(%rsp),%rsi
jne    11a0 <isInOrigString+0x80>
xor    %eax,%eax
jmp    1227 <isInOrigString+0x107>
mov    $0x1,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"replaceLength = %d \0A\00"
@.str.1 = [18 x i8] c"origLength = %d \0A\00"
@.str.2 = [18 x i8] c"difference = %d \0A\00"
@.str.3 = [14 x i8] c"offset = %d \0A\00"
@.str.4 = [13 x i8] c"index = %d \0A\00"
define i32 @isInOrigString(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 0, i32* %6
%12 = load i8*, i8** %4
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %7
%14 = load i8*, i8** %5
%15 = call i32 @strlen(i8* %14)
store i32 %15, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
%16 = load i32, i32* %7
%17 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %8
%19 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %8
%21 = load i32, i32* %7
%22 = sub nsw i32 %20, %21
%23 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %69, %2
%25 = load i32, i32* %9
%26 = load i32, i32* %8
%27 = load i32, i32* %7
%28 = sub nsw i32 %26, %27
%29 = icmp sle i32 %25, %28
br i1 %29, label %30, label %72
30: ; preds = %24
%31 = load i32, i32* %9
%32 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %31)
store i32 0, i32* %11
br label %33
33: ; preds = %60, %30
%34 = load i32, i32* %11
%35 = load i32, i32* %7
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %63
37: ; preds = %33
%38 = load i8*, i8** %4
%39 = load i32, i32* %11
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = load i8*, i8** %5
%45 = load i32, i32* %11
%46 = load i32, i32* %9
%47 = add nsw i32 %45, %46
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %44, i64 %48
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %43, %51
br i1 %52, label %53, label %56
53: ; preds = %37
%54 = load i32, i32* %10
%55 = add nsw i32 %54, 1
store i32 %55, i32* %10
br label %57
56: ; preds = %37
store i32 0, i32* %10
br label %57
57: ; preds = %56, %53
%58 = load i32, i32* %10
%59 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %58)
br label %60
60: ; preds = %57
%61 = load i32, i32* %11
%62 = add nsw i32 %61, 1
store i32 %62, i32* %11
br label %33
63: ; preds = %33
%64 = load i32, i32* %7
%65 = load i32, i32* %10
%66 = icmp eq i32 %64, %65
br i1 %66, label %67, label %69
67: ; preds = %63
store i32 1, i32* %6
%68 = load i32, i32* %6
store i32 %68, i32* %3
br label %74
69: ; preds = %63
%70 = load i32, i32* %9
%71 = add nsw i32 %70, 1
store i32 %71, i32* %9
br label %24
72: ; preds = %24
%73 = load i32, i32* %6
store i32 %73, i32* %3
br label %74
74: ; preds = %72, %67
%75 = load i32, i32* %3
ret i32 %75
}

LLVM IR (-O2):
@.str = [21 x i8] c"replaceLength = %d \0A\00"
@.str.1 = [18 x i8] c"origLength = %d \0A\00"
@.str.2 = [18 x i8] c"difference = %d \0A\00"
@.str.3 = [14 x i8] c"offset = %d \0A\00"
@.str.4 = [13 x i8] c"index = %d \0A\00"
define i32 @isInOrigString(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i32 @strlen(i8* %1)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %3)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%7 = sub nsw i32 %4, %3
%8 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = icmp slt i32 %7, 0
br i1 %9, label %41, label %10
10: ; preds = %2
%11 = icmp sgt i32 %3, 0
%12 = add i32 %4, 1
%13 = sub i32 %12, %3
%14 = zext i32 %13 to i64
%15 = zext i32 %3 to i64
br label %19
16: ; preds = %24
%17 = add nuw nsw i64 %20, 1
%18 = icmp eq i64 %17, %14
br i1 %18, label %41, label %19
19: ; preds = %10, %16
%20 = phi i64 [ 0, %10 ], [ %17, %16 ]
%21 = phi i32 [ 0, %10 ], [ %25, %16 ]
%22 = trunc i64 %20 to i32
%23 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %22)
br i1 %11, label %27, label %24
24: ; preds = %27, %19
%25 = phi i32 [ %21, %19 ], [ %37, %27 ]
%26 = icmp eq i32 %3, %25
br i1 %26, label %41, label %16
27: ; preds = %19, %27
%28 = phi i64 [ %39, %27 ], [ 0, %19 ]
%29 = phi i32 [ %37, %27 ], [ %21, %19 ]
%30 = getelementptr inbounds i8, i8* %0, i64 %28
%31 = load i8, i8* %30
%32 = add nuw nsw i64 %28, %20
%33 = getelementptr inbounds i8, i8* %1, i64 %32
%34 = load i8, i8* %33
%35 = icmp eq i8 %31, %34
%36 = add nsw i32 %29, 1
%37 = select i1 %35, i32 %36, i32 0
%38 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %37)
%39 = add nuw nsw i64 %28, 1
%40 = icmp eq i64 %39, %15
br i1 %40, label %24, label %27
41: ; preds = %24, %16, %2
%42 = phi i32 [ 0, %2 ], [ 0, %16 ], [ 1, %24 ]
ret i32 %42
}