#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 *);
char *url_decode_init(char *);
char *url_encode_init(char *);
int /*<<< orphan*/ url_free(char *);
int main(int argc, char *argv[]) {
  char data[] = "http://a/b/c /g;x?y#s";
  char *url;
  char *encode;
  char *decode;
  url = data;
  printf("url : %s\n", url);
  encode = url_encode_init(url);
  printf("after encode : %s\n", encode);
  decode = url_decode_init(encode);
  printf("after decode : %s\n", decode);
  url_free(decode);
  ;
  url_free(encode);
  ;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xea3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xea0(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe9e(%rip),%eax
mov    %eax,-0x20(%rbp)
mov    0xe98(%rip),%ax
mov    %ax,-0x1c(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1040 <url_encode_init@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
mov    -0x40(%rbp),%rdi
call   1060 <url_decode_init@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rsi
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
mov    -0x48(%rbp),%rdi
call   1050 <url_free@plt>
mov    -0x40(%rbp),%rdi
call   1050 <url_free@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movaps 0xeb2(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0x7323793f783b67,%rax
mov    %rax,0xe(%rsp)
lea    0xeae(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <url_encode_init@plt>
mov    %rax,%r14
lea    0xe9b(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    %r14,%rdi
call   1060 <url_decode_init@plt>
mov    %rax,%rbx
lea    0xe94(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1050 <url_free@plt>
mov    %r14,%rdi
call   1050 <url_free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.data = [22 x i8] c"http://a/b/c /g;x?y#s\00"
@.str = [10 x i8] c"url : %s\0A\00"
@.str.1 = [19 x i8] c"after encode : %s\0A\00"
@.str.2 = [19 x i8] c"after decode : %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [22 x i8]
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [22 x i8]* %6 to i8*
%11 = getelementptr inbounds [22 x i8], [22 x i8]* %6, i64 0, i64 0
store i8* %11, i8** %7
%12 = load i8*, i8** %7
%13 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i8*, i8** %7
%15 = call i8* @url_encode_init(i8* %14)
store i8* %15, i8** %8
%16 = load i8*, i8** %8
%17 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = load i8*, i8** %8
%19 = call i8* @url_decode_init(i8* %18)
store i8* %19, i8** %9
%20 = load i8*, i8** %9
%21 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%22 = load i8*, i8** %9
%23 = call i32 @url_free(i8* %22)
%24 = load i8*, i8** %8
%25 = call i32 @url_free(i8* %24)
ret i32 0
}

LLVM IR (-O2):
@__const.main.data = [22 x i8] c"http://a/b/c /g;x?y#s\00"
@.str = [10 x i8] c"url : %s\0A\00"
@.str.1 = [19 x i8] c"after encode : %s\0A\00"
@.str.2 = [19 x i8] c"after decode : %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [22 x i8]
%4 = getelementptr inbounds [22 x i8], [22 x i8]* %3, i64 0, i64 0
%5 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = call i8* @url_encode_init(i8* %4)
%7 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = call i8* @url_decode_init(i8* %6)
%9 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%10 = call i32 @url_free(i8* %8)
%11 = call i32 @url_free(i8* %6)
ret i32 0
}