#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*/ free(char *);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ urldecode(char *, char *, size_t);
int /*<<< orphan*/ xmlencode(char *, char *, int);
int url_decode_xml_encode(char *dst, char *src, size_t src_size) {
  char *url_decoded_key = (char *)malloc(src_size + 1);
  if (url_decoded_key == NULL) {
    return 0;
  }
  urldecode(url_decoded_key, src, src_size);
  xmlencode(dst, url_decoded_key, 2 * src_size);
  free(url_decoded_key);
  return 1;
}


x86 assembly (clang, -O0):
<url_decode_xml_encode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    117c <url_decode_xml_encode+0x3c>
movl   $0x0,-0x4(%rbp)
jmp    11b4 <url_decode_xml_encode+0x74>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <urldecode@plt>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rax
shl    $0x1,%rax
mov    %eax,%edx
call   1040 <xmlencode@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<url_decode_xml_encode>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r12
mov    %rdi,%r14
lea    0x1(%rdx),%rdi
call   1050 <malloc@plt>
test   %rax,%rax
je     118e <url_decode_xml_encode+0x4e>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1060 <urldecode@plt>
add    %ebx,%ebx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1040 <xmlencode@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    $0x1,%eax
jmp    1190 <url_decode_xml_encode+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @url_decode_xml_encode(i8* %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
%9 = load i64, i64* %7
%10 = add i64 %9, 1
%11 = call i64 @malloc(i64 %10)
%12 = inttoptr i64 %11 to i8*
store i8* %12, i8** %8
%13 = load i8*, i8** %8
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %16
15: ; preds = %3
store i32 0, i32* %4
br label %29
16: ; preds = %3
%17 = load i8*, i8** %8
%18 = load i8*, i8** %6
%19 = load i64, i64* %7
%20 = call i32 @urldecode(i8* %17, i8* %18, i64 %19)
%21 = load i8*, i8** %5
%22 = load i8*, i8** %8
%23 = load i64, i64* %7
%24 = mul i64 2, %23
%25 = trunc i64 %24 to i32
%26 = call i32 @xmlencode(i8* %21, i8* %22, i32 %25)
%27 = load i8*, i8** %8
%28 = call i32 @free(i8* %27)
store i32 1, i32* %4
br label %29
29: ; preds = %16, %15
%30 = load i32, i32* %4
ret i32 %30
}

LLVM IR (-O2):
define i32 @url_decode_xml_encode(i8* %0, i8* %1, i64 %2) {
%4 = add i64 %2, 1
%5 = tail call i64 @malloc(i64 %4)
%6 = inttoptr i64 %5 to i8*
%7 = icmp eq i64 %5, 0
br i1 %7, label %14, label %8
8: ; preds = %3
%9 = tail call i32 @urldecode(i8* %6, i8* %1, i64 %2)
%10 = trunc i64 %2 to i32
%11 = shl i32 %10, 1
%12 = tail call i32 @xmlencode(i8* %0, i8* %6, i32 %11)
%13 = tail call i32 @free(i8* %6)
br label %14
14: ; preds = %3, %8
%15 = phi i32 [ 1, %8 ], [ 0, %3 ]
ret i32 %15
}