#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 *, ...);
int main() {
  int currCharCount, currChar;
  currCharCount = currChar = 0;
  while ((currChar = getchar()) != EOF) {
    if (currChar == '\n') {
      currCharCount = 0;
      printf("\n");
    } else if ((currChar == ' ' || currChar == '\t') && currCharCount >= 80) {
      currCharCount = 0;
      printf("\n");
    } else {
      currCharCount++;
      printf("%c", currChar);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e9a(%rip),%rcx
cmp    (%rcx),%eax
je     11d6 <main+0xb6>
cmpl   $0xa,-0xc(%rbp)
jne    117a <main+0x5a>
movl   $0x0,-0x8(%rbp)
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d1 <main+0xb1>
cmpl   $0x20,-0xc(%rbp)
je     118e <main+0x6e>
cmpl   $0x9,-0xc(%rbp)
jne    11b2 <main+0x92>
cmpl   $0x50,-0x8(%rbp)
jl     11b2 <main+0x92>
movl   $0x0,-0x8(%rbp)
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11cc <main+0xac>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d1 <main+0xb1>
jmp    113d <main+0x1d>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eaf(%rip),%r12
cmp    (%r12),%eax
jne    114a <main+0x2a>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xa,%r15d
xor    %ecx,%ecx
jmp    1174 <main+0x54>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %ebp,%ecx
cmp    (%r12),%eax
je     113f <main+0x1f>
xor    %ebp,%ebp
mov    $0xa,%edi
cmp    $0xa,%eax
je     1160 <main+0x40>
cmp    $0x20,%eax
sete   %dl
cmp    $0x9,%eax
sete   %bl
or     %dl,%bl
cmp    $0x50,%ecx
setge  %dl
add    $0x1,%ecx
test   %dl,%bl
cmovne %r15d,%eax
cmovne %r14d,%ecx
mov    %eax,%edi
mov    %ecx,%ebp
jmp    1160 <main+0x40>

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

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