#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 */
char *strstr(char const *, char const *);
const char *initial_strstr(const char *str, const char *sub_str) {
  const char *sub_str_occ = str;
  while ((sub_str_occ = strstr(sub_str_occ, sub_str)) != NULL) {
    if (sub_str_occ != str) {
      char prev_char = *(sub_str_occ - 1);
      if (prev_char != ' ')
        sub_str_occ++;
      else
        break;
    } else
      break;
  }
  return (sub_str_occ);
}


x86 assembly (clang, -O0):
<initial_strstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     118d <initial_strstr+0x7d>
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
je     1183 <initial_strstr+0x73>
mov    -0x18(%rbp),%rax
mov    -0x1(%rax),%al
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x20,%eax
je     1179 <initial_strstr+0x69>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    117e <initial_strstr+0x6e>
jmp    118d <initial_strstr+0x7d>
jmp    1188 <initial_strstr+0x78>
jmp    118d <initial_strstr+0x7d>
jmp    1128 <initial_strstr+0x18>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initial_strstr>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rsi
call   1030 <strstr@plt>
test   %rax,%rax
je     1141 <initial_strstr+0x31>
cmp    %rbx,%rax
je     1145 <initial_strstr+0x35>
mov    %rax,%rdi
add    $0x1,%rdi
cmpb   $0x20,-0x1(%rax)
jne    1120 <initial_strstr+0x10>
jmp    1148 <initial_strstr+0x38>
xor    %eax,%eax
jmp    1148 <initial_strstr+0x38>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @initial_strstr(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
store i8* %7, i8** %5
br label %8
8: ; preds = %30, %2
%9 = load i8*, i8** %5
%10 = load i8*, i8** %4
%11 = call i8* @strstr(i8* %9, i8* %10)
store i8* %11, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %31
13: ; preds = %8
%14 = load i8*, i8** %5
%15 = load i8*, i8** %3
%16 = icmp ne i8* %14, %15
br i1 %16, label %17, label %29
17: ; preds = %13
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i64 -1
%20 = load i8, i8* %19
store i8 %20, i8* %6
%21 = load i8, i8* %6
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 32
br i1 %23, label %24, label %27
24: ; preds = %17
%25 = load i8*, i8** %5
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %5
br label %28
27: ; preds = %17
br label %31
28: ; preds = %24
br label %30
29: ; preds = %13
br label %31
30: ; preds = %28
br label %8
31: ; preds = %29, %27, %8
%32 = load i8*, i8** %5
ret i8* %32
}

LLVM IR (-O2):
define i8* @initial_strstr(i8* %0, i8* nocapture %1) {
br label %3
3: ; preds = %9, %2
%4 = phi i8* [ %0, %2 ], [ %13, %9 ]
%5 = tail call i8* @strstr(i8* dereferenceable(1) %4, i8* dereferenceable(1) %1)
%6 = icmp eq i8* %5, null
br i1 %6, label %14, label %7
7: ; preds = %3
%8 = icmp eq i8* %5, %0
br i1 %8, label %14, label %9
9: ; preds = %7
%10 = getelementptr inbounds i8, i8* %5, i64 -1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 32
%13 = getelementptr inbounds i8, i8* %5, i64 1
br i1 %12, label %14, label %3
14: ; preds = %9, %7, %3
%15 = phi i8* [ %5, %9 ], [ %0, %7 ], [ null, %3 ]
ret i8* %15
}