#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 *index(char *, char);
char *index_without_escape(char *str, char c) {
  char *tmp = index(str, c);
  if (tmp == str)
    return tmp;
  while (tmp != NULL) {
    if (*(tmp - 1) != '\\')
      return tmp;
    tmp = index(tmp + 1, c);
  }
  return NULL;
}


x86 assembly (clang, -O0):
<index_without_escape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rdi
movsbl -0x11(%rbp),%esi
call   1030 <index@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    114e <index_without_escape+0x3e>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    119e <index_without_escape+0x8e>
jmp    1153 <index_without_escape+0x43>
cmpq   $0x0,-0x20(%rbp)
je     1196 <index_without_escape+0x86>
mov    -0x20(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x5c,%eax
je     117c <index_without_escape+0x6c>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    119e <index_without_escape+0x8e>
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
movsbl -0x11(%rbp),%esi
call   1030 <index@plt>
mov    %rax,-0x20(%rbp)
jmp    1153 <index_without_escape+0x43>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<index_without_escape>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <index@plt>
cmp    %rbx,%rax
je     114e <index_without_escape+0x3e>
test   %rax,%rax
je     114c <index_without_escape+0x3c>
movsbl %bpl,%ebp
mov    %rax,%rbx
xchg   %ax,%ax
cmpb   $0x5c,-0x1(%rbx)
jne    114e <index_without_escape+0x3e>
add    $0x1,%rbx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <index@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1130 <index_without_escape+0x20>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define i8* @index_without_escape(i8* %0, i8 signext %1) {
%3 = tail call i8* @index(i8* %0, i8 signext %1)
%4 = icmp eq i8* %3, %0
br i1 %4, label %16, label %5
5: ; preds = %2
%6 = icmp eq i8* %3, null
br i1 %6, label %16, label %7
7: ; preds = %5, %12
%8 = phi i8* [ %14, %12 ], [ %3, %5 ]
%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 %16
12: ; preds = %7
%13 = getelementptr inbounds i8, i8* %8, i64 1
%14 = tail call i8* @index(i8* %13, i8 signext %1)
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %7
16: ; preds = %7, %12, %5, %2
%17 = phi i8* [ %0, %2 ], [ null, %5 ], [ %8, %7 ], [ null, %12 ]
ret i8* %17
}