#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;
  if (path == NULL) {
    return "";
  }
  if (!strchr(path, '/') && !strchr(path, '\\')) {
    return (path);
  }
  src = path + (strlen(path) - 1);
  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)
cmpq   $0x0,-0x10(%rbp)
jne    1147 <_pico_nopath+0x27>
lea    0xec2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1204 <_pico_nopath+0xe4>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
cmp    $0x0,%eax
jne    1182 <_pico_nopath+0x62>
mov    -0x10(%rbp),%rdi
mov    $0x5c,%esi
call   1040 <strchr@plt>
cmp    $0x0,%eax
jne    1182 <_pico_nopath+0x62>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1204 <_pico_nopath+0xe4>
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)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
cmp    -0x10(%rbp),%rax
je     11f9 <_pico_nopath+0xd9>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     11df <_pico_nopath+0xbf>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    11f4 <_pico_nopath+0xd4>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    %rax,-0x8(%rbp)
jmp    1204 <_pico_nopath+0xe4>
jmp    11a6 <_pico_nopath+0x86>
lea    0xe00(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_pico_nopath>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%r14
test   %rdi,%rdi
je     118d <_pico_nopath+0x6d>
mov    %rdi,%rbx
mov    $0x2f,%esi
call   1040 <strchr@plt>
test   %eax,%eax
jne    1152 <_pico_nopath+0x32>
mov    %rbx,%rdi
mov    $0x5c,%esi
call   1040 <strchr@plt>
test   %eax,%eax
je     1190 <_pico_nopath+0x70>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
add    %rax,%rbx
add    $0xffffffffffffffff,%rbx
add    $0xffffffffffffffff,%rax
add    $0x1,%rbx
nopl   0x0(%rax,%rax,1)
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
add    $0x8,%rsp
pop    %rbx
pop    %r14
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 = icmp eq i8* %5, null
br i1 %6, label %7, label %8
7: ; preds = %1
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %2
br label %45
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32 @strchr(i8* %9, i8 signext 47)
%11 = icmp ne i32 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = call i32 @strchr(i8* %13, i8 signext 92)
%15 = icmp ne i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %12
%17 = load i8*, i8** %3
store i8* %17, i8** %2
br label %45
18: ; preds = %12, %8
%19 = load i8*, i8** %3
%20 = load i8*, i8** %3
%21 = call i32 @strlen(i8* %20)
%22 = sub nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %19, i64 %23
store i8* %24, i8** %4
br label %25
25: ; preds = %43, %18
%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, %16, %7
%46 = load i8*, i8** %2
ret i8* %46
}

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