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


x86 assembly (clang, -O0):
<getFilename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     114a <getFilename+0x3a>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11b8 <getFilename+0xa8>
mov    -0x10(%rbp),%rdi
mov    $0x5c,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1178 <getFilename+0x68>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11b8 <getFilename+0xa8>
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11a6 <getFilename+0x96>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11b8 <getFilename+0xa8>
jmp    11ab <getFilename+0x9b>
jmp    11b0 <getFilename+0xa0>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getFilename>:
push   %rbx
mov    %rdi,%rbx
mov    $0x2f,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
jne    1135 <getFilename+0x25>
mov    %rbx,%rdi
mov    $0x5c,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
je     113b <getFilename+0x2b>
add    $0x1,%rax
pop    %rbx
ret
mov    %rbx,%rdi
mov    $0x3a,%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* @getFilename(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i8* @strrchr(i8* %5, i8 signext 47)
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i64 1
store i8* %11, i8** %2
br label %32
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = call i8* @strrchr(i8* %13, i8 signext 92)
store i8* %14, i8** %4
%15 = load i8*, i8** %4
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i64 1
store i8* %19, i8** %2
br label %32
20: ; preds = %12
%21 = load i8*, i8** %3
%22 = call i8* @strrchr(i8* %21, i8 signext 58)
store i8* %22, i8** %4
%23 = load i8*, i8** %4
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i64 1
store i8* %27, i8** %2
br label %32
28: ; preds = %20
br label %29
29: ; preds = %28
br label %30
30: ; preds = %29
%31 = load i8*, i8** %3
store i8* %31, i8** %2
br label %32
32: ; preds = %30, %25, %17, %9
%33 = load i8*, i8** %2
ret i8* %33
}

LLVM IR (-O2):
define i8* @getFilename(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 %16
6: ; preds = %1
%7 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 92)
%8 = icmp eq i8* %7, null
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = getelementptr inbounds i8, i8* %7, i64 1
br label %16
11: ; preds = %6
%12 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 58)
%13 = icmp eq i8* %12, null
%14 = getelementptr inbounds i8, i8* %12, i64 1
%15 = select i1 %13, i8* %0, i8* %14
br label %16
16: ; preds = %11, %9, %4
%17 = phi i8* [ %5, %4 ], [ %10, %9 ], [ %15, %11 ]
ret i8* %17
}