#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 */
scalar_t__ isalpha(char const);
char *basename(const char *name) {
  const char *base;
  if (isalpha(name[0]) && name[1] == ':')
    name += 2;
  for (base = name; *name; name++)
    if (*name == '/' || *name == '\\')
      base = name + 1;
  return (char *)base;
}


x86 assembly (clang, -O0):
<basename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isalpha@plt>
cmp    $0x0,%rax
je     114f <basename+0x3f>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x3a,%eax
jne    114f <basename+0x3f>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11a6 <basename+0x96>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     1184 <basename+0x74>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    1190 <basename+0x80>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1195 <basename+0x85>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1157 <basename+0x47>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<basename>:
push   %rbx
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1030 <isalpha@plt>
test   %rax,%rax
je     112e <basename+0x1e>
xor    %eax,%eax
cmpb   $0x3a,0x1(%rbx)
sete   %al
lea    (%rbx,%rax,2),%rbx
lea    0x1(%rbx),%rax
jmp    1147 <basename+0x37>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rax,%rbx
add    $0x1,%rax
movzbl -0x1(%rax),%ecx
cmp    $0x2f,%cl
je     1140 <basename+0x30>
cmp    $0x5c,%cl
je     1140 <basename+0x30>
test   %cl,%cl
jne    1143 <basename+0x33>
mov    %rbx,%rax
pop    %rbx
ret

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

LLVM IR (-O2):
define i8* @basename(i8* %0) {
%2 = load i8, i8* %0
%3 = tail call i64 @isalpha(i8 signext %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %11, label %5
5: ; preds = %1
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 58
%9 = select i1 %8, i64 2, i64 0
%10 = getelementptr i8, i8* %0, i64 %9
br label %11
11: ; preds = %5, %1
%12 = phi i8* [ %10, %5 ], [ %0, %1 ]
br label %13
13: ; preds = %11, %19
%14 = phi i8* [ %21, %19 ], [ %12, %11 ]
%15 = phi i8* [ %20, %19 ], [ %12, %11 ]
%16 = load i8, i8* %14
switch i8 %16, label %19 [
i8 0, label %22
i8 47, label %17
i8 92, label %17
]
17: ; preds = %13, %13
%18 = getelementptr inbounds i8, i8* %14, i64 1
br label %19
19: ; preds = %13, %17
%20 = phi i8* [ %18, %17 ], [ %15, %13 ]
%21 = getelementptr inbounds i8, i8* %14, i64 1
br label %13
22: ; preds = %13
ret i8* %15
}