#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 strlen(char *);
char *strstr(char *, char *);
char *strstr_escape(char *big, char *little) {
  char *c;
  c = strstr(big, little);
  while (c != NULL && c != big && c[-1] == '\\') {
    c = strstr(c + strlen(little), little);
  }
  return c;
}


x86 assembly (clang, -O0):
<strstr_escape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x19(%rbp)
je     1175 <strstr_escape+0x55>
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x19(%rbp)
je     1175 <strstr_escape+0x55>
mov    -0x18(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x5c,%eax
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1185 <strstr_escape+0x65>
jmp    11b1 <strstr_escape+0x91>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
cltq
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x18(%rbp)
jmp    1141 <strstr_escape+0x21>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strstr_escape>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
nopl   0x0(%rax,%rax,1)
call   1040 <strstr@plt>
mov    %rax,%rbx
test   %rax,%rax
je     115d <strstr_escape+0x3d>
cmp    %r15,%rbx
je     115d <strstr_escape+0x3d>
cmpb   $0x5c,-0x1(%rbx)
jne    115d <strstr_escape+0x3d>
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
add    %rax,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
jmp    1130 <strstr_escape+0x10>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i8* @strstr_escape(i8* %0, i8* %1) {
%3 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) %1)
%4 = icmp eq i8* %3, null
%5 = icmp eq i8* %3, %0
%6 = or i1 %4, %5
br i1 %6, label %20, label %7
7: ; preds = %2, %12
%8 = phi i8* [ %16, %12 ], [ %3, %2 ]
%9 = getelementptr inbounds i8, i8* %8, i64 -1
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 92
br i1 %11, label %12, label %20
12: ; preds = %7
%13 = tail call i32 @strlen(i8* %1)
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %8, i64 %14
%16 = tail call i8* @strstr(i8* %15, i8* dereferenceable(1) %1)
%17 = icmp eq i8* %16, null
%18 = icmp eq i8* %16, %0
%19 = or i1 %17, %18
br i1 %19, label %20, label %7
20: ; preds = %7, %12, %2
%21 = phi i8* [ %3, %2 ], [ %16, %12 ], [ %8, %7 ]
ret i8* %21
}