#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 EOF;
int /*<<< orphan*/ getch();
int getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ search(char *, char *, int);
main() {
  char input[10000], searchstr[10000];
  int d, c, i;
  d = 0;
  i = 0;
  for (d = 0; d <= 10000 && (c = getchar()) != EOF; ++d) {
    input[d] = c;
  }
  printf("What would you like to search?");
  for (i = 0; i <= 10000 && (c = getchar()) != EOF; ++i) {
    searchstr[i] = c;
  }
  search(input, searchstr, 10000);
  printf("\n%s", searchstr);
  getch();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4e40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x4e34(%rbp)
movl   $0x0,-0x4e3c(%rbp)
movl   $0x0,-0x4e34(%rbp)
xor    %eax,%eax
cmpl   $0x2710,-0x4e34(%rbp)
mov    %al,-0x4e3d(%rbp)
jg     11a7 <main+0x67>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x4e38(%rbp)
mov    0x2e4c(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x4e3d(%rbp)
mov    -0x4e3d(%rbp),%al
test   $0x1,%al
jne    11ba <main+0x7a>
jmp    11e4 <main+0xa4>
mov    -0x4e38(%rbp),%eax
mov    %al,%cl
movslq -0x4e34(%rbp),%rax
mov    %cl,-0x2720(%rbp,%rax,1)
mov    -0x4e34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4e34(%rbp)
jmp    1170 <main+0x30>
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4e3c(%rbp)
xor    %eax,%eax
cmpl   $0x2710,-0x4e3c(%rbp)
mov    %al,-0x4e3e(%rbp)
jg     1233 <main+0xf3>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x4e38(%rbp)
mov    0x2dc0(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x4e3e(%rbp)
mov    -0x4e3e(%rbp),%al
test   $0x1,%al
jne    1246 <main+0x106>
jmp    1270 <main+0x130>
mov    -0x4e38(%rbp),%eax
mov    %al,%cl
movslq -0x4e3c(%rbp),%rax
mov    %cl,-0x4e30(%rbp,%rax,1)
mov    -0x4e3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4e3c(%rbp)
jmp    11fc <main+0xbc>
lea    -0x2720(%rbp),%rdi
lea    -0x4e30(%rbp),%rsi
mov    $0x2710,%edx
call   1040 <search@plt>
lea    -0x4e30(%rbp),%rsi
lea    0xd89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <getch@plt>
mov    -0x4(%rbp),%eax
add    $0x4e40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x4e28,%rsp
mov    0x2e97(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%r14),%eax
je     1180 <main+0x40>
mov    %al,0x2710(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x2711,%rbx
jne    1160 <main+0x20>
lea    0xe79(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%r14),%eax
je     11ac <main+0x6c>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x2711,%rbx
jne    1190 <main+0x50>
lea    0x2710(%rsp),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
mov    $0x2710,%edx
call   1040 <search@plt>
lea    0xe54(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <getch@plt>
xor    %eax,%eax
add    $0x4e28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [31 x i8] c"What would you like to search?\00"
@.str.1 = [4 x i8] c"\0A%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10000 x i8]
%3 = alloca [10000 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %6
store i32 0, i32* %4
br label %7
7: ; preds = %22, %0
%8 = load i32, i32* %4
%9 = icmp sle i32 %8, 10000
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = call i32 (...) @getchar()
store i32 %11, i32* %5
%12 = load i32, i32* @EOF
%13 = icmp ne i32 %11, %12
br label %14
14: ; preds = %10, %7
%15 = phi i1 [ false, %7 ], [ %13, %10 ]
br i1 %15, label %16, label %25
16: ; preds = %14
%17 = load i32, i32* %5
%18 = trunc i32 %17 to i8
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [10000 x i8], [10000 x i8]* %2, i64 0, i64 %20
store i8 %18, i8* %21
br label %22
22: ; preds = %16
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %7
25: ; preds = %14
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
br label %27
27: ; preds = %42, %25
%28 = load i32, i32* %6
%29 = icmp sle i32 %28, 10000
br i1 %29, label %30, label %34
30: ; preds = %27
%31 = call i32 (...) @getchar()
store i32 %31, i32* %5
%32 = load i32, i32* @EOF
%33 = icmp ne i32 %31, %32
br label %34
34: ; preds = %30, %27
%35 = phi i1 [ false, %27 ], [ %33, %30 ]
br i1 %35, label %36, label %45
36: ; preds = %34
%37 = load i32, i32* %5
%38 = trunc i32 %37 to i8
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 %40
store i8 %38, i8* %41
br label %42
42: ; preds = %36
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %27
45: ; preds = %34
%46 = getelementptr inbounds [10000 x i8], [10000 x i8]* %2, i64 0, i64 0
%47 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%48 = call i32 @search(i8* %46, i8* %47, i32 10000)
%49 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %49)
%51 = call i32 (...) @getch()
%52 = load i32, i32* %1
ret i32 %52
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [31 x i8] c"What would you like to search?\00"
@.str.1 = [4 x i8] c"\0A%s\00"
define i32 @main() {
%1 = alloca [10000 x i8]
%2 = alloca [10000 x i8]
%3 = getelementptr inbounds [10000 x i8], [10000 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10000 x i8], [10000 x i8]* %2, i64 0, i64 0
br label %5
5: ; preds = %0, %10
%6 = phi i64 [ 0, %0 ], [ %13, %10 ]
%7 = tail call i32 (...) @getchar()
%8 = load i32, i32* @EOF
%9 = icmp eq i32 %7, %8
br i1 %9, label %15, label %10
10: ; preds = %5
%11 = trunc i32 %7 to i8
%12 = getelementptr inbounds [10000 x i8], [10000 x i8]* %1, i64 0, i64 %6
store i8 %11, i8* %12
%13 = add nuw nsw i64 %6, 1
%14 = icmp eq i64 %13, 10001
br i1 %14, label %15, label %5
15: ; preds = %10, %5
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %22
%18 = phi i64 [ 0, %15 ], [ %25, %22 ]
%19 = tail call i32 (...) @getchar()
%20 = load i32, i32* @EOF
%21 = icmp eq i32 %19, %20
br i1 %21, label %27, label %22
22: ; preds = %17
%23 = trunc i32 %19 to i8
%24 = getelementptr inbounds [10000 x i8], [10000 x i8]* %2, i64 0, i64 %18
store i8 %23, i8* %24
%25 = add nuw nsw i64 %18, 1
%26 = icmp eq i64 %25, 10001
br i1 %26, label %27, label %17
27: ; preds = %22, %17
%28 = call i32 @search(i8* %3, i8* %4, i32 10000)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%30 = call i32 (...) @getch()
ret i32 0
}