#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 *strchr(char const *, char);
const char *bt_get_basename(const char *path) {
  const char *p = strchr(path, '\0') - 1;
  for (; p >= path && *p != '/' && *p != '\\'; p--)
    ;
  return (p + 1);
}


x86 assembly (clang, -O0):
<bt_get_basename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1030 <strchr@plt>
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x11(%rbp)
jb     1167 <bt_get_basename+0x57>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x2f,%ecx
mov    %al,-0x11(%rbp)
je     1167 <bt_get_basename+0x57>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1177 <bt_get_basename+0x67>
jmp    118d <bt_get_basename+0x7d>
jmp    117c <bt_get_basename+0x6c>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    112f <bt_get_basename+0x1f>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bt_get_basename>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
lea    (%rax,%rbx,1),%rcx
add    $0xffffffffffffffff,%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rcx,%rax
cmp    %rbx,%rcx
jb     1149 <bt_get_basename+0x39>
movzbl (%rax),%edx
cmp    $0x5c,%dl
je     1149 <bt_get_basename+0x39>
lea    -0x1(%rax),%rcx
cmp    $0x2f,%dl
jne    1130 <bt_get_basename+0x20>
add    $0x1,%rax
pop    %rbx
ret

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

LLVM IR (-O2):
define i8* @bt_get_basename(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = getelementptr i8, i8* %0, i64 %2
br label %4
4: ; preds = %8, %1
%5 = phi i8* [ %3, %1 ], [ %6, %8 ]
%6 = getelementptr inbounds i8, i8* %5, i64 -1
%7 = icmp ult i8* %6, %0
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = load i8, i8* %6
switch i8 %9, label %4 [
i8 47, label %10
i8 92, label %10
]
10: ; preds = %8, %8, %4
ret i8* %5
}