#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 *StripPath(char *pathname) {
  char *filename = pathname;
  if (filename && *filename) {
    filename = strrchr(filename, '/');
    if (filename)
      if (*(++filename))
        return filename;
      else
        return NULL;
    else
      return pathname;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<StripPath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     119c <StripPath+0x8c>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     119c <StripPath+0x8c>
mov    -0x18(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     118f <StripPath+0x7f>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
cmpb   $0x0,0x1(%rax)
je     1182 <StripPath+0x72>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11a4 <StripPath+0x94>
movq   $0x0,-0x8(%rbp)
jmp    11a4 <StripPath+0x94>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11a4 <StripPath+0x94>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<StripPath>:
push   %rbx
test   %rdi,%rdi
je     1143 <StripPath+0x33>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     1143 <StripPath+0x33>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
je     1145 <StripPath+0x35>
mov    %rax,%rcx
add    $0x1,%rcx
xor    %ebx,%ebx
cmpb   $0x0,0x1(%rax)
cmovne %rcx,%rbx
jmp    1145 <StripPath+0x35>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
ret

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

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