void path_unescape_path(char *str) {
  char *src = str;
  char *dst = str;
  while (*src != '\0') {
    if (*src != '%') {
      *dst++ = *src++;
    } else {
      src++;
      switch (*src) {
      case 'C':
        *dst++ = ',';
        src++;
        break;
      case 'E':
        *dst++ = '=';
        src++;
        break;
      case 'P':
        *dst++ = '%';
        src++;
        break;
      default:;
      }
    }
  }
  *dst = '\0';
}


x86 assembly (clang, -O0):
<path_unescape_path>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     121d <path_unescape_path+0x11d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
je     115f <path_unescape_path+0x5f>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    1218 <path_unescape_path+0x118>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x43,%eax
je     11a5 <path_unescape_path+0xa5>
jmp    1183 <path_unescape_path+0x83>
mov    -0x1c(%rbp),%eax
sub    $0x45,%eax
je     11c8 <path_unescape_path+0xc8>
jmp    1194 <path_unescape_path+0x94>
mov    -0x1c(%rbp),%eax
sub    $0x50,%eax
je     11eb <path_unescape_path+0xeb>
jmp    120e <path_unescape_path+0x10e>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x2c,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1213 <path_unescape_path+0x113>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x3d,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1213 <path_unescape_path+0x113>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x25,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1213 <path_unescape_path+0x113>
jmp    1213 <path_unescape_path+0x113>
jmp    1218 <path_unescape_path+0x118>
jmp    1118 <path_unescape_path+0x18>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<path_unescape_path>:
mov    %rdi,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rdi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl -0x1(%rdi),%ecx
cmp    $0x25,%cl
jne    1150 <path_unescape_path+0x50>
movsbl (%rdi),%ecx
add    $0x1,%rdi
cmp    $0x50,%ecx
je     1160 <path_unescape_path+0x60>
cmp    $0x45,%ecx
je     1170 <path_unescape_path+0x70>
cmp    $0x43,%ecx
jne    1120 <path_unescape_path+0x20>
movb   $0x2c,(%rax)
add    $0x1,%rax
jmp    1110 <path_unescape_path+0x10>
nopl   0x0(%rax,%rax,1)
test   %cl,%cl
je     1179 <path_unescape_path+0x79>
mov    %cl,(%rax)
add    $0x1,%rax
jmp    1110 <path_unescape_path+0x10>
nopl   0x0(%rax)
movb   $0x25,(%rax)
add    $0x1,%rax
jmp    1110 <path_unescape_path+0x10>
nopl   0x0(%rax)
movb   $0x3d,(%rax)
add    $0x1,%rax
jmp    1110 <path_unescape_path+0x10>
movb   $0x0,(%rax)
ret

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

LLVM IR (-O2):
define void @path_unescape_path(i8* nocapture %0) {
br label %2
2: ; preds = %10, %1
%3 = phi i8* [ %0, %1 ], [ %11, %10 ]
%4 = phi i8* [ %0, %1 ], [ %12, %10 ]
br label %5
5: ; preds = %2, %13
%6 = phi i8* [ %14, %13 ], [ %3, %2 ]
%7 = load i8, i8* %6
switch i8 %7, label %8 [
i8 0, label %23
i8 37, label %13
]
8: ; preds = %5
%9 = getelementptr inbounds i8, i8* %6, i64 1
store i8 %7, i8* %4
br label %10
10: ; preds = %8, %21, %19, %17
%11 = phi i8* [ %18, %17 ], [ %20, %19 ], [ %22, %21 ], [ %9, %8 ]
%12 = getelementptr inbounds i8, i8* %4, i64 1
br label %2
13: ; preds = %5
%14 = getelementptr inbounds i8, i8* %6, i64 1
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
switch i32 %16, label %5 [
i32 67, label %17
i32 69, label %19
i32 80, label %21
]
17: ; preds = %13
store i8 44, i8* %4
%18 = getelementptr inbounds i8, i8* %6, i64 2
br label %10
19: ; preds = %13
store i8 61, i8* %4
%20 = getelementptr inbounds i8, i8* %6, i64 2
br label %10
21: ; preds = %13
store i8 37, i8* %4
%22 = getelementptr inbounds i8, i8* %6, i64 2
br label %10
23: ; preds = %5
store i8 0, i8* %4
ret void
}