#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*/ strchr(char const *, char);
int strlen(char const *);
const char *_pico_nopath(const char *path) {
  const char *src;
  src = path + (strlen(path) - 1);
  if (path == NULL)
    return "";
  if (!strchr(path, '/') && !strchr(path, '\\'))
    return (path);
  while ((src--) != path) {
    if (*src == '/' || *src == '\\')
      return (++src);
  }
  return "";
}


x86 assembly (clang, -O0):
<_pico_nopath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    116b <_pico_nopath+0x4b>
lea    0xe9e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1209 <_pico_nopath+0xe9>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
cmp    $0x0,%eax
jne    11a6 <_pico_nopath+0x86>
mov    -0x10(%rbp),%rdi
mov    $0x5c,%esi
call   1040 <strchr@plt>
cmp    $0x0,%eax
jne    11a6 <_pico_nopath+0x86>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1209 <_pico_nopath+0xe9>
jmp    11ab <_pico_nopath+0x8b>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
cmp    -0x10(%rbp),%rax
je     11fe <_pico_nopath+0xde>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     11e4 <_pico_nopath+0xc4>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    11f9 <_pico_nopath+0xd9>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    %rax,-0x8(%rbp)
jmp    1209 <_pico_nopath+0xe9>
jmp    11ab <_pico_nopath+0x8b>
lea    0xdfb(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_pico_nopath>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
lea    0xecd(%rip),%r14
test   %rbx,%rbx
je     118d <_pico_nopath+0x6d>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
test   %eax,%eax
jne    115c <_pico_nopath+0x3c>
mov    %rbx,%rdi
mov    $0x5c,%esi
call   1040 <strchr@plt>
test   %eax,%eax
je     1190 <_pico_nopath+0x70>
add    $0xffffffff,%ebp
movslq %ebp,%rax
add    %rax,%rbx
add    $0x1,%rbx
nopl   0x0(%rax)
test   %rax,%rax
je     118d <_pico_nopath+0x6d>
movzbl -0x2(%rbx),%ecx
add    $0xffffffffffffffff,%rbx
cmp    $0x5c,%cl
je     1190 <_pico_nopath+0x70>
add    $0xffffffffffffffff,%rax
cmp    $0x2f,%cl
jne    1170 <_pico_nopath+0x50>
jmp    1190 <_pico_nopath+0x70>
mov    %r14,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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