#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 *, ...);
scalar_t__ stpsearch(char *, int, char *);
int strsize(char *);
void strsearch(char str1[], char str2[]) {
  int i, size;
  size = strsize(str2);
  for (i = 0; str1[i] != '\0'; i++) {
    if (str1[i] == str2[0]) {
      if (stpsearch(str1, i, str2)) {
        printf("%d ", i);
        i += size;
      }
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<strsearch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strsize@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11cf <strsearch+0x9f>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x10(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11bc <strsearch+0x8c>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1050 <stpsearch@plt>
cmp    $0x0,%rax
je     11b7 <strsearch+0x87>
mov    -0x14(%rbp),%esi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11bc <strsearch+0x8c>
jmp    11c1 <strsearch+0x91>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1153 <strsearch+0x23>
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strsearch>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1050 <strsize@plt>
mov    %eax,%r12d
mov    (%rbx),%al
test   %al,%al
je     11a8 <strsearch+0x68>
lea    0xe9a(%rip),%r15
xor    %ebp,%ebp
jmp    1180 <strsearch+0x40>
nopw   0x0(%rax,%rax,1)
movslq %ebp,%rbp
movzbl 0x1(%rbx,%rbp,1),%eax
add    $0x1,%rbp
test   %al,%al
je     11a8 <strsearch+0x68>
cmp    (%r14),%al
jne    1170 <strsearch+0x30>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
call   1060 <stpsearch@plt>
test   %rax,%rax
je     1170 <strsearch+0x30>
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    %r12d,%ebp
jmp    1170 <strsearch+0x30>
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

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