#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 strlen(char const *);
const char *parse_exename(const char *cmd) {
  const char *exename;
  for (exename = cmd + strlen(cmd); exename > cmd; --exename) {
    char pc = exename[-1];
    if (pc == ':' || pc == '/' || pc == '\\') {
      break;
    }
  }
  return exename;
}


x86 assembly (clang, -O0):
<parse_exename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jbe    1197 <parse_exename+0x87>
mov    -0x10(%rbp),%rax
mov    -0x1(%rax),%al
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x3a,%eax
je     117c <parse_exename+0x6c>
movsbl -0x11(%rbp),%eax
cmp    $0x2f,%eax
je     117c <parse_exename+0x6c>
movsbl -0x11(%rbp),%eax
cmp    $0x5c,%eax
jne    1181 <parse_exename+0x71>
jmp    1197 <parse_exename+0x87>
jmp    1186 <parse_exename+0x76>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    113d <parse_exename+0x2d>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_exename>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
movslq %eax,%rdx
add    %rbx,%rdx
movabs $0x200000000801,%rsi
nopl   0x0(%rax)
mov    %rdx,%rax
cmp    %rbx,%rdx
jbe    1151 <parse_exename+0x41>
lea    -0x1(%rax),%rdx
movzbl -0x1(%rax),%ecx
add    $0xd1,%cl
cmp    $0x2d,%cl
ja     1130 <parse_exename+0x20>
movzbl %cl,%ecx
bt     %rcx,%rsi
jae    1130 <parse_exename+0x20>
pop    %rbx
ret

LLVM IR (-O0):
define i8* @parse_exename(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %5, i64 %8
store i8* %9, i8** %3
br label %10
10: ; preds = %31, %1
%11 = load i8*, i8** %3
%12 = load i8*, i8** %2
%13 = icmp ugt i8* %11, %12
br i1 %13, label %14, label %34
14: ; preds = %10
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i64 -1
%17 = load i8, i8* %16
store i8 %17, i8* %4
%18 = load i8, i8* %4
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 58
br i1 %20, label %29, label %21
21: ; preds = %14
%22 = load i8, i8* %4
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 47
br i1 %24, label %29, label %25
25: ; preds = %21
%26 = load i8, i8* %4
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 92
br i1 %28, label %29, label %30
29: ; preds = %25, %21, %14
br label %34
30: ; preds = %25
br label %31
31: ; preds = %30
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i32 -1
store i8* %33, i8** %3
br label %10
34: ; preds = %29, %10
%35 = load i8*, i8** %3
ret i8* %35
}

LLVM IR (-O2):
define i8* @parse_exename(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = sext i32 %2 to i64
%4 = getelementptr inbounds i8, i8* %0, i64 %3
br label %5
5: ; preds = %8, %1
%6 = phi i8* [ %4, %1 ], [ %9, %8 ]
%7 = icmp ugt i8* %6, %0
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = getelementptr inbounds i8, i8* %6, i64 -1
%10 = load i8, i8* %9
switch i8 %10, label %5 [
i8 92, label %11
i8 58, label %11
i8 47, label %11
]
11: ; preds = %8, %8, %8, %5
ret i8* %6
}