#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int _hex(char);
scalar_t__ isxdigit(char);
void StrDecode(char *to, char *from) {
  for (; *from != '\0'; ++to, ++from) {
    if (from[0] == '%' && isxdigit(from[1]) && isxdigit(from[2])) {
      *to = _hex(from[1]) * 16 + _hex(from[2]);
      from += 2;
    } else {
      *to = *from;
    }
  }
  *to = '\0';
}


x86 assembly (clang, -O0):
<StrDecode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11ec <StrDecode+0xcc>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
jne    11be <StrDecode+0x9e>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1040 <isxdigit@plt>
cmp    $0x0,%rax
je     11be <StrDecode+0x9e>
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%edi
call   1040 <isxdigit@plt>
cmp    $0x0,%rax
je     11be <StrDecode+0x9e>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <_hex@plt>
shl    $0x4,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%edi
call   1030 <_hex@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
add    %ecx,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
jmp    11ca <StrDecode+0xaa>
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
jmp    11cf <StrDecode+0xaf>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1130 <StrDecode+0x10>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<StrDecode>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
jmp    1142 <StrDecode+0x22>
nop
test   %al,%al
je     1187 <StrDecode+0x67>
movzbl (%rbx),%eax
mov    %al,(%r14)
add    $0x1,%r14
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x25,%al
jne    1130 <StrDecode+0x10>
movsbl 0x1(%rbx),%edi
call   1040 <isxdigit@plt>
test   %rax,%rax
je     1134 <StrDecode+0x14>
movsbl 0x2(%rbx),%edi
call   1040 <isxdigit@plt>
test   %rax,%rax
je     1134 <StrDecode+0x14>
lea    0x2(%rbx),%r15
movsbl 0x1(%rbx),%edi
call   1030 <_hex@plt>
mov    %eax,%ebp
shl    $0x4,%ebp
movsbl 0x2(%rbx),%edi
call   1030 <_hex@plt>
add    %ebp,%eax
mov    %r15,%rbx
jmp    1137 <StrDecode+0x17>
movb   $0x0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @StrDecode(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
br label %5
5: ; preds = %48, %2
%6 = load i8*, i8** %4
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %53
10: ; preds = %5
%11 = load i8*, i8** %4
%12 = getelementptr inbounds i8, i8* %11, i64 0
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 37
br i1 %15, label %16, label %43
16: ; preds = %10
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i8, i8* %18
%20 = call i64 @isxdigit(i8 signext %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %43
22: ; preds = %16
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 2
%25 = load i8, i8* %24
%26 = call i64 @isxdigit(i8 signext %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %43
28: ; preds = %22
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i64 1
%31 = load i8, i8* %30
%32 = call i32 @_hex(i8 signext %31)
%33 = mul nsw i32 %32, 16
%34 = load i8*, i8** %4
%35 = getelementptr inbounds i8, i8* %34, i64 2
%36 = load i8, i8* %35
%37 = call i32 @_hex(i8 signext %36)
%38 = add nsw i32 %33, %37
%39 = trunc i32 %38 to i8
%40 = load i8*, i8** %3
store i8 %39, i8* %40
%41 = load i8*, i8** %4
%42 = getelementptr inbounds i8, i8* %41, i64 2
store i8* %42, i8** %4
br label %47
43: ; preds = %22, %16, %10
%44 = load i8*, i8** %4
%45 = load i8, i8* %44
%46 = load i8*, i8** %3
store i8 %45, i8* %46
br label %47
47: ; preds = %43, %28
br label %48
48: ; preds = %47
%49 = load i8*, i8** %3
%50 = getelementptr inbounds i8, i8* %49, i32 1
store i8* %50, i8** %3
%51 = load i8*, i8** %4
%52 = getelementptr inbounds i8, i8* %51, i32 1
store i8* %52, i8** %4
br label %5
53: ; preds = %5
%54 = load i8*, i8** %3
store i8 0, i8* %54
ret void
}

LLVM IR (-O2):
define void @StrDecode(i8* nocapture writeonly %0, i8* nocapture %1) {
br label %3
3: ; preds = %27, %2
%4 = phi i8* [ %0, %2 ], [ %30, %27 ]
%5 = phi i8* [ %1, %2 ], [ %31, %27 ]
%6 = load i8, i8* %5
switch i8 %6, label %25 [
i8 0, label %32
i8 37, label %7
]
7: ; preds = %3
%8 = getelementptr inbounds i8, i8* %5, i64 1
%9 = load i8, i8* %8
%10 = tail call i64 @isxdigit(i8 signext %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %25, label %12
12: ; preds = %7
%13 = getelementptr inbounds i8, i8* %5, i64 2
%14 = load i8, i8* %13
%15 = tail call i64 @isxdigit(i8 signext %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %25, label %17
17: ; preds = %12
%18 = load i8, i8* %8
%19 = tail call i32 @_hex(i8 signext %18)
%20 = shl nsw i32 %19, 4
%21 = load i8, i8* %13
%22 = tail call i32 @_hex(i8 signext %21)
%23 = add nsw i32 %22, %20
%24 = trunc i32 %23 to i8
br label %27
25: ; preds = %3, %12, %7
%26 = load i8, i8* %5
br label %27
27: ; preds = %17, %25
%28 = phi i8 [ %26, %25 ], [ %24, %17 ]
%29 = phi i8* [ %5, %25 ], [ %13, %17 ]
store i8 %28, i8* %4
%30 = getelementptr inbounds i8, i8* %4, i64 1
%31 = getelementptr inbounds i8, i8* %29, i64 1
br label %3
32: ; preds = %3
store i8 0, i8* %4
ret void
}