#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*/ dump(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strlen(char *);
int url_decode(char *, char *, int);
int url_encode(char *, char *, int /*<<< orphan*/);
int main() {
  char *src = "ÄãºÃ£¡";
  char dest[100];
  char temp[100];
  dump(src, strlen(src), 12);
  int len = url_encode(src, dest, strlen(src));
  dest[len] = '\0';
  printf("%d\n", len);
  len = url_decode(temp, dest, len);
  printf("%d\n", len);
  temp[len] = '\0';
  printf("%s\n", temp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x110(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x110(%rbp),%rdi
mov    %eax,%esi
mov    $0xc,%edx
call   1060 <dump@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x108(%rbp)
lea    -0x80(%rbp),%rax
mov    %rax,-0x100(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x108(%rbp),%rdi
mov    -0x100(%rbp),%rsi
mov    %eax,%edx
call   1070 <url_encode@plt>
mov    %eax,-0xf4(%rbp)
movslq -0xf4(%rbp),%rax
movb   $0x0,-0x80(%rbp,%rax,1)
mov    -0xf4(%rbp),%esi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xf0(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    -0xf4(%rbp),%edx
call   1050 <url_decode@plt>
mov    %eax,-0xf4(%rbp)
mov    -0xf4(%rbp),%esi
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0xf4(%rbp),%rax
movb   $0x0,-0xf0(%rbp,%rax,1)
lea    -0xf0(%rbp),%rsi
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xd8,%rsp
lea    0xe8b(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0xc,%edx
call   1070 <dump@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0x70(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1080 <url_encode@plt>
movslq %eax,%rbx
movb   $0x0,0x70(%rsp,%rbx,1)
lea    0xe58(%rip),%r15
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%r12
mov    %r12,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1060 <url_decode@plt>
mov    %eax,%ebx
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movslq %ebx,%rax
movb   $0x0,(%rsp,%rax,1)
mov    %r12,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"\C3\84\C3\A3\C2\BA\C3\83\C2\A3\C2\A1\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
%5 = alloca i32
store i32 0, i32* %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %2
%6 = load i8*, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
%9 = call i32 @dump(i8* %6, i32 %8, i32 12)
%10 = load i8*, i8** %2
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%12 = load i8*, i8** %2
%13 = call i32 @strlen(i8* %12)
%14 = call i32 @url_encode(i8* %10, i8* %11, i32 %13)
store i32 %14, i32* %5
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %16
store i8 0, i8* %17
%18 = load i32, i32* %5
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%22 = load i32, i32* %5
%23 = call i32 @url_decode(i8* %20, i8* %21, i32 %22)
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %27
store i8 0, i8* %28
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %29)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"\C3\84\C3\A3\C2\BA\C3\83\C2\A3\C2\A1\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @strlen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @dump(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %5, i32 12)
%7 = tail call i32 @strlen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @url_encode(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %3, i32 %7)
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %9
store i8 0, i8* %10
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%12 = call i32 @url_decode(i8* %4, i8* %3, i32 %8)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = sext i32 %12 to i64
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %14
store i8 0, i8* %15
%16 = call i32 @puts(i8* %4)
ret i32 0
}