#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 *);
void remfilename(char *pathname) {
  int l = strlen(pathname);
  int i = l - 1;
  while (pathname[i] != '/' && i >= 0) {
    i--;
  }
  pathname[i + 1] = '\0';
}


x86 assembly (clang, -O0):
<remfilename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x2f,%ecx
mov    %al,-0x11(%rbp)
je     1155 <remfilename+0x45>
cmpl   $0x0,-0x10(%rbp)
setge  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1165 <remfilename+0x55>
jmp    1173 <remfilename+0x63>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1131 <remfilename+0x21>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remfilename>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
movslq %eax,%rcx
mov    %rcx,%rdx
shl    $0x20,%rdx
movabs $0x100000000,%rax
add    %rdx,%rax
movabs $0xffffffff00000000,%rdx
ff ff ff
nopw   0x0(%rax,%rax,1)
add    %rdx,%rax
cmpb   $0x2f,-0x1(%rbx,%rcx,1)
je     1156 <remfilename+0x46>
lea    -0x1(%rcx),%rsi
test   %rcx,%rcx
mov    %rsi,%rcx
jg     1140 <remfilename+0x30>
sar    $0x20,%rax
movb   $0x0,(%rbx,%rax,1)
pop    %rbx
ret

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

LLVM IR (-O2):
define void @remfilename(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = sext i32 %2 to i64
br label %4
4: ; preds = %4, %1
%5 = phi i64 [ %6, %4 ], [ %3, %1 ]
%6 = add nsw i64 %5, -1
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 47
%10 = icmp sgt i64 %5, 0
%11 = select i1 %9, i1 %10, i1 false
br i1 %11, label %4, label %12
12: ; preds = %4
%13 = shl i64 %5, 32
%14 = ashr exact i64 %13, 32
%15 = getelementptr inbounds i8, i8* %0, i64 %14
store i8 0, i8* %15
ret void
}