#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int strFind(char *, char *);
int main() {
  char text[80], substring[80];
  int i;
  printf("Text to find in: ");
  gets(text);
  printf("\n");
  while (true) {
    printf("> ");
    gets(substring);
    i = strFind(substring, text);
    if (i != -1)
      printf("Substring '%s' found at index %i.\n\n", substring, i);
    else
      printf("Substring '%s' NOT found in text.\n\n", substring);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x60(%rbp),%rdi
call   1040 <gets@plt>
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xb0(%rbp),%rdi
call   1040 <gets@plt>
lea    -0xb0(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1050 <strFind@plt>
mov    %eax,-0xb4(%rbp)
cmpl   $0xffffffff,-0xb4(%rbp)
je     11c4 <main+0x94>
lea    -0xb0(%rbp),%rsi
mov    -0xb4(%rbp),%edx
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d9 <main+0xa9>
lea    -0xb0(%rbp),%rsi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1167 <main+0x37>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa0,%rsp
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x50(%rsp),%r14
mov    %r14,%rdi
call   1050 <gets@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe96(%rip),%r15
mov    %rsp,%rbx
lea    0xeb3(%rip),%r12
lea    0xe88(%rip),%r13
jmp    119f <main+0x5f>
nop
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1050 <gets@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strFind@plt>
cmp    $0xffffffff,%eax
jne    1190 <main+0x50>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    119f <main+0x5f>

LLVM IR (-O0):
@.str = [18 x i8] c"Text to find in: \00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [3 x i8] c"> \00"
@.str.3 = [36 x i8] c"Substring '%s' found at index %i.\0A\0A\00"
@.str.4 = [36 x i8] c"Substring '%s' NOT found in text.\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [80 x i8]
%3 = alloca [80 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%7 = call i32 @gets(i8* %6)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %0, %25
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%12 = call i32 @gets(i8* %11)
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%14 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%15 = call i32 @strFind(i8* %13, i8* %14)
store i32 %15, i32* %4
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, -1
br i1 %17, label %18, label %22
18: ; preds = %9
%19 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%20 = load i32, i32* %4
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* %19, i32 %20)
br label %25
22: ; preds = %9
%23 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i8* %23)
br label %25
25: ; preds = %22, %18
br label %9
}

LLVM IR (-O2):
@.str = [18 x i8] c"Text to find in: \00"
@.str.2 = [3 x i8] c"> \00"
@.str.3 = [36 x i8] c"Substring '%s' found at index %i.\0A\0A\00"
@.str.4 = [36 x i8] c"Substring '%s' NOT found in text.\0A\0A\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = alloca [80 x i8]
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @gets(i8* %3)
%7 = call i32 @putchar(i32 10)
br label %8
8: ; preds = %17, %0
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @gets(i8* %4)
%11 = call i32 @strFind(i8* %4, i8* %3)
%12 = icmp eq i32 %11, -1
br i1 %12, label %15, label %13
13: ; preds = %8
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* %4, i32 %11)
br label %17
15: ; preds = %8
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i8* %4)
br label %17
17: ; preds = %15, %13
br label %8
}