#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 *);
char *mutilsBasename(char *path) {
  char *cptr;
  for (cptr = path + strlen(path); cptr >= path; --cptr) {
    switch (*cptr) {
    case ':':
    case '/':
    case '\\':
      return ++cptr;
    }
  }
  return (path);
}


x86 assembly (clang, -O0):
<mutilsBasename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jb     11b0 <mutilsBasename+0xa0>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x24(%rbp)
sub    $0x2f,%eax
je     1185 <mutilsBasename+0x75>
jmp    1163 <mutilsBasename+0x53>
mov    -0x24(%rbp),%eax
sub    $0x3a,%eax
je     1185 <mutilsBasename+0x75>
jmp    1174 <mutilsBasename+0x64>
mov    -0x24(%rbp),%eax
sub    $0x5c,%eax
jne    119a <mutilsBasename+0x8a>
jmp    1185 <mutilsBasename+0x75>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    %rax,-0x8(%rbp)
jmp    11b8 <mutilsBasename+0xa8>
jmp    119f <mutilsBasename+0x8f>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    113d <mutilsBasename+0x2d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mutilsBasename>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
js     1151 <mutilsBasename+0x41>
mov    %eax,%eax
add    %rbx,%rax
movabs $0x200000000801,%rcx
jmp    1139 <mutilsBasename+0x29>
xchg   %ax,%ax
add    $0xffffffffffffffff,%rax
cmp    %rbx,%rax
jb     1151 <mutilsBasename+0x41>
movsbl (%rax),%edx
add    $0xffffffd1,%edx
cmp    $0x2d,%edx
ja     1130 <mutilsBasename+0x20>
bt     %rdx,%rcx
jae    1130 <mutilsBasename+0x20>
add    $0x1,%rax
mov    %rax,%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @mutilsBasename(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 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %5, i64 %8
store i8* %9, i8** %4
br label %10
10: ; preds = %22, %1
%11 = load i8*, i8** %4
%12 = load i8*, i8** %3
%13 = icmp uge i8* %11, %12
br i1 %13, label %14, label %25
14: ; preds = %10
%15 = load i8*, i8** %4
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
switch i32 %17, label %21 [
i32 58, label %18
i32 47, label %18
i32 92, label %18
]
18: ; preds = %14, %14, %14
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %4
store i8* %20, i8** %2
br label %27
21: ; preds = %14
br label %22
22: ; preds = %21
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i32 -1
store i8* %24, i8** %4
br label %10
25: ; preds = %10
%26 = load i8*, i8** %3
store i8* %26, i8** %2
br label %27
27: ; preds = %25, %18
%28 = load i8*, i8** %2
ret i8* %28
}

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