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


x86 assembly (clang, -O0):
<getLastName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11a1 <getLastName+0x81>
mov    -0x10(%rbp),%rdi
movsbl 0xeba(%rip),%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    116e <getLastName+0x4e>
mov    -0x10(%rbp),%rdi
movsbl 0xe9d(%rip),%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     118f <getLastName+0x6f>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
jmp    119c <getLastName+0x7c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11a8 <getLastName+0x88>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getLastName>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
test   %rsi,%rsi
je     1164 <getLastName+0x44>
mov    %rsi,%rbx
mov    %rsi,%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
jne    1153 <getLastName+0x33>
mov    %rbx,%rdi
mov    $0x5c,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     1173 <getLastName+0x53>
add    $0x1,%rax
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
jmp    1168 <getLastName+0x48>
movb   $0x0,(%r14)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %r14,%rdi
mov    %rbx,%rsi
jmp    115d <getLastName+0x3d>

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

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