void test_urldecode() {
  char *param = "%26bla+r";
  char dest[128] = {
      0,
  };
  do {
    if (!urldecode(dest, param, 128)) {
      printf("[%s] failed: %s\n", "urldecode(dest, param, 128)",
             "Failed to decode.");
      printf("%s -> FAILED\n", __func__);
      return;
    }
  } while (0);
  do {
    if (strcmp(dest, "&bla r")) {
      printf("expected [%s == %s]\n", "dest", "\"&bla r\"");
      printf(" a = \"%s\"\n", dest);
      printf(" b = \"%s\"\n", "&bla r");
      printf("%s -> FAILED\n", __func__);
      return;
    }
  } while (0);
  printf("%s -> OK\n", __func__);
}


x86 assembly (clang, -O0):
<test_urldecode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
lea    0xeae(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
lea    -0x90(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x80,%edx
mov    $0x0,%al
call   1060 <urldecode@plt>
cmp    $0x0,%eax
jne    11bf <test_urldecode+0x7f>
lea    0xe79(%rip),%rdi
lea    0xe83(%rip),%rsi
lea    0xe98(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9c(%rip),%rdi
lea    0xea3(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125f <test_urldecode+0x11f>
jmp    11c4 <test_urldecode+0x84>
jmp    11c9 <test_urldecode+0x89>
lea    -0x90(%rbp),%rdi
lea    0xe8e(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
je     1245 <test_urldecode+0x105>
lea    0xe80(%rip),%rdi
lea    0xe8e(%rip),%rsi
lea    0xe8c(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x90(%rbp),%rsi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7d(%rip),%rdi
lea    0xe41(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe16(%rip),%rdi
lea    0xe1d(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125f <test_urldecode+0x11f>
jmp    124a <test_urldecode+0x10a>
lea    0xe54(%rip),%rdi
lea    0xdfe(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_urldecode>:
sub    $0x88,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0xea8(%rip),%rsi
mov    %rsp,%rdi
mov    $0x80,%edx
xor    %eax,%eax
call   1040 <urldecode@plt>
test   %eax,%eax
je     11c4 <test_urldecode+0xa4>
mov    $0x616c6226,%eax
xor    (%rsp),%eax
mov    $0x722061,%ecx
xor    0x3(%rsp),%ecx
or     %eax,%ecx
je     11e9 <test_urldecode+0xc9>
lea    0xee5(%rip),%rdi
lea    0xef3(%rip),%rsi
lea    0xef1(%rip),%rdx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeec(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee6(%rip),%rdi
lea    0xeaa(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11e0 <test_urldecode+0xc0>
lea    0xe3e(%rip),%rdi
lea    0xe48(%rip),%rsi
lea    0xe5d(%rip),%rdx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe61(%rip),%rdi
jmp    11f0 <test_urldecode+0xd0>
lea    0xeb5(%rip),%rdi
lea    0xe5f(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x88,%rsp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%26bla+r\00"
@.str.1 = [17 x i8] c"[%s] failed: %s\0A\00"
@.str.2 = [28 x i8] c"urldecode(dest, param, 128)\00"
@.str.3 = [18 x i8] c"Failed to decode.\00"
@.str.4 = [14 x i8] c"%s -> FAILED\0A\00"
@__func__.test_urldecode = [15 x i8] c"test_urldecode\00"
@.str.5 = [7 x i8] c"&bla r\00"
@.str.6 = [21 x i8] c"expected [%s == %s]\0A\00"
@.str.7 = [5 x i8] c"dest\00"
@.str.8 = [9 x i8] c"\22&bla r\22\00"
@.str.9 = [11 x i8] c" a = \22%s\22\0A\00"
@.str.10 = [11 x i8] c" b = \22%s\22\0A\00"
@.str.11 = [10 x i8] c"%s -> OK\0A\00"
define void @test_urldecode() {
%1 = alloca i8*
%2 = alloca [128 x i8]
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %1
%3 = bitcast [128 x i8]* %2 to i8*
br label %4
4: ; preds = %0
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%6 = load i8*, i8** %1
%7 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @urldecode to i32 (i8*, i8*, i32, ...)*)(i8* %5, i8* %6, i32 128)
%8 = icmp ne i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %4
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__func__.test_urldecode, i64 0, i64 0))
br label %27
12: ; preds = %4
br label %13
13: ; preds = %12
br label %14
14: ; preds = %13
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %14
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__func__.test_urldecode, i64 0, i64 0))
br label %27
24: ; preds = %14
br label %25
25: ; preds = %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__func__.test_urldecode, i64 0, i64 0))
br label %27
27: ; preds = %25, %18, %9
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"%26bla+r\00"
@.str.1 = [17 x i8] c"[%s] failed: %s\0A\00"
@.str.2 = [28 x i8] c"urldecode(dest, param, 128)\00"
@.str.3 = [18 x i8] c"Failed to decode.\00"
@.str.4 = [14 x i8] c"%s -> FAILED\0A\00"
@__func__.test_urldecode = [15 x i8] c"test_urldecode\00"
@.str.5 = [7 x i8] c"&bla r\00"
@.str.6 = [21 x i8] c"expected [%s == %s]\0A\00"
@.str.7 = [5 x i8] c"dest\00"
@.str.8 = [9 x i8] c"\22&bla r\22\00"
@.str.9 = [11 x i8] c" a = \22%s\22\0A\00"
@.str.10 = [11 x i8] c" b = \22%s\22\0A\00"
@.str.11 = [10 x i8] c"%s -> OK\0A\00"
define void @test_urldecode() {
%1 = alloca [128 x i8]
%2 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%3 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @urldecode to i32 (i8*, i8*, i32, ...)*)(i8* %2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 128)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %14
7: ; preds = %0
%8 = call i32 @bcmp(i8* dereferenceable(7) %2, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i64 7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* %2)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %14
14: ; preds = %7, %10, %5
%15 = phi i8* [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), %10 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), %7 ]
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %15, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__func__.test_urldecode, i64 0, i64 0))
ret void
}