#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 *);
char *StripDirectorySlash(char *DirPath) {
  char *ptr;
  if ((DirPath ? strlen(DirPath) : 0) == 1)
    return (DirPath);
  ptr = DirPath + (DirPath ? strlen(DirPath) : 0) - 1;
  if (*ptr == '/')
    *ptr = '\0';
  return (DirPath);
}


x86 assembly (clang, -O0):
<StripDirectorySlash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1138 <StripDirectorySlash+0x28>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
jmp    1142 <StripDirectorySlash+0x32>
xor    %eax,%eax
mov    %eax,-0x1c(%rbp)
jmp    1142 <StripDirectorySlash+0x32>
mov    -0x1c(%rbp),%eax
cmp    $0x1,%eax
jne    115b <StripDirectorySlash+0x4b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11bd <StripDirectorySlash+0xad>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     117f <StripDirectorySlash+0x6f>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x2c(%rbp)
jmp    1189 <StripDirectorySlash+0x79>
xor    %eax,%eax
mov    %eax,-0x2c(%rbp)
jmp    1189 <StripDirectorySlash+0x79>
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    11b5 <StripDirectorySlash+0xa5>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<StripDirectorySlash>:
push   %rbx
mov    %rdi,%rbx
test   %rdi,%rdi
je     1139 <StripDirectorySlash+0x29>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
je     1147 <StripDirectorySlash+0x37>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rbx,%rax,1)
je     1142 <StripDirectorySlash+0x32>
jmp    1147 <StripDirectorySlash+0x37>
xor    %eax,%eax
cmpb   $0x2f,-0x1(%rbx,%rax,1)
jne    1147 <StripDirectorySlash+0x37>
movb   $0x0,-0x1(%rbx,%rax,1)
mov    %rbx,%rax
pop    %rbx
ret

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

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