#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 /*<<< orphan*/ puts(char *);
int main(void) {
  char line[1024];
  int ch;
  int i;
  int count;
  int last_blank_index;
  last_blank_index = 0;
  count = 0;
  printf("> ");
  for (i = 0; i < 1024 - 1 && (ch = getchar()) != EOF && ch != '\n'; ++i) {
    ++count;
    line[i] = ch;
    if (ch == ' ' || ch == '\t')
      last_blank_index = i;
    if (count > 80) {
      if (last_blank_index == 0) {
        line[i++] = '\n';
        count = 0;
      } else {
        line[last_blank_index] = '\n';
        count = i - last_blank_index;
        last_blank_index = 0;
      }
    }
  }
  if (ch == '\n')
    line[i++] = '\n';
  line[i] = '\0';
  puts("-");
  printf("%s", line);
  puts("-");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x420(%rbp)
movl   $0x0,-0x41c(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x418(%rbp)
xor    %eax,%eax
cmpl   $0x3ff,-0x418(%rbp)
mov    %al,-0x421(%rbp)
jge    11bc <main+0x8c>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0x414(%rbp)
xor    %eax,%eax
mov    0x2e4a(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x421(%rbp)
je     11bc <main+0x8c>
cmpl   $0xa,-0x414(%rbp)
setne  %al
mov    %al,-0x421(%rbp)
mov    -0x421(%rbp),%al
test   $0x1,%al
jne    11cf <main+0x9f>
jmp    12a7 <main+0x177>
mov    -0x41c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x41c(%rbp)
mov    -0x414(%rbp),%eax
mov    %al,%cl
movslq -0x418(%rbp),%rax
mov    %cl,-0x410(%rbp,%rax,1)
cmpl   $0x20,-0x414(%rbp)
je     120e <main+0xde>
cmpl   $0x9,-0x414(%rbp)
jne    121a <main+0xea>
mov    -0x418(%rbp),%eax
mov    %eax,-0x420(%rbp)
cmpl   $0x50,-0x41c(%rbp)
jle    128e <main+0x15e>
cmpl   $0x0,-0x420(%rbp)
jne    125e <main+0x12e>
mov    -0x418(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x418(%rbp)
cltq
movb   $0xa,-0x410(%rbp,%rax,1)
0a
movl   $0x0,-0x41c(%rbp)
jmp    1289 <main+0x159>
movslq -0x420(%rbp),%rax
movb   $0xa,-0x410(%rbp,%rax,1)
0a
mov    -0x418(%rbp),%eax
sub    -0x420(%rbp),%eax
mov    %eax,-0x41c(%rbp)
movl   $0x0,-0x420(%rbp)
jmp    128e <main+0x15e>
jmp    1293 <main+0x163>
mov    -0x418(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x418(%rbp)
jmp    116e <main+0x3e>
cmpl   $0xa,-0x414(%rbp)
jne    12cf <main+0x19f>
mov    -0x418(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x418(%rbp)
cltq
movb   $0xa,-0x410(%rbp,%rax,1)
0a
movslq -0x418(%rbp),%rax
movb   $0x0,-0x410(%rbp,%rax,1)
lea    0xd1e(%rip),%rdi
call   1030 <puts@plt>
lea    -0x410(%rbp),%rsi
lea    0xd0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xcfd(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x408,%rsp
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e96(%rip),%r14
xor    %r15d,%r15d
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    1170 <main+0x40>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
lea    0x1(%rbx),%ecx
cmp    $0x3fe,%ebx
mov    %ecx,%ebx
jge    11c0 <main+0x90>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%eax
je     11be <main+0x8e>
cmp    (%r14),%eax
je     120e <main+0xde>
movslq %ebx,%rcx
mov    %al,(%rsp,%rcx,1)
cmp    $0x20,%eax
je     1195 <main+0x65>
cmp    $0x9,%eax
jne    1198 <main+0x68>
mov    %ebx,%r15d
cmp    $0x50,%ebp
jl     1160 <main+0x30>
test   %r15d,%r15d
jne    11ad <main+0x7d>
add    $0x1,%ebx
movb   $0xa,(%rsp,%rcx,1)
xor    %ebp,%ebp
jmp    11b9 <main+0x89>
movslq %r15d,%rcx
movb   $0xa,(%rsp,%rcx,1)
mov    %ebx,%ebp
sub    %r15d,%ebp
xor    %r15d,%r15d
jmp    1163 <main+0x33>
mov    %ebx,%ecx
cmp    $0xa,%eax
jne    11cf <main+0x9f>
movslq %ecx,%rax
add    $0x1,%ecx
movb   $0xa,(%rsp,%rax,1)
movslq %ecx,%rax
movb   $0x0,(%rsp,%rax,1)
lea    0xe26(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xe19(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ebx,%ecx
cmp    $0xa,%eax
je     11c5 <main+0x95>
jmp    11cf <main+0x9f>

LLVM IR (-O0):
@.str = [3 x i8] c"> \00"
@EOF = global i32 0
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
store i32 0, i32* %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %8
8: ; preds = %55, %0
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 1023
br i1 %10, label %11, label %18
11: ; preds = %8
%12 = call i32 (...) @getchar()
store i32 %12, i32* %3
%13 = load i32, i32* @EOF
%14 = icmp ne i32 %12, %13
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i32, i32* %3
%17 = icmp ne i32 %16, 10
br label %18
18: ; preds = %15, %11, %8
%19 = phi i1 [ false, %11 ], [ false, %8 ], [ %17, %15 ]
br i1 %19, label %20, label %58
20: ; preds = %18
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
%23 = load i32, i32* %3
%24 = trunc i32 %23 to i8
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %26
store i8 %24, i8* %27
%28 = load i32, i32* %3
%29 = icmp eq i32 %28, 32
br i1 %29, label %33, label %30
30: ; preds = %20
%31 = load i32, i32* %3
%32 = icmp eq i32 %31, 9
br i1 %32, label %33, label %35
33: ; preds = %30, %20
%34 = load i32, i32* %4
store i32 %34, i32* %6
br label %35
35: ; preds = %33, %30
%36 = load i32, i32* %5
%37 = icmp sgt i32 %36, 80
br i1 %37, label %38, label %54
38: ; preds = %35
%39 = load i32, i32* %6
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %46
41: ; preds = %38
%42 = load i32, i32* %4
%43 = add nsw i32 %42, 1
store i32 %43, i32* %4
%44 = sext i32 %42 to i64
%45 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %44
store i8 10, i8* %45
store i32 0, i32* %5
br label %53
46: ; preds = %38
%47 = load i32, i32* %6
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %48
store i8 10, i8* %49
%50 = load i32, i32* %4
%51 = load i32, i32* %6
%52 = sub nsw i32 %50, %51
store i32 %52, i32* %5
store i32 0, i32* %6
br label %53
53: ; preds = %46, %41
br label %54
54: ; preds = %53, %35
br label %55
55: ; preds = %54
%56 = load i32, i32* %4
%57 = add nsw i32 %56, 1
store i32 %57, i32* %4
br label %8
58: ; preds = %18
%59 = load i32, i32* %3
%60 = icmp eq i32 %59, 10
br i1 %60, label %61, label %66
61: ; preds = %58
%62 = load i32, i32* %4
%63 = add nsw i32 %62, 1
store i32 %63, i32* %4
%64 = sext i32 %62 to i64
%65 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %64
store i8 10, i8* %65
br label %66
66: ; preds = %61, %58
%67 = load i32, i32* %4
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %68
store i8 0, i8* %69
%70 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%71 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %71)
%73 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

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