#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 *strrchr(char const *, char);
const char *opt_strip_path(const char *full_name) {
  const char *last_path_delim, *stripped_name = full_name;
  last_path_delim = strrchr(stripped_name, '\\');
  if (last_path_delim > stripped_name)
    stripped_name = last_path_delim + 1;
  last_path_delim = strrchr(stripped_name, '/');
  if (last_path_delim > stripped_name)
    stripped_name = last_path_delim + 1;
  return stripped_name;
}


x86 assembly (clang, -O0):
<opt_strip_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x5c,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    1150 <opt_strip_path+0x40>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    117c <opt_strip_path+0x6c>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<opt_strip_path>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x5c,%esi
call   1030 <strrchr@plt>
lea    0x1(%rax),%rbx
cmp    %r14,%rax
cmovbe %r14,%rbx
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
lea    0x1(%rax),%rcx
cmp    %rbx,%rax
cmovbe %rbx,%rcx
mov    %rcx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @opt_strip_path(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
store i8* %5, i8** %4
%6 = load i8*, i8** %4
%7 = call i8* @strrchr(i8* %6, i8 signext 92)
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = load i8*, i8** %4
%10 = icmp ugt i8* %8, %9
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 1
store i8* %13, i8** %4
br label %14
14: ; preds = %11, %1
%15 = load i8*, i8** %4
%16 = call i8* @strrchr(i8* %15, i8 signext 47)
store i8* %16, i8** %3
%17 = load i8*, i8** %3
%18 = load i8*, i8** %4
%19 = icmp ugt i8* %17, %18
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i64 1
store i8* %22, i8** %4
br label %23
23: ; preds = %20, %14
%24 = load i8*, i8** %4
ret i8* %24
}

LLVM IR (-O2):
define i8* @opt_strip_path(i8* %0) {
%2 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 92)
%3 = icmp ugt i8* %2, %0
%4 = getelementptr inbounds i8, i8* %2, i64 1
%5 = select i1 %3, i8* %4, i8* %0
%6 = tail call i8* @strrchr(i8* dereferenceable(1) %5, i8 signext 47)
%7 = icmp ugt i8* %6, %5
%8 = getelementptr inbounds i8, i8* %6, i64 1
%9 = select i1 %7, i8* %8, i8* %5
ret i8* %9
}