#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 */
char EOF;
char getchar();
int /*<<< orphan*/ putchar(char);
int main() {
  char c;
  char buff[1001];
  int ptr = 0;
  int trailing_spaces = 0;
  while ((c = getchar()) != EOF) {
    if (c == '\n') {
      ptr = 0;
      continue;
    }
    if (c == ' ' || c == '\t') {
      buff[ptr++] = c;
      continue;
    } else {
      int i;
      for (i = 0; i < ptr; ++i) {
        putchar(buff[i]);
      }
      ptr = 0;
      putchar(c);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x3f4(%rbp)
movl   $0x0,-0x3f8(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
mov    0x2e8e(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1219 <main+0xf9>
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
jne    1181 <main+0x61>
movl   $0x0,-0x3f4(%rbp)
jmp    1146 <main+0x26>
movsbl -0x5(%rbp),%eax
cmp    $0x20,%eax
je     119b <main+0x7b>
movsbl -0x5(%rbp),%eax
cmp    $0x9,%eax
jne    11bd <main+0x9d>
mov    -0x5(%rbp),%cl
mov    -0x3f4(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x3f4(%rbp)
cltq
mov    %cl,-0x3f0(%rbp,%rax,1)
jmp    1146 <main+0x26>
movl   $0x0,-0x3fc(%rbp)
mov    -0x3fc(%rbp),%eax
cmp    -0x3f4(%rbp),%eax
jge    1201 <main+0xe1>
movslq -0x3fc(%rbp),%rax
movsbl -0x3f0(%rbp,%rax,1),%edi
ff
call   1030 <putchar@plt>
mov    -0x3fc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3fc(%rbp)
jmp    11c7 <main+0xa7>
movl   $0x0,-0x3f4(%rbp)
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
jmp    1146 <main+0x26>
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
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eab(%rip),%r14
cmp    (%r14),%al
jne    1154 <main+0x34>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%r12d
xor    %eax,%eax
jmp    117f <main+0x5f>
nopl   0x0(%rax,%rax,1)
movslq %eax,%rcx
add    $0x1,%eax
mov    %r12b,(%rsp,%rcx,1)
mov    %eax,%r15d
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%r12d
mov    %r15d,%eax
cmp    (%r14),%r12b
je     1142 <main+0x22>
cmp    $0x9,%r12b
je     1160 <main+0x40>
xor    %r15d,%r15d
cmp    $0xa,%r12b
je     116d <main+0x4d>
cmp    $0x20,%r12b
je     1160 <main+0x40>
test   %eax,%eax
jle    11b2 <main+0x92>
mov    %eax,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax)
movsbl (%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11a0 <main+0x80>
movsbl %r12b,%edi
call   1030 <putchar@plt>
jmp    116d <main+0x4d>

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

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