#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 strlen(char *);
void search(char inp[], char searchstr[], int l) {
  int i, j, state;
  i = 0;
  while (i >= 0 && i <= strlen(inp)) {
    ++i;
    j = 0;
    while (inp[i - 1] == searchstr[j]) {
      ++j;
      printf("match");
    }
  }
}


x86 assembly (clang, -O0):
<search>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x18(%rbp)
mov    %al,-0x21(%rbp)
jl     1165 <search+0x45>
mov    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
setle  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1175 <search+0x55>
jmp    11c9 <search+0xa9>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x10(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    11c4 <search+0xa4>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
lea    0xe46(%rip),%rdi
call   1040 <printf@plt>
jmp    1185 <search+0x65>
jmp    113a <search+0x1a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r13
call   1030 <strlen@plt>
test   %eax,%eax
js     119c <search+0x7c>
lea    0x1(%r14),%r12
xor    %ebx,%ebx
lea    0xeb9(%rip),%r15
jmp    1166 <search+0x46>
nopl   0x0(%rax)
lea    0x1(%rbx),%rbp
mov    %r13,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
mov    %rbp,%rbx
jge    119c <search+0x7c>
mov    0x0(%r13,%rbx,1),%al
cmp    (%r14),%al
jne    1150 <search+0x30>
mov    %r12,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
call   1040 <printf@plt>
movzbl 0x0(%r13,%rbx,1),%eax
lea    0x1(%rbp),%rcx
cmp    0x0(%rbp),%al
mov    %rcx,%rbp
je     1180 <search+0x60>
jmp    1150 <search+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"match\00"
define void @search(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %10
10: ; preds = %42, %3
%11 = load i32, i32* %7
%12 = icmp sge i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load i32, i32* %7
%15 = load i8*, i8** %4
%16 = call i32 @strlen(i8* %15)
%17 = icmp sle i32 %14, %16
br label %18
18: ; preds = %13, %10
%19 = phi i1 [ false, %10 ], [ %17, %13 ]
br i1 %19, label %20, label %43
20: ; preds = %18
%21 = load i32, i32* %7
%22 = add nsw i32 %21, 1
store i32 %22, i32* %7
store i32 0, i32* %8
br label %23
23: ; preds = %38, %20
%24 = load i8*, i8** %4
%25 = load i32, i32* %7
%26 = sub nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %24, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = load i8*, i8** %5
%32 = load i32, i32* %8
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %30, %36
br i1 %37, label %38, label %42
38: ; preds = %23
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 1
store i32 %40, i32* %8
%41 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %23
42: ; preds = %23
br label %10
43: ; preds = %18
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"match\00"
define void @search(i8* %0, i8* nocapture %1, i32 %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp slt i32 %4, 0
br i1 %5, label %25, label %10
6: ; preds = %17, %10
%7 = tail call i32 @strlen(i8* %0)
%8 = sext i32 %7 to i64
%9 = icmp slt i64 %11, %8
br i1 %9, label %10, label %25
10: ; preds = %3, %6
%11 = phi i64 [ %12, %6 ], [ 0, %3 ]
%12 = add nuw nsw i64 %11, 1
%13 = getelementptr inbounds i8, i8* %0, i64 %11
%14 = load i8, i8* %13
%15 = load i8, i8* %1
%16 = icmp eq i8 %14, %15
br i1 %16, label %17, label %6
17: ; preds = %10, %17
%18 = phi i64 [ %19, %17 ], [ 0, %10 ]
%19 = add nuw i64 %18, 1
%20 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%21 = load i8, i8* %13
%22 = getelementptr inbounds i8, i8* %1, i64 %19
%23 = load i8, i8* %22
%24 = icmp eq i8 %21, %23
br i1 %24, label %17, label %6
25: ; preds = %6, %3
ret void
}