#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 *);
char *filespecname(const char *filespec) {
  register const char *p;
  for (p = filespec + strlen(filespec); p != filespec && !((*(p - 1)) == '/');
       p--)
    ;
  return (char *)p;
}


x86 assembly (clang, -O0):
<filespecname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x19(%rbp)
je     1163 <filespecname+0x53>
mov    -0x10(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x2f,%eax
sete   %al
xor    $0xff,%al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1173 <filespecname+0x63>
jmp    1189 <filespecname+0x79>
jmp    1178 <filespecname+0x68>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    113d <filespecname+0x2d>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filespecname>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
cltq
nopl   0x0(%rax,%rax,1)
test   %rax,%rax
je     113a <filespecname+0x2a>
lea    -0x1(%rax),%rcx
cmpb   $0x2f,-0x1(%rbx,%rax,1)
mov    %rcx,%rax
jne    1120 <filespecname+0x10>
add    %rcx,%rbx
add    $0x1,%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @filespecname(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strlen(i8* %5)
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %4, i64 %7
store i8* %8, i8** %3
br label %9
9: ; preds = %23, %1
%10 = load i8*, i8** %3
%11 = load i8*, i8** %2
%12 = icmp ne i8* %10, %11
br i1 %12, label %13, label %20
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i64 -1
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 47
%19 = xor i1 %18, true
br label %20
20: ; preds = %13, %9
%21 = phi i1 [ false, %9 ], [ %19, %13 ]
br i1 %21, label %22, label %26
22: ; preds = %20
br label %23
23: ; preds = %22
%24 = load i8*, i8** %3
%25 = getelementptr inbounds i8, i8* %24, i32 -1
store i8* %25, i8** %3
br label %9
26: ; preds = %20
%27 = load i8*, i8** %3
ret i8* %27
}

LLVM IR (-O2):
define i8* @filespecname(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 eq i8* %6, %0
br i1 %7, label %12, label %8
8: ; preds = %5
%9 = getelementptr inbounds i8, i8* %6, i64 -1
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 47
br i1 %11, label %12, label %5
12: ; preds = %5, %8
%13 = phi i8* [ %0, %5 ], [ %6, %8 ]
ret i8* %13
}