#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 *, char);
char *files_get_filename_in_path(char *path) {
  char *filename;
  if (strrchr(path, '/')) {
    filename = strrchr(path, '/') + 1;
  } else if (strrchr(path, '\\')) {
    filename = strrchr(path, '\\') + 1;
  } else {
    filename = path;
  }
  return filename;
}


x86 assembly (clang, -O0):
<files_get_filename_in_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
cmp    $0x0,%rax
je     114f <files_get_filename_in_path+0x3f>
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    118f <files_get_filename_in_path+0x7f>
mov    -0x8(%rbp),%rdi
mov    $0x5c,%esi
call   1030 <strrchr@plt>
cmp    $0x0,%rax
je     1182 <files_get_filename_in_path+0x72>
mov    -0x8(%rbp),%rdi
mov    $0x5c,%esi
call   1030 <strrchr@plt>
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    118a <files_get_filename_in_path+0x7a>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    118f <files_get_filename_in_path+0x7f>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<files_get_filename_in_path>:
push   %rbx
mov    %rdi,%rbx
mov    $0x2f,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
je     1129 <files_get_filename_in_path+0x19>
add    $0x1,%rax
pop    %rbx
ret
mov    %rbx,%rdi
mov    $0x5c,%esi
call   1030 <strrchr@plt>
mov    %rax,%rcx
add    $0x1,%rax
test   %rcx,%rcx
cmove  %rbx,%rax
pop    %rbx
ret

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

LLVM IR (-O2):
define i8* @files_get_filename_in_path(i8* %0) {
%2 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 47)
%3 = icmp eq i8* %2, null
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %2, i64 1
br label %11
6: ; preds = %1
%7 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 92)
%8 = icmp eq i8* %7, null
%9 = getelementptr inbounds i8, i8* %7, i64 1
%10 = select i1 %8, i8* %0, i8* %9
br label %11
11: ; preds = %6, %4
%12 = phi i8* [ %5, %4 ], [ %10, %6 ]
ret i8* %12
}