#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;
  int current_char = 0;
  int is_char = 0;
  int is_blank = 0;
  int is_first = 0;
  int word_length = 0;
  while ((c = getchar()) != EOF) {
    current_char++;
    word_length++;
    if (is_first == 0) {
      is_first = 1;
      putchar('\n');
    }
    if (c == ' ') {
      is_blank = 1;
      word_length = 0;
    } else {
      is_char = 1;
    }
    if (current_char < 20) {
      putchar(c);
    } else {
      if (is_char) {
        putchar(c);
      }
      if (is_blank) {
        current_char -= 20;
        putchar('\n');
      }
    }
    is_blank = 0;
    is_char = 0;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
mov    0x2e82(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1225 <main+0x105>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    119e <main+0x7e>
movl   $0x1,-0x18(%rbp)
mov    $0xa,%edi
call   1030 <putchar@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x20,%eax
jne    11be <main+0x9e>
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
jmp    11c5 <main+0xa5>
movl   $0x1,-0x10(%rbp)
cmpl   $0x14,-0xc(%rbp)
jge    11dd <main+0xbd>
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
jmp    1212 <main+0xf2>
cmpl   $0x0,-0x10(%rbp)
je     11f0 <main+0xd0>
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
cmpl   $0x0,-0x14(%rbp)
je     120d <main+0xed>
mov    -0xc(%rbp),%eax
sub    $0x14,%eax
mov    %eax,-0xc(%rbp)
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1212 <main+0xf2>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
jmp    1152 <main+0x32>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb6(%rip),%r14
cmp    (%r14),%al
je     11a0 <main+0x80>
mov    %eax,%ebx
mov    $0xa,%ebp
mov    $0xa,%edi
call   1030 <putchar@plt>
movsbl %bl,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r14),%al
je     11a0 <main+0x80>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0x13,%ebx
setge  %cl
cmp    $0x20,%al
sete   %dl
movzbl %al,%eax
lea    0x1(%rbx),%esi
add    $0xffffffed,%ebx
test   %dl,%cl
cmovne %ebp,%eax
cmove  %esi,%ebx
movsbl %al,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r14),%al
jne    1170 <main+0x50>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@EOF = global i8 0
define i32 @main() {
%1 = tail call signext i8 (...) @getchar()
%2 = load i8, i8* @EOF
%3 = icmp eq i8 %1, %2
br i1 %3, label %23, label %4
4: ; preds = %0
%5 = tail call i32 @putchar(i8 signext 10)
%6 = tail call i32 @putchar(i8 signext %1)
%7 = tail call signext i8 (...) @getchar()
%8 = load i8, i8* @EOF
%9 = icmp eq i8 %7, %8
br i1 %9, label %23, label %10
10: ; preds = %4, %10
%11 = phi i8 [ %20, %10 ], [ %7, %4 ]
%12 = phi i32 [ %18, %10 ], [ 1, %4 ]
%13 = icmp sgt i32 %12, 18
%14 = icmp eq i8 %11, 32
%15 = and i1 %13, %14
%16 = select i1 %15, i8 10, i8 %11
%17 = select i1 %15, i32 -19, i32 1
%18 = add nsw i32 %12, %17
%19 = tail call i32 @putchar(i8 signext %16)
%20 = tail call signext i8 (...) @getchar()
%21 = load i8, i8* @EOF
%22 = icmp eq i8 %20, %21
br i1 %22, label %23, label %10
23: ; preds = %10, %4, %0
ret i32 0
}