#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 EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/ *);
void compress(char *src_filename, char *dest_filename) {
  FILE *srcf, *destf;
  int prevchar = 0, ch1;
  int count = 0;
  srcf = fopen(src_filename, "r");
  destf = fopen(dest_filename, "w");
  if (srcf == NULL) {
    printf("Cannot open %s for reading\n", src_filename);
  } else {
    ch1 = getc(srcf);
    while (ch1 != EOF) {
      if ((ch1 == 9) || (ch1 == 32))
        ch1 = getc(srcf);
      else if ((ch1 == '\n') && (prevchar == '\n'))
        ch1 = getc(srcf);
      else {
        putc(ch1, destf);
        count++;
        printf("%d\n", count);
      }
      prevchar = ch1;
      ch1 = getc(srcf);
    }
    fclose(srcf);
    fclose(destf);
  }
}


x86 assembly (clang, -O0):
<compress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe87(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b8 <compress+0x68>
mov    -0x8(%rbp),%rsi
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1274 <compress+0x124>
mov    -0x18(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    0x2e1a(%rip),%rcx
cmp    (%rcx),%eax
je     1262 <compress+0x112>
cmpl   $0x9,-0x28(%rbp)
je     11ea <compress+0x9a>
cmpl   $0x20,-0x28(%rbp)
jne    11fb <compress+0xab>
mov    -0x18(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0x28(%rbp)
jmp    124b <compress+0xfb>
cmpl   $0xa,-0x28(%rbp)
jne    1220 <compress+0xd0>
cmpl   $0xa,-0x24(%rbp)
jne    1220 <compress+0xd0>
mov    -0x18(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0x28(%rbp)
jmp    1246 <compress+0xf6>
mov    -0x28(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1050 <putc@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%esi
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    124b <compress+0xfb>
mov    -0x28(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0x28(%rbp)
jmp    11c4 <compress+0x74>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compress>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbp
mov    %rdi,%r15
lea    0xe98(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
lea    0xe8b(%rip),%rsi
mov    %rbp,%rdi
call   1060 <fopen@plt>
test   %rbx,%rbx
je     11ba <compress+0x6a>
mov    %rax,%r14
mov    %rbx,%rdi
call   1070 <getc@plt>
mov    0x2e52(%rip),%r13
cmp    0x0(%r13),%eax
jne    11d9 <compress+0x89>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>
lea    0xe43(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>
mov    %eax,%ebp
xor    %r12d,%r12d
xor    %r15d,%r15d
jmp    120d <compress+0xbd>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1070 <getc@plt>
mov    %eax,%ebp
mov    %ebp,%r15d
mov    %rbx,%rdi
call   1070 <getc@plt>
mov    %eax,%ebp
cmp    0x0(%r13),%eax
je     119c <compress+0x4c>
cmp    $0x20,%ebp
je     11f0 <compress+0xa0>
cmp    $0x9,%ebp
je     11f0 <compress+0xa0>
cmp    $0xa,%r15d
jne    1222 <compress+0xd2>
cmp    $0xa,%ebp
je     11f0 <compress+0xa0>
mov    %ebp,%edi
mov    %r14,%rsi
call   1050 <putc@plt>
add    $0x1,%r12d
lea    0xde9(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11fa <compress+0xaa>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [28 x i8] c"Cannot open %s for reading\0A\00"
@EOF = global i32 0
@.str.3 = [4 x i8] c"%d\0A\00"
define void @compress(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %7
store i32 0, i32* %9
%10 = load i8*, i8** %3
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %5
%12 = load i8*, i8** %4
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %13, i32** %6
%14 = load i32*, i32** %5
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load i8*, i8** %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %17)
br label %62
19: ; preds = %2
%20 = load i32*, i32** %5
%21 = call i32 @getc(i32* %20)
store i32 %21, i32* %8
br label %22
22: ; preds = %53, %19
%23 = load i32, i32* %8
%24 = load i32, i32* @EOF
%25 = icmp ne i32 %23, %24
br i1 %25, label %26, label %57
26: ; preds = %22
%27 = load i32, i32* %8
%28 = icmp eq i32 %27, 9
br i1 %28, label %32, label %29
29: ; preds = %26
%30 = load i32, i32* %8
%31 = icmp eq i32 %30, 32
br i1 %31, label %32, label %35
32: ; preds = %29, %26
%33 = load i32*, i32** %5
%34 = call i32 @getc(i32* %33)
store i32 %34, i32* %8
br label %53
35: ; preds = %29
%36 = load i32, i32* %8
%37 = icmp eq i32 %36, 10
br i1 %37, label %38, label %44
38: ; preds = %35
%39 = load i32, i32* %7
%40 = icmp eq i32 %39, 10
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i32*, i32** %5
%43 = call i32 @getc(i32* %42)
store i32 %43, i32* %8
br label %52
44: ; preds = %38, %35
%45 = load i32, i32* %8
%46 = load i32*, i32** %6
%47 = call i32 @putc(i32 %45, i32* %46)
%48 = load i32, i32* %9
%49 = add nsw i32 %48, 1
store i32 %49, i32* %9
%50 = load i32, i32* %9
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %50)
br label %52
52: ; preds = %44, %41
br label %53
53: ; preds = %52, %32
%54 = load i32, i32* %8
store i32 %54, i32* %7
%55 = load i32*, i32** %5
%56 = call i32 @getc(i32* %55)
store i32 %56, i32* %8
br label %22
57: ; preds = %22
%58 = load i32*, i32** %5
%59 = call i32 @fclose(i32* %58)
%60 = load i32*, i32** %6
%61 = call i32 @fclose(i32* %60)
br label %62
62: ; preds = %57, %16
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [28 x i8] c"Cannot open %s for reading\0A\00"
@EOF = global i32 0
@.str.3 = [4 x i8] c"%d\0A\00"
define void @compress(i8* %0, i8* nocapture %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %3, null
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %37
8: ; preds = %2
%9 = tail call i32 @getc(i32* %3)
%10 = load i32, i32* @EOF
%11 = icmp eq i32 %9, %10
br i1 %11, label %34, label %12
12: ; preds = %8, %28
%13 = phi i32 [ %30, %28 ], [ 0, %8 ]
%14 = phi i32 [ %31, %28 ], [ %9, %8 ]
%15 = phi i32 [ %29, %28 ], [ 0, %8 ]
switch i32 %14, label %18 [
i32 32, label %16
i32 9, label %16
]
16: ; preds = %12, %12
%17 = tail call i32 @getc(i32* %3)
br label %28
18: ; preds = %12
%19 = icmp eq i32 %14, 10
%20 = icmp eq i32 %15, 10
%21 = and i1 %20, %19
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = tail call i32 @getc(i32* %3)
br label %28
24: ; preds = %18
%25 = tail call i32 @putc(i32 %14, i32* %4)
%26 = add nsw i32 %13, 1
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %22, %24, %16
%29 = phi i32 [ %17, %16 ], [ %23, %22 ], [ %14, %24 ]
%30 = phi i32 [ %13, %16 ], [ %13, %22 ], [ %26, %24 ]
%31 = tail call i32 @getc(i32* %3)
%32 = load i32, i32* @EOF
%33 = icmp eq i32 %31, %32
br i1 %33, label %34, label %12
34: ; preds = %28, %8
%35 = tail call i32 @fclose(i32* %3)
%36 = tail call i32 @fclose(i32* %4)
br label %37
37: ; preds = %34, %6
ret void
}