#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 */
unsigned int strlen(char *);
void clean_file_path(char *file_path) {
  unsigned int length = strlen(file_path);
  unsigned int trailing = 0;
  unsigned int leading = 0;
  while (leading < length) {
    if (trailing != leading) {
      file_path[trailing] = file_path[leading];
    }
    if (file_path[trailing] == '/') {
      while (file_path[leading] == '/') {
        ++leading;
      }
      ++trailing;
    } else {
      ++trailing;
      ++leading;
    }
  }
  file_path[trailing] = '\0';
}


x86 assembly (clang, -O0):
<clean_file_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11c2 <clean_file_path+0xb2>
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     1162 <clean_file_path+0x52>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    11ab <clean_file_path+0x9b>
jmp    117b <clean_file_path+0x6b>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    119d <clean_file_path+0x8d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117b <clean_file_path+0x6b>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11bd <clean_file_path+0xad>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1136 <clean_file_path+0x26>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clean_file_path>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
xor    %ecx,%ecx
test   %eax,%eax
je     1162 <clean_file_path+0x52>
xor    %edx,%edx
jmp    113a <clean_file_path+0x2a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%ecx
add    $0x1,%edx
cmp    %eax,%ecx
jae    1160 <clean_file_path+0x50>
mov    %ecx,%esi
mov    (%rbx,%rsi,1),%sil
cmp    %ecx,%edx
je     114a <clean_file_path+0x3a>
mov    %edx,%edi
mov    %sil,(%rbx,%rdi,1)
cmp    $0x2f,%sil
jne    1130 <clean_file_path+0x20>
mov    %ecx,%esi
add    $0x1,%ecx
cmpb   $0x2f,(%rbx,%rsi,1)
je     1150 <clean_file_path+0x40>
add    $0xffffffff,%ecx
jmp    1133 <clean_file_path+0x23>
mov    %edx,%ecx
movb   $0x0,(%rbx,%rcx,1)
pop    %rbx
ret

LLVM IR (-O0):
define void @clean_file_path(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
store i32 %7, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
br label %8
8: ; preds = %54, %1
%9 = load i32, i32* %5
%10 = load i32, i32* %3
%11 = icmp ult i32 %9, %10
br i1 %11, label %12, label %55
12: ; preds = %8
%13 = load i32, i32* %4
%14 = load i32, i32* %5
%15 = icmp ne i32 %13, %14
br i1 %15, label %16, label %26
16: ; preds = %12
%17 = load i8*, i8** %2
%18 = load i32, i32* %5
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = load i8*, i8** %2
%23 = load i32, i32* %4
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
store i8 %21, i8* %25
br label %26
26: ; preds = %16, %12
%27 = load i8*, i8** %2
%28 = load i32, i32* %4
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 47
br i1 %33, label %34, label %49
34: ; preds = %26
br label %35
35: ; preds = %43, %34
%36 = load i8*, i8** %2
%37 = load i32, i32* %5
%38 = zext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 47
br i1 %42, label %43, label %46
43: ; preds = %35
%44 = load i32, i32* %5
%45 = add i32 %44, 1
store i32 %45, i32* %5
br label %35
46: ; preds = %35
%47 = load i32, i32* %4
%48 = add i32 %47, 1
store i32 %48, i32* %4
br label %54
49: ; preds = %26
%50 = load i32, i32* %4
%51 = add i32 %50, 1
store i32 %51, i32* %4
%52 = load i32, i32* %5
%53 = add i32 %52, 1
store i32 %53, i32* %5
br label %54
54: ; preds = %49, %46
br label %8
55: ; preds = %8
%56 = load i8*, i8** %2
%57 = load i32, i32* %4
%58 = zext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
store i8 0, i8* %59
ret void
}

LLVM IR (-O2):
define void @clean_file_path(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %31, label %4
4: ; preds = %1, %25
%5 = phi i32 [ %26, %25 ], [ 0, %1 ]
%6 = phi i32 [ %27, %25 ], [ 0, %1 ]
%7 = icmp eq i32 %6, %5
%8 = zext i32 %5 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
br i1 %7, label %14, label %11
11: ; preds = %4
%12 = zext i32 %6 to i64
%13 = getelementptr inbounds i8, i8* %0, i64 %12
store i8 %10, i8* %13
br label %14
14: ; preds = %4, %11
%15 = icmp eq i8 %10, 47
br i1 %15, label %16, label %23
16: ; preds = %14, %16
%17 = phi i32 [ %22, %16 ], [ %5, %14 ]
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %0, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 47
%22 = add i32 %17, 1
br i1 %21, label %16, label %25
23: ; preds = %14
%24 = add nuw i32 %5, 1
br label %25
25: ; preds = %16, %23
%26 = phi i32 [ %24, %23 ], [ %17, %16 ]
%27 = add i32 %6, 1
%28 = icmp ult i32 %26, %2
br i1 %28, label %4, label %29
29: ; preds = %25
%30 = zext i32 %27 to i64
br label %31
31: ; preds = %29, %1
%32 = phi i64 [ 0, %1 ], [ %30, %29 ]
%33 = getelementptr inbounds i8, i8* %0, i64 %32
store i8 0, i8* %33
ret void
}