#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 *FindFileName(const char *const fullPath) {
  int i;
  const char *start;
  const char *tmp;
  const char delim[3] = {'\\', '/', ':'};
  start = fullPath;
  for (i = 0; i < 3; i++) {
    tmp = strrchr(start, delim[i]);
    if (tmp != NULL) {
      start = tmp + 1;
    }
  }
  return (char *)start;
}


x86 assembly (clang, -O0):
<FindFileName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0xedd(%rip),%ax
mov    %ax,-0x23(%rbp)
mov    0xed5(%rip),%al
mov    %al,-0x21(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jge    1189 <FindFileName+0x79>
mov    -0x18(%rbp),%rdi
movslq -0xc(%rbp),%rax
movsbl -0x23(%rbp,%rax,1),%esi
call   1030 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1176 <FindFileName+0x66>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    117b <FindFileName+0x6b>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113f <FindFileName+0x2f>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@__const.FindFileName.delim = [3 x i8] c"\\/:"
define i8* @FindFileName(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [3 x i8]
store i8* %0, i8** %2
%7 = bitcast [3 x i8]* %6 to i8*
%8 = load i8*, i8** %2
store i8* %8, i8** %4
store i32 0, i32* %3
br label %9
9: ; preds = %25, %1
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 3
br i1 %11, label %12, label %28
12: ; preds = %9
%13 = load i8*, i8** %4
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = call i8* @strrchr(i8* %13, i8 signext %17)
store i8* %18, i8** %5
%19 = load i8*, i8** %5
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %24
21: ; preds = %12
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i64 1
store i8* %23, i8** %4
br label %24
24: ; preds = %21, %12
br label %25
25: ; preds = %24
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %9
28: ; preds = %9
%29 = load i8*, i8** %4
ret i8* %29
}

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