#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 */
scalar_t__ strrchr(char const *, char);
scalar_t__ strstr(char const *, char *);
char *file_get_name(const char *full_filename) {
  char *filename;
  if (strstr(full_filename, "/")) {
    filename = (char *)strrchr(full_filename, '/');
  } else {
    filename = (char *)strrchr(full_filename, '/');
  }
  if (filename) {
    return ++filename;
  }
  return "";
}


x86 assembly (clang, -O0):
<file_get_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec9(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     115d <file_get_name+0x3d>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x18(%rbp)
jmp    116f <file_get_name+0x4f>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     118f <file_get_name+0x6f>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    %rax,-0x8(%rbp)
jmp    119a <file_get_name+0x7a>
lea    0xe6b(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_get_name>:
push   %rbx
mov    %rdi,%rbx
lea    0xed5(%rip),%rsi
call   1040 <strstr@plt>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
lea    0x1(%rax),%rcx
test   %rax,%rax
lea    0xeb6(%rip),%rax
cmovne %rcx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
@.str.1 = [1 x i8] zeroinitializer
define i8* @file_get_name(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i64 @strstr(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i64 @strrchr(i8* %9, i8 signext 47)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %4
br label %16
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = call i64 @strrchr(i8* %13, i8 signext 47)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %4
br label %16
16: ; preds = %12, %8
%17 = load i8*, i8** %4
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i8*, i8** %4
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %4
store i8* %21, i8** %2
br label %23
22: ; preds = %16
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %23
23: ; preds = %22, %19
%24 = load i8*, i8** %2
ret i8* %24
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
@.str.1 = [1 x i8] zeroinitializer
define i8* @file_get_name(i8* %0) {
%2 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = tail call i64 @strrchr(i8* %0, i8 signext 47)
%4 = icmp eq i64 %3, 0
%5 = inttoptr i64 %3 to i8*
%6 = getelementptr inbounds i8, i8* %5, i64 1
%7 = select i1 %4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* %6
ret i8* %7
}