#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 *, char);
char *mprGetBaseName(char *name) {
  char *cp;
  cp = strrchr(name, '/');
  if (cp == 0) {
    cp = strrchr(name, '\\');
    if (cp == 0) {
      return name;
    }
  }
  if (cp == name) {
    if (cp[1] == '\0') {
      return name;
    }
  } else {
    if (cp[1] == '\0') {
      return "";
    }
  }
  return &cp[1];
}


x86 assembly (clang, -O0):
<mprGetBaseName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1168 <mprGetBaseName+0x58>
mov    -0x10(%rbp),%rdi
mov    $0x5c,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1163 <mprGetBaseName+0x53>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11cb <mprGetBaseName+0xbb>
jmp    1168 <mprGetBaseName+0x58>
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    1199 <mprGetBaseName+0x89>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    1194 <mprGetBaseName+0x84>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11cb <mprGetBaseName+0xbb>
jmp    11bf <mprGetBaseName+0xaf>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    11ba <mprGetBaseName+0xaa>
lea    0xe4f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cb <mprGetBaseName+0xbb>
jmp    11bf <mprGetBaseName+0xaf>
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):
<mprGetBaseName>:
push   %rbx
mov    %rdi,%rbx
mov    $0x2f,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
jne    1135 <mprGetBaseName+0x25>
mov    %rbx,%rdi
mov    $0x5c,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
je     1156 <mprGetBaseName+0x46>
cmp    %rbx,%rax
je     1149 <mprGetBaseName+0x39>
cmpb   $0x0,0x1(%rax)
jne    114f <mprGetBaseName+0x3f>
lea    0xeb9(%rip),%rbx
jmp    1156 <mprGetBaseName+0x46>
cmpb   $0x0,0x1(%rbx)
je     1156 <mprGetBaseName+0x46>
add    $0x1,%rax
mov    %rax,%rbx
mov    %rbx,%rax
pop    %rbx
ret

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

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