#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 *const, char);
const char *log_getFileNameOnly(char const *const fileName) {
  char const *fileNameOnly = NULL;
  if (NULL != fileName) {
    fileNameOnly = strrchr(fileName, '/');
    if (NULL == fileNameOnly) {
      fileNameOnly = strrchr(fileName, '\\');
    }
    if (NULL == fileNameOnly) {
      fileNameOnly = fileName;
    } else {
      fileNameOnly++;
    }
  }
  return fileNameOnly;
}


x86 assembly (clang, -O0):
<log_getFileNameOnly>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
xor    %eax,%eax
cmp    -0x8(%rbp),%rax
je     118a <log_getFileNameOnly+0x7a>
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    1160 <log_getFileNameOnly+0x50>
mov    -0x8(%rbp),%rdi
mov    $0x5c,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    1179 <log_getFileNameOnly+0x69>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1185 <log_getFileNameOnly+0x75>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    118a <log_getFileNameOnly+0x7a>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_getFileNameOnly>:
test   %rdi,%rdi
je     1145 <log_getFileNameOnly+0x35>
push   %rbx
mov    %rdi,%rbx
mov    $0x2f,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
jne    1135 <log_getFileNameOnly+0x25>
mov    %rbx,%rdi
mov    $0x5c,%esi
call   1030 <strrchr@plt>
lea    0x1(%rax),%rcx
test   %rax,%rax
cmove  %rbx,%rcx
pop    %rbx
mov    %rcx,%rax
ret
xor    %ecx,%ecx
mov    %rcx,%rax
ret

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

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