#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 */
int /*<<< orphan*/ strcpy(char *const, char const *const);
char *strrchr(char const *const, int);
char *tinyfd_GetLastName(char *const aoDestination, char const *const aSource) {
  char const *lTmp = strrchr(aSource, (int)*"/");
  if (!lTmp) {
    lTmp = strrchr(aSource, (int)*"\\");
  }
  if (lTmp) {
    strcpy(aoDestination, lTmp + 1);
  } else {
    strcpy(aoDestination, aSource);
  }
  return aoDestination;
}


x86 assembly (clang, -O0):
<tinyfd_GetLastName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
movsbl 0xec5(%rip),%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1163 <tinyfd_GetLastName+0x43>
mov    -0x10(%rbp),%rdi
movsbl 0xea8(%rip),%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1184 <tinyfd_GetLastName+0x64>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
jmp    1191 <tinyfd_GetLastName+0x71>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tinyfd_GetLastName>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
jne    114e <tinyfd_GetLastName+0x2e>
mov    %rbx,%rdi
mov    $0x5c,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     1168 <tinyfd_GetLastName+0x48>
add    $0x1,%rax
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %r14,%rdi
mov    %rbx,%rsi
jmp    1158 <tinyfd_GetLastName+0x38>

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

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