#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();
scalar_t__ is_whitespace(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ putchar(int);
int main() {
  int current_char = EOF;
  int char_position = 0;
  int position_in_word = -1;
  while ((current_char = getchar()) != EOF) {
    ++char_position;
    if (char_position == 30 - 1) {
      if (is_whitespace(current_char)) {
        putchar('\n');
        char_position = 0;
        position_in_word = -1;
      } else {
        if (position_in_word == -1) {
          position_in_word = 1;
        } else {
          ++position_in_word;
        }
        if (position_in_word == 1) {
          printf("\n%c", current_char);
        } else {
          printf("-\n%c", current_char);
        }
        char_position = 0;
      }
    } else {
      if (is_whitespace(current_char)) {
        position_in_word = -1;
      } else if (position_in_word == -1) {
        position_in_word = 1;
      } else {
        ++position_in_word;
      }
      putchar(current_char);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e92(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0xffffffff,-0x10(%rbp)
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e6e(%rip),%rcx
cmp    (%rcx),%eax
je     126b <main+0x12b>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x1d,-0xc(%rbp)
jne    121c <main+0xdc>
mov    -0x8(%rbp),%edi
call   1050 <is_whitespace@plt>
cmp    $0x0,%rax
je     11c4 <main+0x84>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,-0xc(%rbp)
movl   $0xffffffff,-0x10(%rbp)
jmp    1217 <main+0xd7>
cmpl   $0xffffffff,-0x10(%rbp)
jne    11da <main+0x9a>
movl   $0x1,-0x10(%rbp)
jmp    11e3 <main+0xa3>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jne    1201 <main+0xc1>
mov    -0x8(%rbp),%esi
lea    0xe0a(%rip),%rdi
call   1040 <printf@plt>
jmp    1210 <main+0xd0>
mov    -0x8(%rbp),%esi
lea    0xdf5(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
jmp    1266 <main+0x126>
mov    -0x8(%rbp),%edi
call   1050 <is_whitespace@plt>
cmp    $0x0,%rax
je     123a <main+0xfa>
movl   $0xffffffff,-0x10(%rbp)
jmp    125e <main+0x11e>
cmpl   $0xffffffff,-0x10(%rbp)
jne    1250 <main+0x110>
movl   $0x1,-0x10(%rbp)
jmp    1259 <main+0x119>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    125e <main+0x11e>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    1169 <main+0x29>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e8f(%rip),%r13
cmp    0x0(%r13),%eax
jne    1170 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
mov    $0xffffffff,%ebx
mov    $0x1,%r12d
lea    0xe7c(%rip),%r15
xor    %r14d,%r14d
jmp    11b3 <main+0x73>
nopl   0x0(%rax)
inc    %ebx
cmove  %r12d,%ebx
neg    %rax
sbb    %eax,%eax
or     %eax,%ebx
mov    %ebp,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,%ebp
cmp    0x0(%r13),%eax
je     115f <main+0x1f>
add    $0x1,%r14d
mov    %ebp,%edi
call   1050 <is_whitespace@plt>
cmp    $0x1d,%r14d
jne    1190 <main+0x50>
test   %rax,%rax
je     11dd <main+0x9d>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xffffffff,%ebx
xor    %r14d,%r14d
jmp    11a4 <main+0x64>
inc    %ebx
cmove  %r12d,%ebx
cmp    $0x1,%ebx
jne    1200 <main+0xc0>
lea    0xe12(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
mov    $0x1,%ebx
xor    %r14d,%r14d
jmp    11a4 <main+0x64>
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
xor    %r14d,%r14d
jmp    11a4 <main+0x64>

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

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