#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__ strlen(char *);
void StripFilename(char *path) {
  int length;
  length = (int)strlen(path) - 1;
  while (length > 0 && path[length] != '/')
    length--;
  path[length] = 0;
}


x86 assembly (clang, -O0):
<StripFilename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0xd(%rbp)
jle    114f <StripFilename+0x3f>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    115f <StripFilename+0x4f>
jmp    116d <StripFilename+0x5d>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    112b <StripFilename+0x1b>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<StripFilename>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%edx
test   %eax,%eax
mov    $0x1,%ecx
cmovle %eax,%ecx
add    $0xffffffff,%ecx
nopl   0x0(%rax,%rax,1)
cmp    $0x2,%edx
jl     1143 <StripFilename+0x33>
add    $0xffffffffffffffff,%rdx
mov    %edx,%eax
cmpb   $0x2f,(%rbx,%rax,1)
jne    1130 <StripFilename+0x20>
mov    %edx,%ecx
movslq %ecx,%rax
movb   $0x0,(%rbx,%rax,1)
pop    %rbx
ret

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

LLVM IR (-O2):
define void @StripFilename(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = trunc i64 %2 to i32
%4 = and i64 %2, 4294967295
%5 = call i32 @llvm.smin.i32(i32 %3, i32 1)
%6 = add i32 %5, -1
br label %7
7: ; preds = %12, %1
%8 = phi i64 [ %9, %12 ], [ %4, %1 ]
%9 = add nsw i64 %8, -1
%10 = trunc i64 %8 to i32
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %19
12: ; preds = %7
%13 = and i64 %9, 4294967295
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 47
br i1 %16, label %17, label %7
17: ; preds = %12
%18 = trunc i64 %9 to i32
br label %19
19: ; preds = %7, %17
%20 = phi i32 [ %18, %17 ], [ %6, %7 ]
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %0, i64 %21
store i8 0, i8* %22
ret void
}