#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 const *, char);
int /*<<< orphan*/ strspn(char const *, char *);
const char *_cargo_strip_path_from_progname(const char *org_progname) {
  const char *progname;
  if (!(progname = strrchr(org_progname, '/'))) {
    if (!(progname = strrchr(org_progname, '\\'))) {
      progname = org_progname;
    }
  }
  progname += strspn(progname, "/\\");
  return progname;
}


x86 assembly (clang, -O0):
<_cargo_strip_path_from_progname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1171 <_cargo_strip_path_from_progname+0x51>
mov    -0x8(%rbp),%rdi
mov    $0x5c,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    116c <_cargo_strip_path_from_progname+0x4c>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1171 <_cargo_strip_path_from_progname+0x51>
mov    -0x10(%rbp),%rdi
lea    0xe84(%rip),%rsi
call   1040 <strspn@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_cargo_strip_path_from_progname>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x2f,%esi
call   1030 <strrchr@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1150 <_cargo_strip_path_from_progname+0x30>
mov    %r14,%rdi
mov    $0x5c,%esi
call   1030 <strrchr@plt>
mov    %rax,%rbx
test   %rax,%rax
cmove  %r14,%rbx
lea    0xea9(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strspn@plt>
cltq
add    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"/\\\00"
define i8* @_cargo_strip_path_from_progname(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i8* @strrchr(i8* %4, i8 signext 47)
store i8* %5, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %14, label %7
7: ; preds = %1
%8 = load i8*, i8** %2
%9 = call i8* @strrchr(i8* %8, i8 signext 92)
store i8* %9, i8** %3
%10 = icmp ne i8* %9, null
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = load i8*, i8** %2
store i8* %12, i8** %3
br label %13
13: ; preds = %11, %7
br label %14
14: ; preds = %13, %1
%15 = load i8*, i8** %3
%16 = call i32 @strspn(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%17 = load i8*, i8** %3
%18 = sext i32 %16 to i64
%19 = getelementptr inbounds i8, i8* %17, i64 %18
store i8* %19, i8** %3
%20 = load i8*, i8** %3
ret i8* %20
}

LLVM IR (-O2):
@.str = [3 x i8] c"/\\\00"
define i8* @_cargo_strip_path_from_progname(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 %8
4: ; preds = %1
%5 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 92)
%6 = icmp eq i8* %5, null
%7 = select i1 %6, i8* %0, i8* %5
br label %8
8: ; preds = %4, %1
%9 = phi i8* [ %2, %1 ], [ %7, %4 ]
%10 = tail call i32 @strspn(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
ret i8* %12
}