#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 */
size_t strlen(char *);
char *strstr(char *, char *);
void CleanPath(char *entry) {
  char *p, *q;
  size_t len;
  while ((p = strstr(entry, "//")) != NULL) {
    p++;
    q = p + 1;
    while (*p)
      *p++ = *q++;
  }
  len = strlen(entry);
  if (entry[len - 1] == '/')
    entry[len - 1] = '\0';
  while ((p = strstr(entry, "/./")) != NULL) {
    p++;
    q = p + 2;
    while (*p)
      *p++ = *q++;
  }
  if (strstr(entry, "./") == entry) {
    p = entry;
    q = p + 2;
    while (*p)
      *p++ = *q++;
  }
}


x86 assembly (clang, -O0):
<CleanPath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec9(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     119b <CleanPath+0x7b>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1196 <CleanPath+0x76>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    1162 <CleanPath+0x42>
jmp    112c <CleanPath+0xc>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    11d1 <CleanPath+0xb1>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    11d6 <CleanPath+0xb6>
mov    -0x8(%rbp),%rdi
lea    0xe22(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1245 <CleanPath+0x125>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1240 <CleanPath+0x120>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    120c <CleanPath+0xec>
jmp    11d6 <CleanPath+0xb6>
mov    -0x8(%rbp),%rdi
lea    0xdb4(%rip),%rsi
call   1040 <strstr@plt>
cmp    -0x8(%rbp),%rax
jne    12ac <CleanPath+0x18c>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     12a7 <CleanPath+0x187>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    1273 <CleanPath+0x153>
jmp    12ac <CleanPath+0x18c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CleanPath>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xec2(%rip),%rsi
call   1050 <strstr@plt>
test   %rax,%rax
je     1190 <CleanPath+0x60>
lea    0xeb1(%rip),%r14
jmp    1170 <CleanPath+0x40>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strstr@plt>
test   %rax,%rax
je     1190 <CleanPath+0x60>
cmpb   $0x0,0x1(%rax)
je     1160 <CleanPath+0x30>
add    $0x2,%rax
nopw   0x0(%rax,%rax,1)
movzbl (%rax),%ecx
mov    %cl,-0x1(%rax)
add    $0x1,%rax
test   %cl,%cl
jne    1180 <CleanPath+0x50>
jmp    1160 <CleanPath+0x30>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmpb   $0x2f,-0x1(%rax,%rbx,1)
jne    11a4 <CleanPath+0x74>
movb   $0x0,-0x1(%rbx,%rax,1)
lea    0xe58(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strstr@plt>
test   %rax,%rax
je     1202 <CleanPath+0xd2>
lea    0xe44(%rip),%r14
jmp    11e0 <CleanPath+0xb0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strstr@plt>
test   %rax,%rax
je     1202 <CleanPath+0xd2>
cmpb   $0x0,0x1(%rax)
je     11d0 <CleanPath+0xa0>
add    $0x3,%rax
nopw   0x0(%rax,%rax,1)
movzbl (%rax),%ecx
mov    %cl,-0x2(%rax)
cmpb   $0x0,-0x1(%rax)
lea    0x1(%rax),%rax
jne    11f0 <CleanPath+0xc0>
jmp    11d0 <CleanPath+0xa0>
lea    0xdfb(%rip),%rsi
mov    $0x2,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
jne    1240 <CleanPath+0x110>
cmpb   $0x0,(%rbx)
je     1240 <CleanPath+0x110>
add    $0x2,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%rbx),%eax
mov    %al,-0x2(%rbx)
cmpb   $0x0,-0x1(%rbx)
lea    0x1(%rbx),%rbx
jne    1230 <CleanPath+0x100>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"//\00"
@.str.1 = [4 x i8] c"/./\00"
@.str.2 = [3 x i8] c"./\00"
define void @CleanPath(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
store i8* %0, i8** %2
br label %6
6: ; preds = %25, %1
%7 = load i8*, i8** %2
%8 = call i8* @strstr(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %3
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %26
10: ; preds = %6
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i32 1
store i8* %12, i8** %3
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i64 1
store i8* %14, i8** %4
br label %15
15: ; preds = %19, %10
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
%18 = icmp ne i8 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %15
%20 = load i8*, i8** %4
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %4
%22 = load i8, i8* %20
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %3
store i8 %22, i8* %23
br label %15
25: ; preds = %15
br label %6
26: ; preds = %6
%27 = load i8*, i8** %2
%28 = call i64 @strlen(i8* %27)
store i64 %28, i64* %5
%29 = load i8*, i8** %2
%30 = load i64, i64* %5
%31 = sub i64 %30, 1
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 47
br i1 %35, label %36, label %41
36: ; preds = %26
%37 = load i8*, i8** %2
%38 = load i64, i64* %5
%39 = sub i64 %38, 1
%40 = getelementptr inbounds i8, i8* %37, i64 %39
store i8 0, i8* %40
br label %41
41: ; preds = %36, %26
br label %42
42: ; preds = %61, %41
%43 = load i8*, i8** %2
%44 = call i8* @strstr(i8* %43, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i8* %44, i8** %3
%45 = icmp ne i8* %44, null
br i1 %45, label %46, label %62
46: ; preds = %42
%47 = load i8*, i8** %3
%48 = getelementptr inbounds i8, i8* %47, i32 1
store i8* %48, i8** %3
%49 = load i8*, i8** %3
%50 = getelementptr inbounds i8, i8* %49, i64 2
store i8* %50, i8** %4
br label %51
51: ; preds = %55, %46
%52 = load i8*, i8** %3
%53 = load i8, i8* %52
%54 = icmp ne i8 %53, 0
br i1 %54, label %55, label %61
55: ; preds = %51
%56 = load i8*, i8** %4
%57 = getelementptr inbounds i8, i8* %56, i32 1
store i8* %57, i8** %4
%58 = load i8, i8* %56
%59 = load i8*, i8** %3
%60 = getelementptr inbounds i8, i8* %59, i32 1
store i8* %60, i8** %3
store i8 %58, i8* %59
br label %51
61: ; preds = %51
br label %42
62: ; preds = %42
%63 = load i8*, i8** %2
%64 = call i8* @strstr(i8* %63, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%65 = load i8*, i8** %2
%66 = icmp eq i8* %64, %65
br i1 %66, label %67, label %82
67: ; preds = %62
%68 = load i8*, i8** %2
store i8* %68, i8** %3
%69 = load i8*, i8** %3
%70 = getelementptr inbounds i8, i8* %69, i64 2
store i8* %70, i8** %4
br label %71
71: ; preds = %75, %67
%72 = load i8*, i8** %3
%73 = load i8, i8* %72
%74 = icmp ne i8 %73, 0
br i1 %74, label %75, label %81
75: ; preds = %71
%76 = load i8*, i8** %4
%77 = getelementptr inbounds i8, i8* %76, i32 1
store i8* %77, i8** %4
%78 = load i8, i8* %76
%79 = load i8*, i8** %3
%80 = getelementptr inbounds i8, i8* %79, i32 1
store i8* %80, i8** %3
store i8 %78, i8* %79
br label %71
81: ; preds = %71
br label %82
82: ; preds = %81, %62
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"//\00"
@.str.1 = [4 x i8] c"/./\00"
@.str.2 = [3 x i8] c"./\00"
define void @CleanPath(i8* %0) {
%2 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %22, label %7
4: ; preds = %14, %7
%5 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %22, label %7
7: ; preds = %1, %4
%8 = phi i8* [ %5, %4 ], [ %2, %1 ]
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %4, label %12
12: ; preds = %7
%13 = getelementptr inbounds i8, i8* %8, i64 2
br label %14
14: ; preds = %12, %14
%15 = phi i8* [ %19, %14 ], [ %9, %12 ]
%16 = phi i8* [ %17, %14 ], [ %13, %12 ]
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i8, i8* %16
store i8 %18, i8* %15
%19 = getelementptr inbounds i8, i8* %15, i64 1
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %4, label %14
22: ; preds = %4, %1
%23 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%24 = add i64 %23, -1
%25 = getelementptr inbounds i8, i8* %0, i64 %24
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 47
br i1 %27, label %28, label %29
28: ; preds = %22
store i8 0, i8* %25
br label %29
29: ; preds = %28, %22
%30 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%31 = icmp eq i8* %30, null
br i1 %31, label %50, label %35
32: ; preds = %42, %35
%33 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%34 = icmp eq i8* %33, null
br i1 %34, label %50, label %35
35: ; preds = %29, %32
%36 = phi i8* [ %33, %32 ], [ %30, %29 ]
%37 = getelementptr inbounds i8, i8* %36, i64 1
%38 = load i8, i8* %37
%39 = icmp eq i8 %38, 0
br i1 %39, label %32, label %40
40: ; preds = %35
%41 = getelementptr inbounds i8, i8* %36, i64 3
br label %42
42: ; preds = %40, %42
%43 = phi i8* [ %47, %42 ], [ %37, %40 ]
%44 = phi i8* [ %45, %42 ], [ %41, %40 ]
%45 = getelementptr inbounds i8, i8* %44, i64 1
%46 = load i8, i8* %44
store i8 %46, i8* %43
%47 = getelementptr inbounds i8, i8* %43, i64 1
%48 = load i8, i8* %47
%49 = icmp eq i8 %48, 0
br i1 %49, label %32, label %42
50: ; preds = %32, %29
%51 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i64 2)
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %66
53: ; preds = %50
%54 = load i8, i8* %0
%55 = icmp eq i8 %54, 0
br i1 %55, label %66, label %56
56: ; preds = %53
%57 = getelementptr inbounds i8, i8* %0, i64 2
br label %58
58: ; preds = %56, %58
%59 = phi i8* [ %63, %58 ], [ %0, %56 ]
%60 = phi i8* [ %61, %58 ], [ %57, %56 ]
%61 = getelementptr inbounds i8, i8* %60, i64 1
%62 = load i8, i8* %60
%63 = getelementptr inbounds i8, i8* %59, i64 1
store i8 %62, i8* %59
%64 = load i8, i8* %63
%65 = icmp eq i8 %64, 0
br i1 %65, label %66, label %58
66: ; preds = %58, %53, %50
ret void
}