int urldecode(const char *src, char *dst) {
  static const char tbl[256] = {
      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0,  1,  2,  3,  4,  5,
      6,  7,  8,  9,  -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1,
      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1,
      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      -1, -1, -1, -1};
  char c, v1, v2, *beg = dst;
  while ((c = *src++) != '\0') {
    if (c == '%') {
      if (!(v1 = *src++) || (v1 = tbl[(unsigned char)v1]) < 0 ||
          !(v2 = *src++) || (v2 = tbl[(unsigned char)v2]) < 0) {
        *beg = '\0';
        return 0;
      }
      c = (v1 << 4) | v2;
    }
    *dst++ = c;
  }
  *dst = '\0';
  return 1;
}


x86 assembly (clang, -O0):
<urldecode>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x19(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
je     11f3 <urldecode+0xf3>
movsbl -0x19(%rbp),%eax
cmp    $0x25,%eax
jne    11da <urldecode+0xda>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x1a(%rbp)
cmp    $0x0,%al
je     11b7 <urldecode+0xb7>
movzbl -0x1a(%rbp),%eax
mov    %eax,%ecx
lea    0xe96(%rip),%rax
mov    (%rax,%rcx,1),%al
mov    %al,-0x1a(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
jl     11b7 <urldecode+0xb7>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x1b(%rbp)
cmp    $0x0,%al
je     11b7 <urldecode+0xb7>
movzbl -0x1b(%rbp),%eax
mov    %eax,%ecx
lea    0xe5b(%rip),%rax
mov    (%rax,%rcx,1),%al
mov    %al,-0x1b(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
jge    11ca <urldecode+0xca>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1201 <urldecode+0x101>
movsbl -0x1a(%rbp),%eax
shl    $0x4,%eax
movsbl -0x1b(%rbp),%ecx
or     %ecx,%eax
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    1114 <urldecode+0x14>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<urldecode>:
lea    0xef9(%rip),%r8
mov    %rsi,%r9
xor    %eax,%eax
jmp    111f <urldecode+0x1f>
xchg   %ax,%ax
test   %dl,%dl
je     115a <urldecode+0x5a>
add    $0x1,%rdi
mov    %dl,(%r9)
add    $0x1,%r9
movzbl (%rdi),%edx
cmp    $0x25,%dl
jne    1110 <urldecode+0x10>
movzbl 0x1(%rdi),%ecx
test   %rcx,%rcx
je     1156 <urldecode+0x56>
movzbl (%rcx,%r8,1),%ecx
test   %cl,%cl
js     1156 <urldecode+0x56>
movzbl 0x2(%rdi),%edx
test   %rdx,%rdx
je     1156 <urldecode+0x56>
movzbl (%rdx,%r8,1),%edx
test   %dl,%dl
js     1156 <urldecode+0x56>
add    $0x3,%rdi
shl    $0x4,%cl
or     %cl,%dl
jmp    1118 <urldecode+0x18>
movb   $0x0,(%rsi)
ret
mov    $0x1,%eax
movb   $0x0,(%r9)
ret

LLVM IR (-O0):
@urldecode.tbl = internal constant [256 x i8] c"\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\00\01\02\03\04\05\06\07\08\09\FF\FF\FF\FF\FF\FF\FF\0A\0B\0C\0D\0E\0F\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\0A\0B\0C\0D\0E\0F\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF"
define i32 @urldecode(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%10 = load i8*, i8** %5
store i8* %10, i8** %9
br label %11
11: ; preds = %55, %2
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %4
%14 = load i8, i8* %12
store i8 %14, i8* %6
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %59
17: ; preds = %11
%18 = load i8, i8* %6
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 37
br i1 %20, label %21, label %55
21: ; preds = %17
%22 = load i8*, i8** %4
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %4
%24 = load i8, i8* %22
store i8 %24, i8* %7
%25 = icmp ne i8 %24, 0
br i1 %25, label %26, label %45
26: ; preds = %21
%27 = load i8, i8* %7
%28 = zext i8 %27 to i64
%29 = getelementptr inbounds [256 x i8], [256 x i8]* @urldecode.tbl, i64 0, i64 %28
%30 = load i8, i8* %29
store i8 %30, i8* %7
%31 = sext i8 %30 to i32
%32 = icmp slt i32 %31, 0
br i1 %32, label %45, label %33
33: ; preds = %26
%34 = load i8*, i8** %4
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %4
%36 = load i8, i8* %34
store i8 %36, i8* %8
%37 = icmp ne i8 %36, 0
br i1 %37, label %38, label %45
38: ; preds = %33
%39 = load i8, i8* %8
%40 = zext i8 %39 to i64
%41 = getelementptr inbounds [256 x i8], [256 x i8]* @urldecode.tbl, i64 0, i64 %40
%42 = load i8, i8* %41
store i8 %42, i8* %8
%43 = sext i8 %42 to i32
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %38, %33, %26, %21
%46 = load i8*, i8** %9
store i8 0, i8* %46
store i32 0, i32* %3
br label %61
47: ; preds = %38
%48 = load i8, i8* %7
%49 = sext i8 %48 to i32
%50 = shl i32 %49, 4
%51 = load i8, i8* %8
%52 = sext i8 %51 to i32
%53 = or i32 %50, %52
%54 = trunc i32 %53 to i8
store i8 %54, i8* %6
br label %55
55: ; preds = %47, %17
%56 = load i8, i8* %6
%57 = load i8*, i8** %5
%58 = getelementptr inbounds i8, i8* %57, i32 1
store i8* %58, i8** %5
store i8 %56, i8* %57
br label %11
59: ; preds = %11
%60 = load i8*, i8** %5
store i8 0, i8* %60
store i32 1, i32* %3
br label %61
61: ; preds = %59, %45
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
@urldecode.tbl = internal unnamed_addr constant [256 x i8] c"\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\00\01\02\03\04\05\06\07\08\09\FF\FF\FF\FF\FF\FF\FF\0A\0B\0C\0D\0E\0F\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\0A\0B\0C\0D\0E\0F\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF"
define i32 @urldecode(i8* nocapture %0, i8* nocapture writeonly %1) {
br label %3
3: ; preds = %29, %2
%4 = phi i8* [ %0, %2 ], [ %30, %29 ]
%5 = phi i8* [ %1, %2 ], [ %32, %29 ]
%6 = getelementptr inbounds i8, i8* %4, i64 1
%7 = load i8, i8* %4
switch i8 %7, label %29 [
i8 0, label %33
i8 37, label %8
]
8: ; preds = %3
%9 = getelementptr inbounds i8, i8* %4, i64 2
%10 = load i8, i8* %6
%11 = icmp eq i8 %10, 0
br i1 %11, label %33, label %12
12: ; preds = %8
%13 = zext i8 %10 to i64
%14 = getelementptr inbounds [256 x i8], [256 x i8]* @urldecode.tbl, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = icmp slt i8 %15, 0
br i1 %16, label %33, label %17
17: ; preds = %12
%18 = getelementptr inbounds i8, i8* %4, i64 3
%19 = load i8, i8* %9
%20 = icmp eq i8 %19, 0
br i1 %20, label %33, label %21
21: ; preds = %17
%22 = zext i8 %19 to i64
%23 = getelementptr inbounds [256 x i8], [256 x i8]* @urldecode.tbl, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = icmp slt i8 %24, 0
br i1 %25, label %33, label %26
26: ; preds = %21
%27 = shl i8 %15, 4
%28 = or i8 %24, %27
br label %29
29: ; preds = %3, %26
%30 = phi i8* [ %18, %26 ], [ %6, %3 ]
%31 = phi i8 [ %28, %26 ], [ %7, %3 ]
%32 = getelementptr inbounds i8, i8* %5, i64 1
store i8 %31, i8* %5
br label %3
33: ; preds = %3, %8, %12, %17, %21
%34 = phi i8* [ %1, %21 ], [ %1, %17 ], [ %1, %12 ], [ %1, %8 ], [ %5, %3 ]
%35 = phi i32 [ 0, %21 ], [ 0, %17 ], [ 0, %12 ], [ 0, %8 ], [ 1, %3 ]
store i8 0, i8* %34
ret i32 %35
}