#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__ HAVE_DRIVE(char *);
int strlen(char *);
char *filename_non_directory(char *pathname) {
  register char *filename = pathname + strlen(pathname);
  if (HAVE_DRIVE(pathname))
    pathname += 2;
  while (filename > pathname && !((filename[-1]) == '/'))
    filename--;
  return (filename);
}


x86 assembly (clang, -O0):
<filename_non_directory>:
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   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <HAVE_DRIVE@plt>
cmp    $0x0,%rax
je     116c <filename_non_directory+0x4c>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
jmp    1171 <filename_non_directory+0x51>
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x19(%rbp)
jbe    1197 <filename_non_directory+0x77>
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    11a7 <filename_non_directory+0x87>
jmp    11b8 <filename_non_directory+0x98>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    1171 <filename_non_directory+0x51>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filename_non_directory>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <strlen@plt>
movslq %eax,%rbx
add    %r14,%rbx
mov    %r14,%rdi
call   1030 <HAVE_DRIVE@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    (%r14,%rcx,2),%rcx
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rax
cmp    %rcx,%rbx
jbe    1162 <filename_non_directory+0x42>
lea    -0x1(%rax),%rbx
cmpb   $0x2f,-0x1(%rax)
jne    1150 <filename_non_directory+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @filename_non_directory(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
%9 = load i8*, i8** %2
%10 = call i64 @HAVE_DRIVE(i8* %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %1
%13 = load i8*, i8** %2
%14 = getelementptr inbounds i8, i8* %13, i64 2
store i8* %14, i8** %2
br label %15
15: ; preds = %12, %1
br label %16
16: ; preds = %29, %15
%17 = load i8*, i8** %3
%18 = load i8*, i8** %2
%19 = icmp ugt i8* %17, %18
br i1 %19, label %20, label %27
20: ; preds = %16
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i64 -1
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 47
%26 = xor i1 %25, true
br label %27
27: ; preds = %20, %16
%28 = phi i1 [ false, %16 ], [ %26, %20 ]
br i1 %28, label %29, label %32
29: ; preds = %27
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i32 -1
store i8* %31, i8** %3
br label %16
32: ; preds = %27
%33 = load i8*, i8** %3
ret i8* %33
}

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