#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 DecodeAldcString(char *, size_t, char **, size_t *);
int EncodeAldcString(char *, int /*<<< orphan*/, char **, size_t *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fwrite(char *, int, size_t, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, size_t);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strlen(char *);
int round_trip(char *s) {
  char *compressed;
  size_t compressed_len;
  char *decompressed;
  size_t decompressed_len;
  int r;
  r = EncodeAldcString(s, strlen(s), &compressed, &compressed_len);
  printf("Compressed to %lu bytes.\nCompressed Data:", compressed_len);
  r = DecodeAldcString(compressed, compressed_len, &decompressed,
                       &decompressed_len);
  free(compressed);
  printf("\nDecompressed to %lu bytes.\ndecompressed Data:", decompressed_len);
  fwrite(decompressed, 1, decompressed_len, stdout);
  return 0;
}


x86 assembly (clang, -O0):
<round_trip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%esi
lea    -0x10(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1050 <EncodeAldcString@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe62(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1080 <DecodeAldcString@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rsi
lea    0xe5b(%rip),%rdi
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    0x2dfd(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1070 <fwrite@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<round_trip>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
call   1040 <strlen@plt>
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <EncodeAldcString@plt>
mov    0x8(%rsp),%rsi
lea    0xe73(%rip),%rdi
call   1060 <printf@plt>
mov    0x10(%rsp),%rdi
mov    0x8(%rsp),%rsi
lea    0x18(%rsp),%rdx
mov    %rsp,%rcx
call   1080 <DecodeAldcString@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    (%rsp),%rsi
lea    0xe6c(%rip),%rdi
call   1060 <printf@plt>
mov    0x18(%rsp),%rdi
mov    (%rsp),%rdx
mov    0x2e0d(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1070 <fwrite@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Compressed to %lu bytes.\0ACompressed Data:\00"
@.str.1 = [47 x i8] c"\0ADecompressed to %lu bytes.\0Adecompressed Data:\00"
@stdout = global i32 0
define i32 @round_trip(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
store i8* %0, i8** %2
%8 = load i8*, i8** %2
%9 = load i8*, i8** %2
%10 = call i32 @strlen(i8* %9)
%11 = call i32 @EncodeAldcString(i8* %8, i32 %10, i8** %3, i64* %4)
store i32 %11, i32* %7
%12 = load i64, i64* %4
%13 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i64 %12)
%14 = load i8*, i8** %3
%15 = load i64, i64* %4
%16 = call i32 @DecodeAldcString(i8* %14, i64 %15, i8** %5, i64* %6)
store i32 %16, i32* %7
%17 = load i8*, i8** %3
%18 = call i32 @free(i8* %17)
%19 = load i64, i64* %6
%20 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i64 %19)
%21 = load i8*, i8** %5
%22 = load i64, i64* %6
%23 = load i32, i32* @stdout
%24 = call i32 @fwrite(i8* %21, i32 1, i64 %22, i32 %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [42 x i8] c"Compressed to %lu bytes.\0ACompressed Data:\00"
@.str.1 = [47 x i8] c"\0ADecompressed to %lu bytes.\0Adecompressed Data:\00"
@stdout = global i32 0
define i32 @round_trip(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i64
%6 = bitcast i8** %2 to i8*
%7 = bitcast i64* %3 to i8*
%8 = bitcast i8** %4 to i8*
%9 = bitcast i64* %5 to i8*
%10 = tail call i32 @strlen(i8* %0)
%11 = call i32 @EncodeAldcString(i8* %0, i32 %10, i8** %2, i64* %3)
%12 = load i64, i64* %3
%13 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i64 %12)
%14 = load i8*, i8** %2
%15 = load i64, i64* %3
%16 = call i32 @DecodeAldcString(i8* %14, i64 %15, i8** %4, i64* %5)
%17 = load i8*, i8** %2
%18 = call i32 @free(i8* %17)
%19 = load i64, i64* %5
%20 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i64 %19)
%21 = load i8*, i8** %4
%22 = load i64, i64* %5
%23 = load i32, i32* @stdout
%24 = call i32 @fwrite(i8* %21, i32 1, i64 %22, i32 %23)
ret i32 0
}