#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(unsigned char *, size_t, size_t, int /*<<< orphan*/ *);
scalar_t__ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
unsigned char *malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ system(char *);
void data_compress(unsigned char *s, int slen, unsigned char **t, int *tlen) {
  FILE *Outfile;
  FILE *Infile;
  int i;
  system("rm -f FileXbzipTmp.*");
  Outfile = fopen("FileXbzipTmp.dat", "wb");
  if (!Outfile) {
    printf("Error in opening Outfile! (DataCompress)");
    exit(-1);
  }
  fwrite(s, sizeof(unsigned char), slen, Outfile);
  fclose(Outfile);
  system("./ppmd.exe e -m100 -o10 FileXbzipTmp.dat");
  Infile = fopen("FileXbzipTmp.pmd", "rb");
  if (!Infile) {
    printf("Error in opening Infile! (DataCompress)");
    exit(-1);
  }
  if (fseek(Infile, 0, SEEK_END) != 0)
    exit(-1);
  *tlen = ftell(Infile);
  *t = malloc(*tlen);
  if (!(*t)) {
    printf("Error in Malloc! (DataCompress)");
    exit(-1);
  }
  rewind(Infile);
  i = fread(*t, (size_t)1, (size_t)*tlen, Infile);
  if (i != *tlen) {
    printf("Incorrect fread! (DataCompress)");
    exit(-1);
  }
  fclose(Infile);
  system("rm -f FileXbzipTmp.*");
}


x86 assembly (clang, -O0):
<data_compress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    0xe32(%rip),%rdi
call   1050 <system@plt>
lea    0xe7f(%rip),%rdi
lea    0xe34(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    120b <data_compress+0x5b>
lea    0xe1c(%rip),%rdi
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
call   10d0 <fwrite@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xe11(%rip),%rdi
call   1050 <system@plt>
lea    0xe2e(%rip),%rdi
lea    0xe38(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    126d <data_compress+0xbd>
lea    0xe20(%rip),%rdi
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x30(%rbp),%rdi
mov    0x2d70(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10a0 <fseek@plt>
cmp    $0x0,%rax
je     1295 <data_compress+0xe5>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x30(%rbp),%rdi
call   1080 <ftell@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
call   1090 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    12df <data_compress+0x12f>
lea    0xdd6(%rip),%rdi
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x30(%rbp),%rdi
call   1070 <rewind@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rax
movslq (%rax),%rdx
mov    -0x30(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
je     132c <data_compress+0x17c>
lea    0xda9(%rip),%rdi
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xcc4(%rip),%rdi
call   1050 <system@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<data_compress>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r15
mov    %rdx,%r14
mov    %esi,%r12d
mov    %rdi,%rbx
lea    0xe35(%rip),%rdi
call   1050 <system@plt>
lea    0xe82(%rip),%rdi
lea    0xe37(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     129f <data_compress+0xef>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r12d,%edx
mov    %rax,%rcx
call   10d0 <fwrite@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
lea    0xe30(%rip),%rdi
call   1050 <system@plt>
lea    0xe4d(%rip),%rdi
lea    0xe57(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     12a8 <data_compress+0xf8>
mov    %rax,%rbx
mov    0x2db0(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10a0 <fseek@plt>
test   %rax,%rax
jne    12b1 <data_compress+0x101>
mov    %rbx,%rdi
call   1080 <ftell@plt>
mov    %eax,(%r15)
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,(%r14)
test   %rax,%rax
je     12bb <data_compress+0x10b>
mov    %rbx,%rdi
call   1070 <rewind@plt>
mov    (%r14),%rdi
movslq (%r15),%rdx
mov    $0x1,%esi
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    (%r15),%eax
jne    12c4 <data_compress+0x114>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xd6e(%rip),%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <system@plt>
lea    0xd72(%rip),%rdi
jmp    12cb <data_compress+0x11b>
lea    0xdcf(%rip),%rdi
jmp    12cb <data_compress+0x11b>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
lea    0xde4(%rip),%rdi
jmp    12cb <data_compress+0x11b>
lea    0xdfb(%rip),%rdi
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"rm -f FileXbzipTmp.*\00"
@.str.1 = [17 x i8] c"FileXbzipTmp.dat\00"
@.str.2 = [3 x i8] c"wb\00"
@.str.3 = [41 x i8] c"Error in opening Outfile! (DataCompress)\00"
@.str.4 = [41 x i8] c"./ppmd.exe e -m100 -o10 FileXbzipTmp.dat\00"
@.str.5 = [17 x i8] c"FileXbzipTmp.pmd\00"
@.str.6 = [3 x i8] c"rb\00"
@.str.7 = [40 x i8] c"Error in opening Infile! (DataCompress)\00"
@SEEK_END = global i32 0
@.str.8 = [32 x i8] c"Error in Malloc! (DataCompress)\00"
@.str.9 = [32 x i8] c"Incorrect fread! (DataCompress)\00"
define void @data_compress(i8* %0, i32 %1, i8** %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
store i32* %3, i32** %8
%12 = call i32 @system(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%13 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %13, i32** %9
%14 = load i32*, i32** %9
%15 = icmp ne i32* %14, null
br i1 %15, label %19, label %16
16: ; preds = %4
%17 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 @exit(i32 -1)
unreachable
19: ; preds = %4
%20 = load i8*, i8** %5
%21 = load i32, i32* %6
%22 = load i32*, i32** %9
%23 = call i32 @fwrite(i8* %20, i32 1, i32 %21, i32* %22)
%24 = load i32*, i32** %9
%25 = call i32 @fclose(i32* %24)
%26 = call i32 @system(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
%27 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
store i32* %27, i32** %10
%28 = load i32*, i32** %10
%29 = icmp ne i32* %28, null
br i1 %29, label %33, label %30
30: ; preds = %19
%31 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0))
%32 = call i32 @exit(i32 -1)
unreachable
33: ; preds = %19
%34 = load i32*, i32** %10
%35 = load i32, i32* @SEEK_END
%36 = call i64 @fseek(i32* %34, i32 0, i32 %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %33
%39 = call i32 @exit(i32 -1)
unreachable
40: ; preds = %33
%41 = load i32*, i32** %10
%42 = call i32 @ftell(i32* %41)
%43 = load i32*, i32** %8
store i32 %42, i32* %43
%44 = load i32*, i32** %8
%45 = load i32, i32* %44
%46 = call i8* @malloc(i32 %45)
%47 = load i8**, i8*** %7
store i8* %46, i8** %47
%48 = load i8**, i8*** %7
%49 = load i8*, i8** %48
%50 = icmp ne i8* %49, null
br i1 %50, label %54, label %51
51: ; preds = %40
%52 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
%53 = call i32 @exit(i32 -1)
unreachable
54: ; preds = %40
%55 = load i32*, i32** %10
%56 = call i32 @rewind(i32* %55)
%57 = load i8**, i8*** %7
%58 = load i8*, i8** %57
%59 = load i32*, i32** %8
%60 = load i32, i32* %59
%61 = sext i32 %60 to i64
%62 = load i32*, i32** %10
%63 = call i32 @fread(i8* %58, i64 1, i64 %61, i32* %62)
store i32 %63, i32* %11
%64 = load i32, i32* %11
%65 = load i32*, i32** %8
%66 = load i32, i32* %65
%67 = icmp ne i32 %64, %66
br i1 %67, label %68, label %71
68: ; preds = %54
%69 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0))
%70 = call i32 @exit(i32 -1)
unreachable
71: ; preds = %54
%72 = load i32*, i32** %10
%73 = call i32 @fclose(i32* %72)
%74 = call i32 @system(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"rm -f FileXbzipTmp.*\00"
@.str.1 = [17 x i8] c"FileXbzipTmp.dat\00"
@.str.2 = [3 x i8] c"wb\00"
@.str.3 = [41 x i8] c"Error in opening Outfile! (DataCompress)\00"
@.str.4 = [41 x i8] c"./ppmd.exe e -m100 -o10 FileXbzipTmp.dat\00"
@.str.5 = [17 x i8] c"FileXbzipTmp.pmd\00"
@.str.6 = [3 x i8] c"rb\00"
@.str.7 = [40 x i8] c"Error in opening Infile! (DataCompress)\00"
@SEEK_END = global i32 0
@.str.8 = [32 x i8] c"Error in Malloc! (DataCompress)\00"
@.str.9 = [32 x i8] c"Incorrect fread! (DataCompress)\00"
define void @data_compress(i8* nocapture %0, i32 %1, i8** nocapture %2, i32* nocapture %3) {
%5 = tail call i32 @system(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %11
8: ; preds = %4
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
%10 = tail call i32 @exit(i32 -1)
unreachable
11: ; preds = %4
%12 = tail call i32 @fwrite(i8* %0, i32 1, i32 %1, i32* %6)
%13 = tail call i32 @fclose(i32* %6)
%14 = tail call i32 @system(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
%15 = tail call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0))
%19 = tail call i32 @exit(i32 -1)
unreachable
20: ; preds = %11
%21 = load i32, i32* @SEEK_END
%22 = tail call i64 @fseek(i32* %15, i32 0, i32 %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %20
%25 = tail call i32 @exit(i32 -1)
unreachable
26: ; preds = %20
%27 = tail call i32 @ftell(i32* %15)
store i32 %27, i32* %3
%28 = tail call i8* @malloc(i32 %27)
store i8* %28, i8** %2
%29 = icmp eq i8* %28, null
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
%32 = tail call i32 @exit(i32 -1)
unreachable
33: ; preds = %26
%34 = tail call i32 @rewind(i32* %15)
%35 = load i8*, i8** %2
%36 = load i32, i32* %3
%37 = sext i32 %36 to i64
%38 = tail call i32 @fread(i8* %35, i64 1, i64 %37, i32* %15)
%39 = load i32, i32* %3
%40 = icmp eq i32 %38, %39
br i1 %40, label %44, label %41
41: ; preds = %33
%42 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0))
%43 = tail call i32 @exit(i32 -1)
unreachable
44: ; preds = %33
%45 = tail call i32 @fclose(i32* %15)
%46 = tail call i32 @system(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
ret void
}