#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 /*<<< orphan*/ sscanf(char const *, char *, int *);
void urldecode_common(const char *from, char *to) {
  int tmp;
  while (*from) {
    if (*from == '%') {
      ++from;
      sscanf(from, "%2x", &tmp);
      ++from;
      *(to++) = (char)tmp;
    } else {
      *(to++) = *from;
    }
    from++;
  }
}


x86 assembly (clang, -O0):
<urldecode_common>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11ac <urldecode_common+0x9c>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
jne    1184 <urldecode_common+0x74>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeac(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1030 <sscanf@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    119b <urldecode_common+0x8b>
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1120 <urldecode_common+0x10>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<urldecode_common>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xedb(%rip),%r15
lea    0x4(%rsp),%r12
jmp    1153 <urldecode_common+0x43>
nopl   0x0(%rax)
lea    0x1(%rbx),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <sscanf@plt>
add    $0x2,%rbx
movzbl 0x4(%rsp),%eax
mov    %al,(%r14)
add    $0x1,%r14
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x25,%al
je     1130 <urldecode_common+0x20>
test   %al,%al
jne    1148 <urldecode_common+0x38>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%2x\00"
define void @urldecode_common(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
br label %6
6: ; preds = %31, %2
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 0
br i1 %9, label %10, label %34
10: ; preds = %6
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 37
br i1 %14, label %15, label %26
15: ; preds = %10
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %3
%18 = load i8*, i8** %3
%19 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %5)
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %3
%22 = load i32, i32* %5
%23 = trunc i32 %22 to i8
%24 = load i8*, i8** %4
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %4
store i8 %23, i8* %24
br label %31
26: ; preds = %10
%27 = load i8*, i8** %3
%28 = load i8, i8* %27
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %4
store i8 %28, i8* %29
br label %31
31: ; preds = %26, %15
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %3
br label %6
34: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%2x\00"
define void @urldecode_common(i8* nocapture %0, i8* nocapture writeonly %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
br label %5
5: ; preds = %15, %2
%6 = phi i8* [ %0, %2 ], [ %19, %15 ]
%7 = phi i8* [ %1, %2 ], [ %18, %15 ]
%8 = load i8, i8* %6
switch i8 %8, label %15 [
i8 0, label %20
i8 37, label %9
]
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %6, i64 1
%11 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%12 = getelementptr inbounds i8, i8* %6, i64 2
%13 = load i32, i32* %3
%14 = trunc i32 %13 to i8
br label %15
15: ; preds = %5, %9
%16 = phi i8 [ %14, %9 ], [ %8, %5 ]
%17 = phi i8* [ %12, %9 ], [ %6, %5 ]
%18 = getelementptr inbounds i8, i8* %7, i64 1
store i8 %16, i8* %7
%19 = getelementptr inbounds i8, i8* %17, i64 1
br label %5
20: ; preds = %5
ret void
}