#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 */

/* Variables and functions */
int EOF;
int fgetc(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(void) {
  int in_char;
  int inside_cr = 0;
  int inside_space = 0;
  while (1) {
    in_char = fgetc(stdin);
    if (in_char == EOF) {
      return 0;
    } else if (in_char == 13) {
    } else if (in_char == 10) {
      if (inside_cr) {
        putc(10, stdout);
        putc(10, stdout);
        inside_cr = 0;
        continue;
      } else {
        in_char = ' ';
        inside_cr = 1;
      }
    }
    if (in_char == ' ') {
      if (!inside_space)
        putc(' ', stdout);
      inside_space = 1;
    } else {
      putc(in_char, stdout);
      inside_cr = 0;
      inside_space = 0;
    }
  }
  fprintf(stderr, "Error: should not reach here.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    0x2ea4(%rip),%rax
mov    (%rax),%edi
call   1030 <fgetc@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2e88(%rip),%rcx
cmp    (%rcx),%eax
jne    1168 <main+0x48>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret
cmpl   $0xd,-0x8(%rbp)
jne    1177 <main+0x57>
jmp    11d5 <main+0xb5>
cmpl   $0xa,-0x8(%rbp)
jne    11d0 <main+0xb0>
cmpl   $0x0,-0xc(%rbp)
je     11bd <main+0x9d>
mov    0x2e3e(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1040 <putc@plt>
mov    0x2e2b(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1040 <putc@plt>
movl   $0x0,-0xc(%rbp)
jmp    113d <main+0x1d>
movl   $0x20,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
jmp    11d0 <main+0xb0>
jmp    11d5 <main+0xb5>
jmp    11da <main+0xba>
cmpl   $0x20,-0x8(%rbp)
jne    120d <main+0xed>
cmpl   $0x0,-0x10(%rbp)
jne    1201 <main+0xe1>
mov    0x2ddb(%rip),%rax
mov    (%rax),%esi
mov    $0x20,%edi
call   1040 <putc@plt>
movl   $0x1,-0x10(%rbp)
jmp    122c <main+0x10c>
mov    -0x8(%rbp),%edi
mov    0x2db9(%rip),%rax
mov    (%rax),%esi
call   1040 <putc@plt>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
jmp    113d <main+0x1d>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2eb6(%rip),%r14
mov    (%r14),%edi
call   1030 <fgetc@plt>
mov    0x2e9f(%rip),%r15
cmp    (%r15),%eax
jne    1157 <main+0x37>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r12d,%r12d
mov    0x2e6f(%rip),%rbx
xor    %ebp,%ebp
jmp    1190 <main+0x70>
xor    %ebp,%ebp
xor    %r13d,%r13d
mov    (%rbx),%esi
mov    %eax,%edi
call   1040 <putc@plt>
mov    (%r14),%edi
call   1030 <fgetc@plt>
mov    %r13d,%r12d
cmp    (%r15),%eax
je     1146 <main+0x26>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    $0xa,%eax
jne    11c2 <main+0xa2>
test   %ebp,%ebp
je     11c9 <main+0xa9>
mov    (%rbx),%esi
mov    $0xa,%edi
call   1040 <putc@plt>
mov    (%rbx),%esi
mov    $0xa,%edi
call   1040 <putc@plt>
mov    (%r14),%edi
call   1030 <fgetc@plt>
xor    %ebp,%ebp
cmp    (%r15),%eax
jne    1190 <main+0x70>
jmp    1146 <main+0x26>
cmp    $0x20,%eax
jne    1165 <main+0x45>
jmp    11ce <main+0xae>
mov    $0x1,%ebp
mov    $0x1,%r13d
test   %r12d,%r12d
jne    1173 <main+0x53>
mov    $0x20,%eax
jmp    116a <main+0x4a>

LLVM IR (-O0):
@stdin = global i32 0
@EOF = global i32 0
@stdout = global i32 0
@stderr = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %0, %22, %45
%6 = load i32, i32* @stdin
%7 = call i32 @fgetc(i32 %6)
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = load i32, i32* @EOF
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %12
11: ; preds = %5
ret i32 0
12: ; preds = %5
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 13
br i1 %14, label %15, label %16
15: ; preds = %12
br label %30
16: ; preds = %12
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, 10
br i1 %18, label %19, label %29
19: ; preds = %16
%20 = load i32, i32* %3
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = load i32, i32* @stdout
%24 = call i32 @putc(i32 10, i32 %23)
%25 = load i32, i32* @stdout
%26 = call i32 @putc(i32 10, i32 %25)
store i32 0, i32* %3
br label %5
27: ; preds = %19
store i32 32, i32* %2
store i32 1, i32* %3
br label %28
28: ; preds = %27
br label %29
29: ; preds = %28, %16
br label %30
30: ; preds = %29, %15
br label %31
31: ; preds = %30
%32 = load i32, i32* %2
%33 = icmp eq i32 %32, 32
br i1 %33, label %34, label %41
34: ; preds = %31
%35 = load i32, i32* %4
%36 = icmp ne i32 %35, 0
br i1 %36, label %40, label %37
37: ; preds = %34
%38 = load i32, i32* @stdout
%39 = call i32 @putc(i32 32, i32 %38)
br label %40
40: ; preds = %37, %34
store i32 1, i32* %4
br label %45
41: ; preds = %31
%42 = load i32, i32* %2
%43 = load i32, i32* @stdout
%44 = call i32 @putc(i32 %42, i32 %43)
store i32 0, i32* %3
store i32 0, i32* %4
br label %45
45: ; preds = %41, %40
br label %5
}

LLVM IR (-O2):
@stdin = global i32 0
@EOF = global i32 0
@stdout = global i32 0
@stderr = global i32 0
define i32 @main() {
%1 = load i32, i32* @stdin
%2 = tail call i32 @fgetc(i32 %1)
%3 = load i32, i32* @EOF
%4 = icmp eq i32 %2, %3
br i1 %4, label %9, label %5
5: ; preds = %0, %33
%6 = phi i32 [ %37, %33 ], [ %2, %0 ]
%7 = phi i32 [ %35, %33 ], [ 0, %0 ]
%8 = phi i32 [ %34, %33 ], [ 0, %0 ]
br label %10
9: ; preds = %33, %15, %0
ret i32 0
10: ; preds = %5, %15
%11 = phi i32 [ %6, %5 ], [ %21, %15 ]
%12 = phi i32 [ %8, %5 ], [ 0, %15 ]
switch i32 %11, label %27 [
i32 10, label %13
i32 32, label %24
]
13: ; preds = %10
%14 = icmp eq i32 %12, 0
br i1 %14, label %24, label %15
15: ; preds = %13
%16 = load i32, i32* @stdout
%17 = tail call i32 @putc(i32 10, i32 %16)
%18 = load i32, i32* @stdout
%19 = tail call i32 @putc(i32 10, i32 %18)
%20 = load i32, i32* @stdin
%21 = tail call i32 @fgetc(i32 %20)
%22 = load i32, i32* @EOF
%23 = icmp eq i32 %21, %22
br i1 %23, label %9, label %10
24: ; preds = %10, %13
%25 = phi i32 [ 1, %13 ], [ %12, %10 ]
%26 = icmp eq i32 %7, 0
br i1 %26, label %27, label %33
27: ; preds = %10, %24
%28 = phi i32 [ 32, %24 ], [ %11, %10 ]
%29 = phi i32 [ %25, %24 ], [ 0, %10 ]
%30 = phi i32 [ 1, %24 ], [ 0, %10 ]
%31 = load i32, i32* @stdout
%32 = tail call i32 @putc(i32 %28, i32 %31)
br label %33
33: ; preds = %27, %24
%34 = phi i32 [ %25, %24 ], [ %29, %27 ]
%35 = phi i32 [ 1, %24 ], [ %30, %27 ]
%36 = load i32, i32* @stdin
%37 = tail call i32 @fgetc(i32 %36)
%38 = load i32, i32* @EOF
%39 = icmp eq i32 %37, %38
br i1 %39, label %9, label %5
}