#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*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ test_find_pattern(char *, char *);
int main(int argc, char *argv[]) {
  char *pattern = malloc(128);
  printf("\nNull String\n");
  test_find_pattern(pattern, "");
  printf("\nDouble Pattern\n");
  test_find_pattern(pattern, "asdfasdf");
  printf("\nQuadruple Pattern\n");
  test_find_pattern(pattern, "qwertyqwertyqwertyqwerty");
  printf("\nNo Pattern\n");
  test_find_pattern(pattern, "asdf");
  printf("\nOne Letter\n");
  test_find_pattern(pattern, "a");
  printf("\nOne Letter Repeated\n");
  test_find_pattern(pattern, "aaaaaaaa");
  printf("\nZero Char Embedded\n");
  test_find_pattern(pattern, "asdfasdf\0asdfqwert");
  free(pattern);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x80,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
lea    0xe9c(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xf2e(%rip),%rsi
call   1040 <test_find_pattern@plt>
lea    0xe8e(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe8f(%rip),%rsi
call   1040 <test_find_pattern@plt>
lea    0xe8c(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1040 <test_find_pattern@plt>
lea    0xe9d(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe5b(%rip),%rsi
call   1040 <test_find_pattern@plt>
lea    0xe8e(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xea8(%rip),%rsi
call   1040 <test_find_pattern@plt>
lea    0xe7f(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1040 <test_find_pattern@plt>
lea    0xe82(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe87(%rip),%rsi
call   1040 <test_find_pattern@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x80,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xed6(%rip),%rdi
call   1040 <puts@plt>
lea    0xec9(%rip),%rsi
mov    %rbx,%rdi
call   1050 <test_find_pattern@plt>
lea    0xec8(%rip),%rdi
call   1040 <puts@plt>
lea    0xe84(%rip),%rsi
mov    %rbx,%rdi
call   1050 <test_find_pattern@plt>
lea    0xebd(%rip),%rdi
call   1040 <puts@plt>
lea    0xe72(%rip),%rsi
mov    %rbx,%rdi
call   1050 <test_find_pattern@plt>
lea    0xeb5(%rip),%rdi
call   1040 <puts@plt>
lea    0xe52(%rip),%rsi
mov    %rbx,%rdi
call   1050 <test_find_pattern@plt>
lea    0xea6(%rip),%rdi
call   1040 <puts@plt>
lea    0xe5c(%rip),%rsi
mov    %rbx,%rdi
call   1050 <test_find_pattern@plt>
lea    0xe97(%rip),%rdi
call   1040 <puts@plt>
lea    0xe3a(%rip),%rsi
mov    %rbx,%rdi
call   1050 <test_find_pattern@plt>
lea    0xe91(%rip),%rdi
call   1040 <puts@plt>
lea    0xe99(%rip),%rsi
mov    %rbx,%rdi
call   1050 <test_find_pattern@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"\0ANull String\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [17 x i8] c"\0ADouble Pattern\0A\00"
@.str.3 = [9 x i8] c"asdfasdf\00"
@.str.4 = [20 x i8] c"\0AQuadruple Pattern\0A\00"
@.str.5 = [25 x i8] c"qwertyqwertyqwertyqwerty\00"
@.str.6 = [13 x i8] c"\0ANo Pattern\0A\00"
@.str.7 = [5 x i8] c"asdf\00"
@.str.8 = [13 x i8] c"\0AOne Letter\0A\00"
@.str.9 = [2 x i8] c"a\00"
@.str.10 = [22 x i8] c"\0AOne Letter Repeated\0A\00"
@.str.11 = [9 x i8] c"aaaaaaaa\00"
@.str.12 = [21 x i8] c"\0AZero Char Embedded\0A\00"
@.str.13 = [19 x i8] c"asdfasdf\00asdfqwert\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = call i8* @malloc(i32 128)
store i8* %6, i8** %5
%7 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%8 = load i8*, i8** %5
%9 = call i32 @test_find_pattern(i8* %8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%11 = load i8*, i8** %5
%12 = call i32 @test_find_pattern(i8* %11, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%14 = load i8*, i8** %5
%15 = call i32 @test_find_pattern(i8* %14, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%17 = load i8*, i8** %5
%18 = call i32 @test_find_pattern(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%19 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%20 = load i8*, i8** %5
%21 = call i32 @test_find_pattern(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%22 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0))
%23 = load i8*, i8** %5
%24 = call i32 @test_find_pattern(i8* %23, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0))
%25 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0))
%26 = load i8*, i8** %5
%27 = call i32 @test_find_pattern(i8* %26, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0))
%28 = load i8*, i8** %5
%29 = call i32 @free(i8* %28)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [1 x i8] zeroinitializer
@.str.3 = [9 x i8] c"asdfasdf\00"
@.str.5 = [25 x i8] c"qwertyqwertyqwertyqwerty\00"
@.str.7 = [5 x i8] c"asdf\00"
@.str.9 = [2 x i8] c"a\00"
@.str.11 = [9 x i8] c"aaaaaaaa\00"
@.str.13 = [19 x i8] c"asdfasdf\00asdfqwert\00"
@str = [13 x i8] c"\0ANull String\00"
@str.14 = [16 x i8] c"\0ADouble Pattern\00"
@str.15 = [19 x i8] c"\0AQuadruple Pattern\00"
@str.16 = [12 x i8] c"\0ANo Pattern\00"
@str.17 = [12 x i8] c"\0AOne Letter\00"
@str.18 = [21 x i8] c"\0AOne Letter Repeated\00"
@str.19 = [20 x i8] c"\0AZero Char Embedded\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call dereferenceable_or_null(128) i8* @malloc(i32 128)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @test_find_pattern(i8* %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.14, i64 0, i64 0))
%7 = tail call i32 @test_find_pattern(i8* %3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.15, i64 0, i64 0))
%9 = tail call i32 @test_find_pattern(i8* %3, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.16, i64 0, i64 0))
%11 = tail call i32 @test_find_pattern(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.17, i64 0, i64 0))
%13 = tail call i32 @test_find_pattern(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.18, i64 0, i64 0))
%15 = tail call i32 @test_find_pattern(i8* %3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.19, i64 0, i64 0))
%17 = tail call i32 @test_find_pattern(i8* %3, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0))
%18 = tail call i32 @free(i8* %3)
ret i32 0
}