#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 */
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct TYPE_5__ {
  int /*<<< orphan*/ *next_out;
  void *avail_out;
  int /*<<< orphan*/ *next_in;
  void *avail_in;
  void *opaque;
  void *zfree;
  void *zalloc;
};
typedef TYPE_1__ z_stream;
typedef void *uInt;
typedef int /*<<< orphan*/ ret;
typedef int /*<<< orphan*/ Bytef;

/* Variables and functions */
int /*<<< orphan*/ Z_BEST_COMPRESSION;
int /*<<< orphan*/ Z_FINISH;
void *Z_NULL;
int /*<<< orphan*/ deflate(TYPE_1__ *, int /*<<< orphan*/);
int /*<<< orphan*/ deflateEnd(TYPE_1__ *);
int /*<<< orphan*/ deflateInit(TYPE_1__ *, int /*<<< orphan*/);
char *malloc(char *);
int /*<<< orphan*/ printf(char *, ...);
char *strlen(char const *);
char *compressString(const char *str) {
  char *ret = malloc(strlen(str) + 1);
  printf("Uncompressed size is: %lu\n", strlen(str));
  printf("Uncompressed string is: %s\n", str);
  printf("\n----------\n\n");
  z_stream defstream;
  defstream.zalloc = Z_NULL;
  defstream.zfree = Z_NULL;
  defstream.opaque = Z_NULL;
  defstream.avail_in = (uInt)strlen(str) + 1;
  defstream.next_in = (Bytef *)str;
  defstream.avail_out = (uInt)sizeof(ret);
  defstream.next_out = (Bytef *)ret;
  deflateInit(&defstream, Z_BEST_COMPRESSION);
  deflate(&defstream, Z_FINISH);
  deflateEnd(&defstream);
  printf("Compressed size is: %lu\n", strlen(ret));
  printf("Compressed string is: %s\n", ret);
  return ret;
}


x86 assembly (clang, -O0):
<compressString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rsi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e12(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e04(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    0x2df6(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0x8,%eax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    0x2dce(%rip),%rax
mov    (%rax),%esi
lea    -0x48(%rbp),%rdi
call   1060 <deflateInit@plt>
mov    0x2da4(%rip),%rax
mov    (%rax),%esi
lea    -0x48(%rbp),%rdi
call   1050 <deflate@plt>
lea    -0x48(%rbp),%rdi
call   1080 <deflateEnd@plt>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rsi
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compressString>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%rbx
call   1040 <strlen@plt>
lea    0x1(%rax),%rdi
call   1080 <malloc@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0xe66(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe70(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeae(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e10(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x30(%rsp)
mov    %rax,0x28(%rsp)
mov    %rax,0x20(%rsp)
mov    %rbx,%rdi
call   1040 <strlen@plt>
add    $0x1,%rax
mov    %rax,0x18(%rsp)
mov    %rbx,0x10(%rsp)
movq   $0x8,0x8(%rsp)
mov    %r14,(%rsp)
mov    0x2de4(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <deflateInit@plt>
mov    0x2db8(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1060 <deflate@plt>
mov    %rbx,%rdi
call   1090 <deflateEnd@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0xdfe(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe06(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_5__ = type { i32*, i8*, i32*, i8*, i8*, i8*, i8* }
@.str = [27 x i8] c"Uncompressed size is: %lu\0A\00"
@.str.1 = [28 x i8] c"Uncompressed string is: %s\0A\00"
@.str.2 = [14 x i8] c"\0A----------\0A\0A\00"
@Z_NULL = global i8* null
@Z_BEST_COMPRESSION = global i32 0
@Z_FINISH = global i32 0
@.str.3 = [25 x i8] c"Compressed size is: %lu\0A\00"
@.str.4 = [26 x i8] c"Compressed string is: %s\0A\00"
define i8* @compressString(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca %struct.TYPE_5__
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @strlen(i8* %5)
%7 = getelementptr inbounds i8, i8* %6, i64 1
%8 = call i8* @malloc(i8* %7)
store i8* %8, i8** %3
%9 = load i8*, i8** %2
%10 = call i8* @strlen(i8* %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i8*, i8** %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%15 = load i8*, i8** @Z_NULL
%16 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %4, i32 0, i32 6
store i8* %15, i8** %16
%17 = load i8*, i8** @Z_NULL
%18 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %4, i32 0, i32 5
store i8* %17, i8** %18
%19 = load i8*, i8** @Z_NULL
%20 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %4, i32 0, i32 4
store i8* %19, i8** %20
%21 = load i8*, i8** %2
%22 = call i8* @strlen(i8* %21)
%23 = getelementptr i8, i8* %22, i64 1
%24 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %4, i32 0, i32 3
store i8* %23, i8** %24
%25 = load i8*, i8** %2
%26 = bitcast i8* %25 to i32*
%27 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %4, i32 0, i32 2
store i32* %26, i32** %27
%28 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %4, i32 0, i32 1
store i8* inttoptr (i64 8 to i8*), i8** %28
%29 = load i8*, i8** %3
%30 = bitcast i8* %29 to i32*
%31 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %4, i32 0, i32 0
store i32* %30, i32** %31
%32 = load i32, i32* @Z_BEST_COMPRESSION
%33 = call i32 @deflateInit(%struct.TYPE_5__* %4, i32 %32)
%34 = load i32, i32* @Z_FINISH
%35 = call i32 @deflate(%struct.TYPE_5__* %4, i32 %34)
%36 = call i32 @deflateEnd(%struct.TYPE_5__* %4)
%37 = load i8*, i8** %3
%38 = call i8* @strlen(i8* %37)
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %38)
%40 = load i8*, i8** %3
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %40)
%42 = load i8*, i8** %3
ret i8* %42
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i32*, i8*, i32*, i8*, i8*, i8*, i8* }
@.str = [27 x i8] c"Uncompressed size is: %lu\0A\00"
@.str.1 = [28 x i8] c"Uncompressed string is: %s\0A\00"
@Z_NULL = global i8* null
@Z_BEST_COMPRESSION = global i32 0
@Z_FINISH = global i32 0
@.str.3 = [25 x i8] c"Compressed size is: %lu\0A\00"
@.str.4 = [26 x i8] c"Compressed string is: %s\0A\00"
@str = [13 x i8] c"\0A----------\0A\00"
define i8* @compressString(i8* %0) {
%2 = alloca %struct.TYPE_5__
%3 = tail call i8* @strlen(i8* %0)
%4 = getelementptr inbounds i8, i8* %3, i64 1
%5 = tail call i8* @malloc(i8* %4)
%6 = tail call i8* @strlen(i8* %0)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%10 = bitcast %struct.TYPE_5__* %2 to i8*
%11 = load i8*, i8** @Z_NULL
%12 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %2, i64 0, i32 6
store i8* %11, i8** %12
%13 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %2, i64 0, i32 5
store i8* %11, i8** %13
%14 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %2, i64 0, i32 4
store i8* %11, i8** %14
%15 = tail call i8* @strlen(i8* %0)
%16 = getelementptr i8, i8* %15, i64 1
%17 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %2, i64 0, i32 3
store i8* %16, i8** %17
%18 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %2, i64 0, i32 2
%19 = bitcast i32** %18 to i8**
store i8* %0, i8** %19
%20 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %2, i64 0, i32 1
store i8* inttoptr (i64 8 to i8*), i8** %20
%21 = bitcast %struct.TYPE_5__* %2 to i8**
store i8* %5, i8** %21
%22 = load i32, i32* @Z_BEST_COMPRESSION
%23 = call i32 @deflateInit(%struct.TYPE_5__* %2, i32 %22)
%24 = load i32, i32* @Z_FINISH
%25 = call i32 @deflate(%struct.TYPE_5__* %2, i32 %24)
%26 = call i32 @deflateEnd(%struct.TYPE_5__* %2)
%27 = call i8* @strlen(i8* %5)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %27)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %5)
ret i8* %5
}