#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 fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  FILE *fp;
  FILE *out;
  int c, next;
  int newline_count = 0;
  int line_pos = 0;
  fp = fopen(argv[1], "rb");
  if (!fp) {
    return 1;
  }
  out = fopen(argv[2], "wb");
  if (!out) {
    return 1;
  }
  while (1) {
    c = fgetc(fp);
    if (c == EOF) {
      break;
    } else if (c == '\r') {
    } else if (c == '\n') {
      newline_count++;
      line_pos = 0;
    } else {
      if (newline_count > 1) {
        fputc('\r', out);
        fputc('\n', out);
        fputc('\r', out);
        fputc('\n', out);
      } else if (newline_count == 1) {
        fputc(' ', out);
      }
      newline_count = 0;
      if (c == '-' && line_pos == 0) {
      } else {
        fputc(c, out);
        line_pos++;
      }
    }
  }
  fclose(fp);
  fclose(out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe8d(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1193 <main+0x53>
movl   $0x1,-0x4(%rbp)
jmp    12de <main+0x19e>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe61(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11c2 <main+0x82>
movl   $0x1,-0x4(%rbp)
jmp    12de <main+0x19e>
jmp    11c7 <main+0x87>
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2e0b(%rip),%rcx
cmp    (%rcx),%eax
jne    11ea <main+0xaa>
jmp    12c5 <main+0x185>
cmpl   $0xd,-0x24(%rbp)
jne    11f9 <main+0xb9>
jmp    12bb <main+0x17b>
cmpl   $0xa,-0x24(%rbp)
jne    1218 <main+0xd8>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
jmp    12b6 <main+0x176>
cmpl   $0x1,-0x2c(%rbp)
jle    125f <main+0x11f>
mov    -0x20(%rbp),%rsi
mov    $0xd,%edi
call   1050 <fputc@plt>
mov    -0x20(%rbp),%rsi
mov    $0xa,%edi
call   1050 <fputc@plt>
mov    -0x20(%rbp),%rsi
mov    $0xd,%edi
call   1050 <fputc@plt>
mov    -0x20(%rbp),%rsi
mov    $0xa,%edi
call   1050 <fputc@plt>
jmp    127c <main+0x13c>
cmpl   $0x1,-0x2c(%rbp)
jne    1277 <main+0x137>
mov    -0x20(%rbp),%rsi
mov    $0x20,%edi
call   1050 <fputc@plt>
jmp    127c <main+0x13c>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x2d,-0x24(%rbp)
jne    129c <main+0x15c>
cmpl   $0x0,-0x30(%rbp)
jne    129c <main+0x15c>
jmp    12b1 <main+0x171>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1050 <fputc@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    12b6 <main+0x176>
jmp    12bb <main+0x17b>
jmp    12c0 <main+0x180>
jmp    11c7 <main+0x87>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xea7(%rip),%rsi
call   1060 <fopen@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     11a8 <main+0x68>
mov    %rax,%r15
mov    0x10(%rbx),%rdi
lea    0xe8d(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11a8 <main+0x68>
mov    %rax,%r14
mov    %r15,%rdi
call   1040 <fgetc@plt>
mov    0x2e56(%rip),%rbx
cmp    (%rbx),%eax
jne    11b9 <main+0x79>
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
xor    %r13d,%r13d
xor    %r12d,%r12d
jmp    11e5 <main+0xa5>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r12d
xor    %r13d,%r13d
mov    %r15,%rdi
call   1040 <fgetc@plt>
mov    %eax,%ebp
cmp    (%rbx),%eax
je     1196 <main+0x56>
cmp    $0xd,%ebp
je     11d7 <main+0x97>
cmp    $0xa,%ebp
je     11d0 <main+0x90>
cmp    $0x2,%r12d
jl     1223 <main+0xe3>
mov    $0xd,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
mov    $0xa,%ebx
mov    $0xa,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
mov    $0xd,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
jmp    122e <main+0xee>
mov    $0x20,%ebx
cmp    $0x1,%r12d
jne    1238 <main+0xf8>
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
xor    %r12d,%r12d
cmp    $0x2d,%ebp
jne    124a <main+0x10a>
test   %r13d,%r13d
jne    124a <main+0x10a>
xor    %r13d,%r13d
jmp    1258 <main+0x118>
mov    %ebp,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
add    $0x1,%r13d
mov    0x2d89(%rip),%rbx
jmp    11d7 <main+0x97>

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [3 x i8] c"wb\00"
@EOF = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %10
store i32 0, i32* %11
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %6
%16 = load i32*, i32** %6
%17 = icmp ne i32* %16, null
br i1 %17, label %19, label %18
18: ; preds = %2
store i32 1, i32* %3
br label %86
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %7
%24 = load i32*, i32** %7
%25 = icmp ne i32* %24, null
br i1 %25, label %27, label %26
26: ; preds = %19
store i32 1, i32* %3
br label %86
27: ; preds = %19
br label %28
28: ; preds = %27, %80
%29 = load i32*, i32** %6
%30 = call i32 @fgetc(i32* %29)
store i32 %30, i32* %8
%31 = load i32, i32* %8
%32 = load i32, i32* @EOF
%33 = icmp eq i32 %31, %32
br i1 %33, label %34, label %35
34: ; preds = %28
br label %81
35: ; preds = %28
%36 = load i32, i32* %8
%37 = icmp eq i32 %36, 13
br i1 %37, label %38, label %39
38: ; preds = %35
br label %79
39: ; preds = %35
%40 = load i32, i32* %8
%41 = icmp eq i32 %40, 10
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = load i32, i32* %10
%44 = add nsw i32 %43, 1
store i32 %44, i32* %10
store i32 0, i32* %11
br label %78
45: ; preds = %39
%46 = load i32, i32* %10
%47 = icmp sgt i32 %46, 1
br i1 %47, label %48, label %57
48: ; preds = %45
%49 = load i32*, i32** %7
%50 = call i32 @fputc(i32 13, i32* %49)
%51 = load i32*, i32** %7
%52 = call i32 @fputc(i32 10, i32* %51)
%53 = load i32*, i32** %7
%54 = call i32 @fputc(i32 13, i32* %53)
%55 = load i32*, i32** %7
%56 = call i32 @fputc(i32 10, i32* %55)
br label %64
57: ; preds = %45
%58 = load i32, i32* %10
%59 = icmp eq i32 %58, 1
br i1 %59, label %60, label %63
60: ; preds = %57
%61 = load i32*, i32** %7
%62 = call i32 @fputc(i32 32, i32* %61)
br label %63
63: ; preds = %60, %57
br label %64
64: ; preds = %63, %48
store i32 0, i32* %10
%65 = load i32, i32* %8
%66 = icmp eq i32 %65, 45
br i1 %66, label %67, label %71
67: ; preds = %64
%68 = load i32, i32* %11
%69 = icmp eq i32 %68, 0
br i1 %69, label %70, label %71
70: ; preds = %67
br label %77
71: ; preds = %67, %64
%72 = load i32, i32* %8
%73 = load i32*, i32** %7
%74 = call i32 @fputc(i32 %72, i32* %73)
%75 = load i32, i32* %11
%76 = add nsw i32 %75, 1
store i32 %76, i32* %11
br label %77
77: ; preds = %71, %70
br label %78
78: ; preds = %77, %42
br label %79
79: ; preds = %78, %38
br label %80
80: ; preds = %79
br label %28
81: ; preds = %34
%82 = load i32*, i32** %6
%83 = call i32 @fclose(i32* %82)
%84 = load i32*, i32** %7
%85 = call i32 @fclose(i32* %84)
store i32 0, i32* %3
br label %86
86: ; preds = %81, %26, %18
%87 = load i32, i32* %3
ret i32 %87
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [3 x i8] c"wb\00"
@EOF = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %49, label %7
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %49, label %12
12: ; preds = %7
%13 = tail call i32 @fgetc(i32* %5)
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %13, %14
br i1 %15, label %46, label %16
16: ; preds = %12, %40
%17 = phi i32 [ %43, %40 ], [ %13, %12 ]
%18 = phi i32 [ %42, %40 ], [ 0, %12 ]
%19 = phi i32 [ %41, %40 ], [ 0, %12 ]
switch i32 %17, label %22 [
i32 13, label %40
i32 10, label %20
]
20: ; preds = %16
%21 = add nsw i32 %19, 1
br label %40
22: ; preds = %16
%23 = icmp sgt i32 %19, 1
br i1 %23, label %24, label %28
24: ; preds = %22
%25 = tail call i32 @fputc(i32 13, i32* %10)
%26 = tail call i32 @fputc(i32 10, i32* %10)
%27 = tail call i32 @fputc(i32 13, i32* %10)
br label %30
28: ; preds = %22
%29 = icmp eq i32 %19, 1
br i1 %29, label %30, label %33
30: ; preds = %28, %24
%31 = phi i32 [ 10, %24 ], [ 32, %28 ]
%32 = tail call i32 @fputc(i32 %31, i32* %10)
br label %33
33: ; preds = %30, %28
%34 = icmp eq i32 %17, 45
%35 = icmp eq i32 %18, 0
%36 = select i1 %34, i1 %35, i1 false
br i1 %36, label %40, label %37
37: ; preds = %33
%38 = tail call i32 @fputc(i32 %17, i32* %10)
%39 = add nsw i32 %18, 1
br label %40
40: ; preds = %16, %37, %33, %20
%41 = phi i32 [ %19, %16 ], [ %21, %20 ], [ 0, %33 ], [ 0, %37 ]
%42 = phi i32 [ %18, %16 ], [ 0, %20 ], [ 0, %33 ], [ %39, %37 ]
%43 = tail call i32 @fgetc(i32* %5)
%44 = load i32, i32* @EOF
%45 = icmp eq i32 %43, %44
br i1 %45, label %46, label %16
46: ; preds = %40, %12
%47 = tail call i32 @fclose(i32* %5)
%48 = tail call i32 @fclose(i32* %10)
br label %49
49: ; preds = %7, %2, %46
%50 = phi i32 [ 0, %46 ], [ 1, %2 ], [ 1, %7 ]
ret i32 %50
}