void remove_double_dots_and_double_slashes(char *s) {
  char *p = s;
  while (*s != '\0') {
    *p++ = *s++;
    if (((s[-1]) == '/')) {
      while (((s[0]) == '/')) {
        s++;
      }
      while (*s == '.' && s[1] == '.') {
        s += 2;
      }
    }
  }
  *p = '\0';
}


x86 assembly (clang, -O0):
<remove_double_dots_and_double_slashes>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11cf <remove_double_dots_and_double_slashes+0xcf>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x2f,%eax
jne    11ca <remove_double_dots_and_double_slashes+0xca>
jmp    1158 <remove_double_dots_and_double_slashes+0x58>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1179 <remove_double_dots_and_double_slashes+0x79>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1158 <remove_double_dots_and_double_slashes+0x58>
jmp    117e <remove_double_dots_and_double_slashes+0x7e>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x2e,%ecx
mov    %al,-0x11(%rbp)
jne    11a4 <remove_double_dots_and_double_slashes+0xa4>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2e,%eax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    11b4 <remove_double_dots_and_double_slashes+0xb4>
jmp    11c5 <remove_double_dots_and_double_slashes+0xc5>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
jmp    117e <remove_double_dots_and_double_slashes+0x7e>
jmp    11ca <remove_double_dots_and_double_slashes+0xca>
jmp    1110 <remove_double_dots_and_double_slashes+0x10>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_double_dots_and_double_slashes>:
mov    (%rdi),%cl
test   %cl,%cl
je     1157 <remove_double_dots_and_double_slashes+0x57>
mov    %rdi,%rax
jmp    111e <remove_double_dots_and_double_slashes+0x1e>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rax
mov    (%rax),%cl
add    $0x1,%rdi
test   %cl,%cl
je     1157 <remove_double_dots_and_double_slashes+0x57>
mov    %cl,(%rdi)
cmpb   $0x2f,(%rax)
jne    1110 <remove_double_dots_and_double_slashes+0x10>
cs nopw 0x0(%rax,%rax,1)
nop
movzbl 0x1(%rax),%ecx
add    $0x1,%rax
cmp    $0x2f,%cl
je     1130 <remove_double_dots_and_double_slashes+0x30>
jmp    1148 <remove_double_dots_and_double_slashes+0x48>
nop
movzbl 0x2(%rax),%ecx
add    $0x2,%rax
cmp    $0x2e,%cl
jne    1116 <remove_double_dots_and_double_slashes+0x16>
cmpb   $0x2e,0x1(%rax)
je     1140 <remove_double_dots_and_double_slashes+0x40>
mov    $0x2e,%cl
jmp    1116 <remove_double_dots_and_double_slashes+0x16>
movb   $0x0,(%rdi)
ret

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

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