#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 *fix_vpath(char *value) {
  int len;
  while (*value == '/')
    ++value;
  for (len = strlen(value); len && value[len - 1] == '/'; --len) {
  }
  value[len] = 0;
  return value;
}


x86 assembly (clang, -O0):
<fix_vpath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    113d <fix_vpath+0x2d>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    111c <fix_vpath+0xc>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0xd(%rbp)
je     1172 <fix_vpath+0x62>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
sete   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1182 <fix_vpath+0x72>
jmp    1195 <fix_vpath+0x85>
jmp    1187 <fix_vpath+0x77>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1149 <fix_vpath+0x39>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fix_vpath>:
push   %rbx
mov    %rdi,%rbx
add    $0xffffffffffffffff,%rbx
nopl   0x0(%rax,%rax,1)
cmpb   $0x2f,0x1(%rbx)
lea    0x1(%rbx),%rbx
je     1120 <fix_vpath+0x10>
mov    %rbx,%rdi
call   1030 <strlen@plt>
movslq %eax,%rsi
mov    %rsi,%rcx
shl    $0x20,%rcx
movabs $0xffffffff00000000,%r8
ff ff ff
mov    %rsi,%rdi
nopl   0x0(%rax)
mov    %eax,%edx
sub    $0x1,%rdi
jb     1168 <fix_vpath+0x58>
add    %r8,%rcx
lea    -0x1(%rdx),%eax
cmpb   $0x2f,-0x1(%rbx,%rsi,1)
mov    %rdi,%rsi
je     1150 <fix_vpath+0x40>
movslq %edx,%rax
movb   $0x0,(%rbx,%rax,1)
mov    %rbx,%rax
pop    %rbx
ret

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

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