#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 */
char strtol(char *, int /*<<< orphan*/ *, int);
void HTTP_DecodeURL(char *url) {
  int i, y;
  char parse[3];
  parse[2] = '\0';
  for (i = 0, y = 0; url[i] != '\0'; ++i, ++y) {
    if (url[i] == '%') {
      parse[0] = url[i + 1];
      parse[1] = url[i + 2];
      url[y] = strtol(parse, NULL, 16);
      y += 2;
    } else {
      url[y] = url[i];
    }
  }
}


x86 assembly (clang, -O0):
<HTTP_DecodeURL>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x0,-0x11(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11dd <HTTP_DecodeURL+0xcd>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x25,%eax
jne    11ab <HTTP_DecodeURL+0x9b>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x13(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x12(%rbp)
lea    -0x13(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1030 <strtol@plt>
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x10(%rbp)
jmp    11c1 <HTTP_DecodeURL+0xb1>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    11c6 <HTTP_DecodeURL+0xb6>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112e <HTTP_DecodeURL+0x1e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HTTP_DecodeURL>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
movb   $0x0,0x7(%rsp)
xor    %eax,%eax
lea    0x5(%rsp),%r14
xor    %ebx,%ebx
jmp    1167 <HTTP_DecodeURL+0x57>
nopl   0x0(%rax,%rax,1)
lea    0x1(%rax),%r12
movzbl 0x1(%r15,%rax,1),%ecx
mov    %cl,0x5(%rsp)
movzbl 0x2(%rax,%r15,1),%eax
mov    %al,0x6(%rsp)
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <strtol@plt>
movslq %ebx,%rbx
mov    %al,(%r15,%rbx,1)
add    $0x2,%ebx
add    $0x1,%ebx
mov    %r12,%rax
movzbl (%r15,%rax,1),%ecx
cmp    $0x25,%cl
je     1130 <HTTP_DecodeURL+0x20>
test   %cl,%cl
je     1185 <HTTP_DecodeURL+0x75>
movslq %ebx,%rdx
mov    %cl,(%r15,%rdx,1)
add    $0x1,%rax
add    $0x1,%ebx
jmp    1167 <HTTP_DecodeURL+0x57>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @HTTP_DecodeURL(i8* nocapture %0) {
%2 = alloca [3 x i8]
%3 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 2
store i8 0, i8* %4
%5 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 1
br label %6
6: ; preds = %26, %1
%7 = phi i64 [ %27, %26 ], [ 0, %1 ]
%8 = phi i32 [ %29, %26 ], [ 0, %1 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %7
%10 = load i8, i8* %9
switch i8 %10, label %22 [
i8 0, label %30
i8 37, label %11
]
11: ; preds = %6
%12 = add nuw i64 %7, 1
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
store i8 %14, i8* %3
%15 = add nuw nsw i64 %7, 2
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = load i8, i8* %16
store i8 %17, i8* %5
%18 = call signext i8 @strtol(i8* nocapture %3, i32* null, i32 16)
%19 = sext i32 %8 to i64
%20 = getelementptr inbounds i8, i8* %0, i64 %19
store i8 %18, i8* %20
%21 = add nsw i32 %8, 2
br label %26
22: ; preds = %6
%23 = sext i32 %8 to i64
%24 = getelementptr inbounds i8, i8* %0, i64 %23
store i8 %10, i8* %24
%25 = add nuw i64 %7, 1
br label %26
26: ; preds = %11, %22
%27 = phi i64 [ %12, %11 ], [ %25, %22 ]
%28 = phi i32 [ %21, %11 ], [ %8, %22 ]
%29 = add nsw i32 %28, 1
br label %6
30: ; preds = %6
ret void
}