void remove_double_dots_and_double_slashes(char *s) {
  char *p = s;
  while (*s != '\0') {
    *p++ = *s++;
    if (s[-1] == '/' || s[-1] == '\\') {
      while (*s == '.' && s[1] == '.')
        s += 2;
      while (*s == '/' || *s == '\\')
        s++;
    }
  }
  *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     1205 <remove_double_dots_and_double_slashes+0x105>
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
je     1164 <remove_double_dots_and_double_slashes+0x64>
mov    -0x8(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x5c,%eax
jne    1200 <remove_double_dots_and_double_slashes+0x100>
jmp    1169 <remove_double_dots_and_double_slashes+0x69>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x2e,%ecx
mov    %al,-0x11(%rbp)
jne    118f <remove_double_dots_and_double_slashes+0x8f>
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    119f <remove_double_dots_and_double_slashes+0x9f>
jmp    11b0 <remove_double_dots_and_double_slashes+0xb0>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
jmp    1169 <remove_double_dots_and_double_slashes+0x69>
jmp    11b5 <remove_double_dots_and_double_slashes+0xb5>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x2f,%ecx
mov    %al,-0x12(%rbp)
je     11da <remove_double_dots_and_double_slashes+0xda>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
sete   %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    11ea <remove_double_dots_and_double_slashes+0xea>
jmp    11fb <remove_double_dots_and_double_slashes+0xfb>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11b5 <remove_double_dots_and_double_slashes+0xb5>
jmp    1200 <remove_double_dots_and_double_slashes+0x100>
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     1174 <remove_double_dots_and_double_slashes+0x74>
mov    %rdi,%rax
jmp    111a <remove_double_dots_and_double_slashes+0x1a>
nopl   0x0(%rax,%rax,1)
mov    (%rax),%cl
add    $0x1,%rdi
test   %cl,%cl
je     1174 <remove_double_dots_and_double_slashes+0x74>
mov    %cl,(%rdi)
mov    (%rax),%cl
add    $0x1,%rax
cmp    $0x2f,%cl
je     112c <remove_double_dots_and_double_slashes+0x2c>
cmp    $0x5c,%cl
jne    1110 <remove_double_dots_and_double_slashes+0x10>
mov    (%rax),%cl
cmp    $0x2e,%cl
jne    1168 <remove_double_dots_and_double_slashes+0x68>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmpb   $0x2e,0x1(%rax)
jne    1155 <remove_double_dots_and_double_slashes+0x55>
movzbl 0x2(%rax),%ecx
add    $0x2,%rax
cmp    $0x2e,%cl
je     1140 <remove_double_dots_and_double_slashes+0x40>
jmp    1168 <remove_double_dots_and_double_slashes+0x68>
mov    $0x2e,%cl
jmp    1168 <remove_double_dots_and_double_slashes+0x68>
nopl   0x0(%rax)
movzbl 0x1(%rax),%ecx
add    $0x1,%rax
cmp    $0x5c,%cl
je     1160 <remove_double_dots_and_double_slashes+0x60>
cmp    $0x2f,%cl
je     1160 <remove_double_dots_and_double_slashes+0x60>
jmp    1112 <remove_double_dots_and_double_slashes+0x12>
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 = %61, %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 %62
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 %27, label %21
21: ; preds = %10
%22 = load i8*, i8** %2
%23 = getelementptr inbounds i8, i8* %22, i64 -1
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 92
br i1 %26, label %27, label %61
27: ; preds = %21, %10
br label %28
28: ; preds = %41, %27
%29 = load i8*, i8** %2
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 46
br i1 %32, label %33, label %39
33: ; preds = %28
%34 = load i8*, i8** %2
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 46
br label %39
39: ; preds = %33, %28
%40 = phi i1 [ false, %28 ], [ %38, %33 ]
br i1 %40, label %41, label %44
41: ; preds = %39
%42 = load i8*, i8** %2
%43 = getelementptr inbounds i8, i8* %42, i64 2
store i8* %43, i8** %2
br label %28
44: ; preds = %39
br label %45
45: ; preds = %57, %44
%46 = load i8*, i8** %2
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 47
br i1 %49, label %55, label %50
50: ; preds = %45
%51 = load i8*, i8** %2
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 92
br label %55
55: ; preds = %50, %45
%56 = phi i1 [ true, %45 ], [ %54, %50 ]
br i1 %56, label %57, label %60
57: ; preds = %55
%58 = load i8*, i8** %2
%59 = getelementptr inbounds i8, i8* %58, i32 1
store i8* %59, i8** %2
br label %45
60: ; preds = %55
br label %61
61: ; preds = %60, %21
br label %5
62: ; preds = %5
%63 = load i8*, i8** %3
store i8 0, i8* %63
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 %38, label %4
4: ; preds = %1, %34
%5 = phi i8 [ %35, %34 ], [ %2, %1 ]
%6 = phi i8* [ %9, %34 ], [ %0, %1 ]
%7 = phi i8* [ %36, %34 ], [ %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
switch i8 %10, label %11 [
i8 47, label %13
i8 92, label %13
]
11: ; preds = %4
%12 = load i8, i8* %8
br label %34
13: ; preds = %4, %4
%14 = load i8, i8* %8
%15 = icmp eq i8 %14, 46
br i1 %15, label %16, label %25
16: ; preds = %13, %21
%17 = phi i8* [ %22, %21 ], [ %8, %13 ]
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 46
br i1 %20, label %21, label %25
21: ; preds = %16
%22 = getelementptr inbounds i8, i8* %17, i64 2
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 46
br i1 %24, label %16, label %25
25: ; preds = %16, %21, %13
%26 = phi i8 [ %14, %13 ], [ 46, %16 ], [ %23, %21 ]
%27 = phi i8* [ %8, %13 ], [ %17, %16 ], [ %22, %21 ]
br label %28
28: ; preds = %25, %31
%29 = phi i8 [ %33, %31 ], [ %26, %25 ]
%30 = phi i8* [ %32, %31 ], [ %27, %25 ]
switch i8 %29, label %34 [
i8 47, label %31
i8 92, label %31
]
31: ; preds = %28, %28
%32 = getelementptr inbounds i8, i8* %30, i64 1
%33 = load i8, i8* %32
br label %28
34: ; preds = %28, %11
%35 = phi i8 [ %12, %11 ], [ %29, %28 ]
%36 = phi i8* [ %8, %11 ], [ %30, %28 ]
%37 = icmp eq i8 %35, 0
br i1 %37, label %38, label %4
38: ; preds = %34, %1
%39 = phi i8* [ %0, %1 ], [ %9, %34 ]
store i8 0, i8* %39
ret void
}