#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 getchar();
int /*<<< orphan*/ printf(char *, char *, int);
int /*<<< orphan*/ putchar(char);
int main(void) {
  char line[1000];
  int flag;
  int c;
  int i;
  line[i = 0] = '\0';
  flag = 0;
  while ((c = getchar()) != EOF) {
    if (c == ' ' || c == '\t') {
      line[i++] = c;
      line[i] = '\0';
    } else if (c == '\n') {
      if (flag) {
        putchar('\n');
        flag = 0;
      }
      line[i = 0] = '\0';
    } else {
      printf("%s%c", line, c);
      line[i = 0] = '\0';
      flag = 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x3fc(%rbp)
movb   $0x0,-0x3f0(%rbp)
movl   $0x0,-0x3f4(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x3f8(%rbp)
mov    0x2e77(%rip),%rcx
cmp    (%rcx),%eax
je     124b <main+0x11b>
cmpl   $0x20,-0x3f8(%rbp)
je     1193 <main+0x63>
cmpl   $0x9,-0x3f8(%rbp)
jne    11c9 <main+0x99>
mov    -0x3f8(%rbp),%eax
mov    %al,%cl
mov    -0x3fc(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x3fc(%rbp)
cltq
mov    %cl,-0x3f0(%rbp,%rax,1)
movslq -0x3fc(%rbp),%rax
movb   $0x0,-0x3f0(%rbp,%rax,1)
jmp    1246 <main+0x116>
cmpl   $0xa,-0x3f8(%rbp)
jne    120d <main+0xdd>
cmpl   $0x0,-0x3f4(%rbp)
je     11f7 <main+0xc7>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x3f4(%rbp)
movl   $0x0,-0x3fc(%rbp)
movb   $0x0,-0x3f0(%rbp)
jmp    1241 <main+0x111>
lea    -0x3f0(%rbp),%rsi
mov    -0x3f8(%rbp),%edx
lea    0xddf(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x3fc(%rbp)
movb   $0x0,-0x3f0(%rbp)
movl   $0x1,-0x3f4(%rbp)
jmp    1246 <main+0x116>
jmp    115d <main+0x2d>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x3f0,%rsp
movb   $0x0,(%rsp)
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e97(%rip),%r12
cmp    (%r12),%eax
jne    1169 <main+0x39>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe90(%rip),%r14
mov    %rsp,%r15
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    119c <main+0x6c>
nopl   0x0(%rax)
movslq %ebx,%rcx
lea    0x1(%rcx),%rbx
mov    %al,(%rsp,%rcx,1)
movb   $0x0,0x1(%rsp,%rcx,1)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%r12),%eax
je     1157 <main+0x27>
cmp    $0x20,%eax
je     1180 <main+0x50>
cmp    $0xa,%eax
je     11d0 <main+0xa0>
cmp    $0x9,%eax
je     1180 <main+0x50>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1040 <printf@plt>
movb   $0x0,(%rsp)
xor    %ebx,%ebx
mov    $0x1,%ebp
jmp    118f <main+0x5f>
cs nopw 0x0(%rax,%rax,1)
nop
test   %ebp,%ebp
je     11de <main+0xae>
mov    $0xa,%edi
call   1030 <putchar@plt>
movb   $0x0,(%rsp)
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    118f <main+0x5f>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [5 x i8] c"%s%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
store i8 0, i8* %6
store i32 0, i32* %3
br label %7
7: ; preds = %43, %0
%8 = call i32 (...) @getchar()
store i32 %8, i32* %4
%9 = load i32, i32* @EOF
%10 = icmp ne i32 %8, %9
br i1 %10, label %11, label %44
11: ; preds = %7
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 32
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 9
br i1 %16, label %17, label %27
17: ; preds = %14, %11
%18 = load i32, i32* %4
%19 = trunc i32 %18 to i8
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
%22 = sext i32 %20 to i64
%23 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %22
store i8 %19, i8* %23
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %25
store i8 0, i8* %26
br label %43
27: ; preds = %14
%28 = load i32, i32* %4
%29 = icmp eq i32 %28, 10
br i1 %29, label %30, label %37
30: ; preds = %27
%31 = load i32, i32* %3
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = call i32 @putchar(i8 signext 10)
store i32 0, i32* %3
br label %35
35: ; preds = %33, %30
store i32 0, i32* %5
%36 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
store i8 0, i8* %36
br label %42
37: ; preds = %27
%38 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%39 = load i32, i32* %4
%40 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %38, i32 %39)
store i32 0, i32* %5
%41 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
store i8 0, i8* %41
store i32 1, i32* %3
br label %42
42: ; preds = %37, %35
br label %43
43: ; preds = %42, %17
br label %7
44: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [5 x i8] c"%s%c\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
store i8 0, i8* %2
%3 = call i32 (...) @getchar()
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %30, label %6
6: ; preds = %0, %24
%7 = phi i32 [ %27, %24 ], [ %3, %0 ]
%8 = phi i32 [ %26, %24 ], [ 0, %0 ]
%9 = phi i32 [ %25, %24 ], [ 0, %0 ]
switch i32 %7, label %22 [
i32 32, label %10
i32 9, label %10
i32 10, label %17
]
10: ; preds = %6, %6
%11 = trunc i32 %7 to i8
%12 = add nsw i32 %8, 1
%13 = sext i32 %8 to i64
%14 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %13
store i8 %11, i8* %14
%15 = sext i32 %12 to i64
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %15
store i8 0, i8* %16
br label %24
17: ; preds = %6
%18 = icmp eq i32 %9, 0
br i1 %18, label %21, label %19
19: ; preds = %17
%20 = call i32 @putchar(i8 signext 10)
br label %21
21: ; preds = %19, %17
store i8 0, i8* %2
br label %24
22: ; preds = %6
%23 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %2, i32 %7)
store i8 0, i8* %2
br label %24
24: ; preds = %21, %22, %10
%25 = phi i32 [ %9, %10 ], [ 0, %21 ], [ 1, %22 ]
%26 = phi i32 [ %12, %10 ], [ 0, %21 ], [ 0, %22 ]
%27 = call i32 (...) @getchar()
%28 = load i32, i32* @EOF
%29 = icmp eq i32 %27, %28
br i1 %29, label %30, label %6
30: ; preds = %24, %0
ret i32 0
}