#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 findPattern(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
void test_findPattern() {
  printf("TEST: findPattern\n");
  char input[] = "This is a test!\n";
  char pattern[] = "es";
  printf("The position of pattern \"%s\" in input \"%s\" is: %d\n", pattern,
         input, findPattern(pattern, input));
}


x86 assembly (clang, -O0):
<test_findPattern>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0xf13(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xf10(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xf0e(%rip),%al
mov    %al,-0x10(%rbp)
mov    0xeb7(%rip),%ax
mov    %ax,-0x23(%rbp)
mov    0xeaf(%rip),%al
mov    %al,-0x21(%rbp)
lea    -0x23(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x23(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <findPattern@plt>
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    %eax,%ecx
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_findPattern>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xf09(%rip),%rdi
call   1030 <puts@plt>
movaps 0xeb6(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movb   $0x0,0x20(%rsp)
movb   $0x0,0xe(%rsp)
movw   $0x7365,0xc(%rsp)
lea    0xc(%rsp),%rbx
lea    0x10(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <findPattern@plt>
lea    0xe98(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [19 x i8] c"TEST: findPattern\0A\00"
@__const.test_findPattern.input = [17 x i8] c"This is a test!\0A\00"
@__const.test_findPattern.pattern = [3 x i8] c"es\00"
@.str.1 = [51 x i8] c"The position of pattern \22%s\22 in input \22%s\22 is: %d\0A\00"
define void @test_findPattern() {
%1 = alloca [17 x i8]
%2 = alloca [3 x i8]
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%4 = bitcast [17 x i8]* %1 to i8*
%5 = bitcast [3 x i8]* %2 to i8*
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [17 x i8], [17 x i8]* %1, i64 0, i64 0
%8 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [17 x i8], [17 x i8]* %1, i64 0, i64 0
%10 = call i32 @findPattern(i8* %8, i8* %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i8* %6, i8* %7, i32 %10)
ret void
}

LLVM IR (-O2):
@__const.test_findPattern.input = [17 x i8] c"This is a test!\0A\00"
@__const.test_findPattern.pattern = [3 x i8] c"es\00"
@.str.1 = [51 x i8] c"The position of pattern \22%s\22 in input \22%s\22 is: %d\0A\00"
@str = [18 x i8] c"TEST: findPattern\00"
define void @test_findPattern() {
%1 = alloca [17 x i8]
%2 = alloca [3 x i8]
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%4 = getelementptr inbounds [17 x i8], [17 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%6 = call i32 @findPattern(i8* %5, i8* %4)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i8* %5, i8* %4, i32 %6)
ret void
}