#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 */
char *compress_blocks(char *);
char *compress_string(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ strlen(char *);
int main() {
  char *test = "aabbbcddeeeeeeeeeeee";
  printf("%s :: compressed :: %s\n", test, compress_string(test, strlen(test)));
  printf("%s :: compressed blocks :: %s\n", test, compress_blocks(test));
  test = "abbccdde";
  printf("%s :: compressed :: %s\n", test, compress_string(test, strlen(test)));
  test = "uuuseeerr";
  printf("%s :: compressed blocks :: %s\n", test, compress_blocks(test));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%esi
call   1030 <compress_string@plt>
mov    -0x38(%rbp),%rsi
mov    %rax,%rdx
lea    0xe89(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <compress_blocks@plt>
mov    -0x30(%rbp),%rsi
mov    %rax,%rdx
lea    0xe7d(%rip),%rdi
call   1060 <printf@plt>
lea    0xe90(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
call   1030 <compress_string@plt>
mov    -0x20(%rbp),%rsi
mov    %rax,%rdx
lea    0xe23(%rip),%rdi
call   1060 <printf@plt>
lea    0xe57(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <compress_blocks@plt>
mov    -0x18(%rbp),%rsi
mov    %rax,%rdx
lea    0xe0c(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xeb4(%rip),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <compress_string@plt>
lea    0xeb0(%rip),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1040 <compress_blocks@plt>
lea    0xeab(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1060 <printf@plt>
lea    0xeb5(%rip),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <compress_string@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1060 <printf@plt>
lea    0xe97(%rip),%rbx
mov    %rbx,%rdi
call   1040 <compress_blocks@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1060 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"aabbbcddeeeeeeeeeeee\00"
@.str.1 = [24 x i8] c"%s :: compressed :: %s\0A\00"
@.str.2 = [31 x i8] c"%s :: compressed blocks :: %s\0A\00"
@.str.3 = [9 x i8] c"abbccdde\00"
@.str.4 = [10 x i8] c"uuuseeerr\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8** %2
%3 = load i8*, i8** %2
%4 = load i8*, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strlen(i8* %5)
%7 = call i8* @compress_string(i8* %4, i32 %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %3, i8* %7)
%9 = load i8*, i8** %2
%10 = load i8*, i8** %2
%11 = call i8* @compress_blocks(i8* %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %9, i8* %11)
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8** %2
%13 = load i8*, i8** %2
%14 = load i8*, i8** %2
%15 = load i8*, i8** %2
%16 = call i32 @strlen(i8* %15)
%17 = call i8* @compress_string(i8* %14, i32 %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %13, i8* %17)
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8** %2
%19 = load i8*, i8** %2
%20 = load i8*, i8** %2
%21 = call i8* @compress_blocks(i8* %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %19, i8* %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"aabbbcddeeeeeeeeeeee\00"
@.str.1 = [24 x i8] c"%s :: compressed :: %s\0A\00"
@.str.2 = [31 x i8] c"%s :: compressed blocks :: %s\0A\00"
@.str.3 = [9 x i8] c"abbccdde\00"
@.str.4 = [10 x i8] c"uuuseeerr\00"
define i32 @main() {
%1 = tail call i32 @strlen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%2 = tail call i8* @compress_string(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = tail call i8* @compress_blocks(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = tail call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%7 = tail call i8* @compress_string(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %6)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%9 = tail call i8* @compress_blocks(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%10 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %9)
ret i32 0
}