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


x86 assembly (clang, -O0):
<XX_httplib_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),%ecx
xor    %eax,%eax
cmp    $0x2e,%ecx
mov    %al,-0x11(%rbp)
jne    1136 <XX_httplib_remove_double_dots_and_double_slashes+0x36>
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    1146 <XX_httplib_remove_double_dots_and_double_slashes+0x46>
jmp    1157 <XX_httplib_remove_double_dots_and_double_slashes+0x57>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1110 <XX_httplib_remove_double_dots_and_double_slashes+0x10>
jmp    115c <XX_httplib_remove_double_dots_and_double_slashes+0x5c>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1241 <XX_httplib_remove_double_dots_and_double_slashes+0x141>
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     11b0 <XX_httplib_remove_double_dots_and_double_slashes+0xb0>
mov    -0x8(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x5c,%eax
jne    123c <XX_httplib_remove_double_dots_and_double_slashes+0x13c>
jmp    11b5 <XX_httplib_remove_double_dots_and_double_slashes+0xb5>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1237 <XX_httplib_remove_double_dots_and_double_slashes+0x137>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     11e5 <XX_httplib_remove_double_dots_and_double_slashes+0xe5>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    11f6 <XX_httplib_remove_double_dots_and_double_slashes+0xf6>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1232 <XX_httplib_remove_double_dots_and_double_slashes+0x132>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1228 <XX_httplib_remove_double_dots_and_double_slashes+0x128>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2e,%eax
jne    1228 <XX_httplib_remove_double_dots_and_double_slashes+0x128>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
jmp    122d <XX_httplib_remove_double_dots_and_double_slashes+0x12d>
jmp    1237 <XX_httplib_remove_double_dots_and_double_slashes+0x137>
jmp    1232 <XX_httplib_remove_double_dots_and_double_slashes+0x132>
jmp    11b5 <XX_httplib_remove_double_dots_and_double_slashes+0xb5>
jmp    123c <XX_httplib_remove_double_dots_and_double_slashes+0x13c>
jmp    115c <XX_httplib_remove_double_dots_and_double_slashes+0x5c>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<XX_httplib_remove_double_dots_and_double_slashes>:
cmpb   $0x2e,(%rdi)
sete   %cl
mov    %rdi,%rdx
nopl   0x0(%rax)
mov    %rdx,%rax
test   $0x1,%cl
je     1124 <XX_httplib_remove_double_dots_and_double_slashes+0x24>
lea    0x1(%rax),%rdx
mov    $0x1,%cl
cmpb   $0x2e,0x1(%rax)
je     1110 <XX_httplib_remove_double_dots_and_double_slashes+0x10>
mov    (%rax),%cl
test   %cl,%cl
jne    1138 <XX_httplib_remove_double_dots_and_double_slashes+0x38>
movb   $0x0,(%rdi)
ret
xchg   %ax,%ax
add    $0x1,%rdi
test   %cl,%cl
je     112a <XX_httplib_remove_double_dots_and_double_slashes+0x2a>
mov    %cl,(%rdi)
mov    (%rax),%cl
add    $0x1,%rax
cmp    $0x5c,%cl
je     1163 <XX_httplib_remove_double_dots_and_double_slashes+0x63>
cmp    $0x2f,%cl
je     1163 <XX_httplib_remove_double_dots_and_double_slashes+0x63>
mov    (%rax),%cl
add    $0x1,%rdi
test   %cl,%cl
jne    1138 <XX_httplib_remove_double_dots_and_double_slashes+0x38>
jmp    112a <XX_httplib_remove_double_dots_and_double_slashes+0x2a>
cs nopw 0x0(%rax,%rax,1)
add    %rdx,%rax
movzbl (%rax),%ecx
mov    $0x1,%edx
cmp    $0x5c,%cl
je     1160 <XX_httplib_remove_double_dots_and_double_slashes+0x60>
cmp    $0x2f,%cl
je     1160 <XX_httplib_remove_double_dots_and_double_slashes+0x60>
cmp    $0x2e,%cl
jne    1130 <XX_httplib_remove_double_dots_and_double_slashes+0x30>
mov    $0x2,%edx
cmpb   $0x2e,0x1(%rax)
je     1160 <XX_httplib_remove_double_dots_and_double_slashes+0x60>
mov    $0x2e,%cl
jmp    1130 <XX_httplib_remove_double_dots_and_double_slashes+0x30>

LLVM IR (-O0):
define void @XX_httplib_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 = %19, %1
%6 = load i8*, i8** %2
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 46
br i1 %10, label %11, label %17
11: ; preds = %5
%12 = load i8*, i8** %2
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 46
br label %17
17: ; preds = %11, %5
%18 = phi i1 [ false, %5 ], [ %16, %11 ]
br i1 %18, label %19, label %22
19: ; preds = %17
%20 = load i8*, i8** %2
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %2
br label %5
22: ; preds = %17
br label %23
23: ; preds = %86, %22
%24 = load i8*, i8** %2
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %87
28: ; preds = %23
%29 = load i8*, i8** %2
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %2
%31 = load i8, i8* %29
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %3
store i8 %31, i8* %32
%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, 47
br i1 %38, label %45, label %39
39: ; preds = %28
%40 = load i8*, i8** %2
%41 = getelementptr inbounds i8, i8* %40, i64 -1
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 92
br i1 %44, label %45, label %86
45: ; preds = %39, %28
br label %46
46: ; preds = %84, %45
%47 = load i8*, i8** %2
%48 = getelementptr inbounds i8, i8* %47, i64 0
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %85
52: ; preds = %46
%53 = load i8*, i8** %2
%54 = getelementptr inbounds i8, i8* %53, i64 0
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 47
br i1 %57, label %64, label %58
58: ; preds = %52
%59 = load i8*, i8** %2
%60 = getelementptr inbounds i8, i8* %59, i64 0
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 92
br i1 %63, label %64, label %67
64: ; preds = %58, %52
%65 = load i8*, i8** %2
%66 = getelementptr inbounds i8, i8* %65, i32 1
store i8* %66, i8** %2
br label %84
67: ; preds = %58
%68 = load i8*, i8** %2
%69 = getelementptr inbounds i8, i8* %68, i64 0
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
%72 = icmp eq i32 %71, 46
br i1 %72, label %73, label %82
73: ; preds = %67
%74 = load i8*, i8** %2
%75 = getelementptr inbounds i8, i8* %74, i64 1
%76 = load i8, i8* %75
%77 = sext i8 %76 to i32
%78 = icmp eq i32 %77, 46
br i1 %78, label %79, label %82
79: ; preds = %73
%80 = load i8*, i8** %2
%81 = getelementptr inbounds i8, i8* %80, i64 2
store i8* %81, i8** %2
br label %83
82: ; preds = %73, %67
br label %85
83: ; preds = %79
br label %84
84: ; preds = %83, %64
br label %46
85: ; preds = %82, %46
br label %86
86: ; preds = %85, %39
br label %23
87: ; preds = %23
%88 = load i8*, i8** %3
store i8 0, i8* %88
ret void
}

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