#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 *ExtractFileName(const char *_path) {
  if (NULL == _path)
    return "";
  const char *pos = strrchr(_path, '\\');
  if (NULL == pos) {
    pos = strrchr(_path, '/');
  }
  if (NULL == pos || '\0' == *(pos + 1)) {
    return _path;
  } else {
    return pos + 1;
  }
}


x86 assembly (clang, -O0):
<ExtractFileName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    1138 <ExtractFileName+0x28>
lea    0xed1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119f <ExtractFileName+0x8f>
mov    -0x10(%rbp),%rdi
mov    $0x5c,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    1168 <ExtractFileName+0x58>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
je     1186 <ExtractFileName+0x76>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    1193 <ExtractFileName+0x83>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    119f <ExtractFileName+0x8f>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ExtractFileName>:
push   %rbx
test   %rdi,%rdi
je     1148 <ExtractFileName+0x38>
mov    %rdi,%rbx
mov    $0x5c,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
jne    113a <ExtractFileName+0x2a>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
je     114f <ExtractFileName+0x3f>
lea    0x1(%rax),%rcx
cmpb   $0x0,0x1(%rax)
cmovne %rcx,%rbx
jmp    114f <ExtractFileName+0x3f>
lea    0xeb1(%rip),%rbx
mov    %rbx,%rax
pop    %rbx
ret

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

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