#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*/ printf(char *, char *);
int /*<<< orphan*/ tsk_free(void **);
char *tsk_url_decode(char const *);
char *tsk_url_encode(char *);
void test_url() {
  const char *url =
      "http://xcap.example.org/resource-lists/users/sip:RCSUser@example.org/"
      "index/~~/resource-lists/list%5B@name=%22rcs%22%5D";
  char *str1, *str2;
  str1 = tsk_url_decode(url);
  printf("test_url/// decoded url:%s\n", str1);
  str2 = tsk_url_encode(str1);
  printf("test_url/// encoded url:%s\n", str2);
  tsk_free((void **)&str1);
  tsk_free((void **)&str2);
}


x86 assembly (clang, -O0):
<test_url>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <tsk_url_decode@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xf0c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <tsk_url_encode@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xf0b(%rip),%rdi
call   1030 <printf@plt>
lea    -0x10(%rbp),%rdi
call   1050 <tsk_free@plt>
lea    -0x18(%rbp),%rdi
call   1050 <tsk_free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_url>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
call   1040 <tsk_url_decode@plt>
mov    %rax,%rbx
mov    %rax,0x8(%rsp)
lea    0xf17(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1060 <tsk_url_encode@plt>
mov    %rax,(%rsp)
lea    0xf18(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
lea    0x8(%rsp),%rdi
call   1050 <tsk_free@plt>
mov    %rsp,%rdi
call   1050 <tsk_free@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [119 x i8] c"http://xcap.example.org/resource-lists/users/sip:RCSUser@example.org/index/~~/resource-lists/list%5B@name=%22rcs%22%5D\00"
@.str.1 = [28 x i8] c"test_url/// decoded url:%s\0A\00"
@.str.2 = [28 x i8] c"test_url/// encoded url:%s\0A\00"
define void @test_url() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
store i8* getelementptr inbounds ([119 x i8], [119 x i8]* @.str, i64 0, i64 0), i8** %1
%4 = load i8*, i8** %1
%5 = call i8* @tsk_url_decode(i8* %4)
store i8* %5, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = load i8*, i8** %2
%9 = call i8* @tsk_url_encode(i8* %8)
store i8* %9, i8** %3
%10 = load i8*, i8** %3
%11 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = call i32 @tsk_free(i8** %2)
%13 = call i32 @tsk_free(i8** %3)
ret void
}

LLVM IR (-O2):
@.str = [119 x i8] c"http://xcap.example.org/resource-lists/users/sip:RCSUser@example.org/index/~~/resource-lists/list%5B@name=%22rcs%22%5D\00"
@.str.1 = [28 x i8] c"test_url/// decoded url:%s\0A\00"
@.str.2 = [28 x i8] c"test_url/// encoded url:%s\0A\00"
define void @test_url() {
%1 = alloca i8*
%2 = alloca i8*
%3 = bitcast i8** %1 to i8*
%4 = bitcast i8** %2 to i8*
%5 = tail call i8* @tsk_url_decode(i8* getelementptr inbounds ([119 x i8], [119 x i8]* @.str, i64 0, i64 0))
store i8* %5, i8** %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = tail call i8* @tsk_url_encode(i8* %5)
store i8* %7, i8** %2
%8 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%9 = call i32 @tsk_free(i8** %1)
%10 = call i32 @tsk_free(i8** %2)
ret void
}