#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ compress(char *, char *);
int /*<<< orphan*/ decompress(char *, char *);
int /*<<< orphan*/ diffFiles(char *, char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
long long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, ...);
int main(void) {
  char *input = "test.txt";
  compress(input, "comp.txt");
  decompress("comp.txt", "decomp.txt");
  diffFiles(input, "decomp.txt");
  FILE *in = fopen(input, "r");
  FILE *out = fopen("comp.txt", "r");
  long long sizeIn, sizeOut;
  fseek(in, 0, SEEK_END);
  sizeIn = ftell(in);
  fseek(out, 0, SEEK_END);
  sizeOut = ftell(out);
  printf("%ld bytes vs %ld bytes\n", sizeIn, sizeOut);
  printf("%.2f%% compression\n", 100 * (1 - ((float)sizeOut / (float)sizeIn)));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xe89(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1030 <compress@plt>
lea    0xe79(%rip),%rdi
lea    0xe70(%rip),%rsi
call   1090 <decompress@plt>
mov    -0x8(%rbp),%rdi
lea    0xe60(%rip),%rsi
call   1060 <diffFiles@plt>
mov    -0x8(%rbp),%rdi
lea    0xe5b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe42(%rip),%rdi
lea    0xe44(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2dfc(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <fseek@plt>
mov    -0x10(%rbp),%rdi
call   1050 <ftell@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2ddb(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1050 <ftell@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    %eax,%esi
mov    -0x28(%rbp),%rdx
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cvtsi2ssq -0x28(%rbp),%xmm0
cvtsi2ssq -0x20(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  0xdb1(%rip),%xmm1
subss  %xmm0,%xmm1
movss  0xda1(%rip),%xmm0
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%esi
lea    0xdc8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xe89(%rip),%r15
lea    0xe8d(%rip),%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <compress@plt>
lea    0xe79(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1090 <decompress@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <diffFiles@plt>
lea    0xe67(%rip),%r12
mov    %r15,%rdi
mov    %r12,%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %r12,%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
mov    0x2e10(%rip),%r12
mov    (%r12),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <fseek@plt>
mov    %rbx,%rdi
call   1050 <ftell@plt>
mov    %rax,%r15
mov    (%r12),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1070 <fseek@plt>
mov    %r14,%rdi
call   1050 <ftell@plt>
mov    %rax,%rbx
lea    0xe0d(%rip),%rdi
mov    %r15d,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
cvtsi2ss %rbx,%xmm0
cvtsi2ss %r15,%xmm1
divss  %xmm1,%xmm0
movss  0xdcc(%rip),%xmm1
subss  %xmm0,%xmm1
mulss  0xdc4(%rip),%xmm1
cvttss2si %xmm1,%esi
lea    0xdeb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"test.txt\00"
@.str.1 = [9 x i8] c"comp.txt\00"
@.str.2 = [11 x i8] c"decomp.txt\00"
@.str.3 = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@.str.4 = [24 x i8] c"%ld bytes vs %ld bytes\0A\00"
@.str.5 = [20 x i8] c"%.2f%% compression\0A\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i64
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %1
%6 = load i8*, i8** %1
%7 = call i32 @compress(i8* %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @decompress(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%9 = load i8*, i8** %1
%10 = call i32 @diffFiles(i8* %9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%11 = load i8*, i8** %1
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %12, i32** %2
%13 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %13, i32** %3
%14 = load i32*, i32** %2
%15 = load i32, i32* @SEEK_END
%16 = call i32 @fseek(i32* %14, i32 0, i32 %15)
%17 = load i32*, i32** %2
%18 = call i64 @ftell(i32* %17)
store i64 %18, i64* %4
%19 = load i32*, i32** %3
%20 = load i32, i32* @SEEK_END
%21 = call i32 @fseek(i32* %19, i32 0, i32 %20)
%22 = load i32*, i32** %3
%23 = call i64 @ftell(i32* %22)
store i64 %23, i64* %5
%24 = load i64, i64* %4
%25 = trunc i64 %24 to i32
%26 = load i64, i64* %5
%27 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %25, i64 %26)
%28 = load i64, i64* %5
%29 = sitofp i64 %28 to float
%30 = load i64, i64* %4
%31 = sitofp i64 %30 to float
%32 = fdiv float %29, %31
%33 = fsub float 1.000000e+00, %32
%34 = fmul float 1.000000e+02, %33
%35 = fptosi float %34 to i32
%36 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %35)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"test.txt\00"
@.str.1 = [9 x i8] c"comp.txt\00"
@.str.2 = [11 x i8] c"decomp.txt\00"
@.str.3 = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@.str.4 = [24 x i8] c"%ld bytes vs %ld bytes\0A\00"
@.str.5 = [20 x i8] c"%.2f%% compression\0A\00"
define i32 @main() {
%1 = tail call i32 @compress(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @decompress(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%3 = tail call i32 @diffFiles(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%6 = load i32, i32* @SEEK_END
%7 = tail call i32 @fseek(i32* %4, i32 0, i32 %6)
%8 = tail call i64 @ftell(i32* %4)
%9 = load i32, i32* @SEEK_END
%10 = tail call i32 @fseek(i32* %5, i32 0, i32 %9)
%11 = tail call i64 @ftell(i32* %5)
%12 = trunc i64 %8 to i32
%13 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %12, i64 %11)
%14 = sitofp i64 %11 to float
%15 = sitofp i64 %8 to float
%16 = fdiv float %14, %15
%17 = fsub float 1.000000e+00, %16
%18 = fmul float %17, 1.000000e+02
%19 = fptosi float %18 to i32
%20 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %19)
ret i32 0
}