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 == '\\')
        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     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
mov    $0x1,%al
cmp    $0x2f,%ecx
mov    %al,-0x11(%rbp)
je     118e <remove_double_dots_and_double_slashes+0x8e>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    119e <remove_double_dots_and_double_slashes+0x9e>
jmp    11af <remove_double_dots_and_double_slashes+0xaf>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1169 <remove_double_dots_and_double_slashes+0x69>
jmp    11b4 <remove_double_dots_and_double_slashes+0xb4>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x2e,%ecx
mov    %al,-0x12(%rbp)
jne    11da <remove_double_dots_and_double_slashes+0xda>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2e,%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    $0x2,%rax
mov    %rax,-0x8(%rbp)
jmp    11b4 <remove_double_dots_and_double_slashes+0xb4>
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     1167 <remove_double_dots_and_double_slashes+0x67>
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     1167 <remove_double_dots_and_double_slashes+0x67>
mov    %cl,(%rdi)
mov    (%rax),%cl
add    $0x1,%rax
cmp    $0x5c,%cl
je     1134 <remove_double_dots_and_double_slashes+0x34>
cmp    $0x2f,%cl
je     1134 <remove_double_dots_and_double_slashes+0x34>
jmp    1110 <remove_double_dots_and_double_slashes+0x10>
xchg   %ax,%ax
add    $0x1,%rax
movzbl (%rax),%ecx
cmp    $0x2f,%cl
je     1130 <remove_double_dots_and_double_slashes+0x30>
cmp    $0x5c,%cl
je     1130 <remove_double_dots_and_double_slashes+0x30>
jmp    1158 <remove_double_dots_and_double_slashes+0x58>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl 0x2(%rax),%ecx
add    $0x2,%rax
cmp    $0x2e,%cl
jne    1112 <remove_double_dots_and_double_slashes+0x12>
cmpb   $0x2e,0x1(%rax)
je     1150 <remove_double_dots_and_double_slashes+0x50>
mov    $0x2e,%cl
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 = %40, %27
%29 = load i8*, i8** %2
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 47
br i1 %32, label %38, label %33
33: ; preds = %28
%34 = load i8*, i8** %2
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 92
br label %38
38: ; preds = %33, %28
%39 = phi i1 [ true, %28 ], [ %37, %33 ]
br i1 %39, label %40, label %43
40: ; preds = %38
%41 = load i8*, i8** %2
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %2
br label %28
43: ; preds = %38
br label %44
44: ; preds = %57, %43
%45 = load i8*, i8** %2
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 46
br i1 %48, label %49, label %55
49: ; preds = %44
%50 = load i8*, i8** %2
%51 = getelementptr inbounds i8, i8* %50, i64 1
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 46
br label %55
55: ; preds = %49, %44
%56 = phi i1 [ false, %44 ], [ %54, %49 ]
br i1 %56, label %57, label %60
57: ; preds = %55
%58 = load i8*, i8** %2
%59 = getelementptr inbounds i8, i8* %58, i64 2
store i8* %59, i8** %2
br label %44
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 %32, label %4
4: ; preds = %1, %28
%5 = phi i8 [ %29, %28 ], [ %2, %1 ]
%6 = phi i8* [ %9, %28 ], [ %0, %1 ]
%7 = phi i8* [ %30, %28 ], [ %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 %12 [
i8 47, label %11
i8 92, label %11
]
11: ; preds = %4, %4
br label %14
12: ; preds = %4
%13 = load i8, i8* %8
br label %28
14: ; preds = %11, %17
%15 = phi i8* [ %18, %17 ], [ %8, %11 ]
%16 = load i8, i8* %15
switch i8 %16, label %28 [
i8 47, label %17
i8 92, label %17
i8 46, label %19
]
17: ; preds = %14, %14
%18 = getelementptr inbounds i8, i8* %15, i64 1
br label %14
19: ; preds = %14, %24
%20 = phi i8* [ %25, %24 ], [ %15, %14 ]
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 46
br i1 %23, label %24, label %28
24: ; preds = %19
%25 = getelementptr inbounds i8, i8* %20, i64 2
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 46
br i1 %27, label %19, label %28
28: ; preds = %14, %24, %19, %12
%29 = phi i8 [ %13, %12 ], [ %26, %24 ], [ 46, %19 ], [ %16, %14 ]
%30 = phi i8* [ %8, %12 ], [ %25, %24 ], [ %20, %19 ], [ %15, %14 ]
%31 = icmp eq i8 %29, 0
br i1 %31, label %32, label %4
32: ; preds = %28, %1
%33 = phi i8* [ %0, %1 ], [ %9, %28 ]
store i8 0, i8* %33
ret void
}