#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 *, char *);
int main() {
  int longline = 0;
  int len, c;
  char buffer[80];
  while ((c = getchar()) != EOF) {
    buffer[len] = c;
    if (c == '\n') {
      if (longline == 1 && len < 80 - 1) {
        buffer[len + 1] = '\0';
        printf("%-s", buffer);
      }
      len = 0;
      longline = 0;
      continue;
    }
    if (len == 80) {
      buffer[len + 1] = '\0';
      printf("%-s", buffer);
      len = 0;
      longline = 1;
      continue;
    }
    ++len;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x10(%rbp)
mov    0x2ea1(%rip),%rcx
cmp    (%rcx),%eax
je     11f2 <main+0xd2>
mov    -0x10(%rbp),%eax
mov    %al,%cl
movslq -0xc(%rbp),%rax
mov    %cl,-0x60(%rbp,%rax,1)
cmpl   $0xa,-0x10(%rbp)
jne    11aa <main+0x8a>
cmpl   $0x1,-0x8(%rbp)
jne    1197 <main+0x77>
cmpl   $0x4f,-0xc(%rbp)
jge    1197 <main+0x77>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,-0x60(%rbp,%rax,1)
lea    -0x60(%rbp),%rsi
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
jmp    1136 <main+0x16>
cmpl   $0x50,-0xc(%rbp)
jne    11e4 <main+0xc4>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,-0x60(%rbp,%rax,1)
lea    -0x60(%rbp),%rsi
lea    0xe34(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x8(%rbp)
jmp    1136 <main+0x16>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1136 <main+0x16>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eac(%rip),%rbx
cmp    (%rbx),%eax
jne    1151 <main+0x31>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x1(%rsp),%r13
xor    %r12d,%r12d
mov    %r13,%rbp
xor    %r15d,%r15d
nop
mov    %al,-0x1(%rbp)
cmp    $0xa,%eax
je     1190 <main+0x70>
cmp    $0x50,%r15
je     11b0 <main+0x90>
add    $0x1,%r15
xor    %eax,%eax
call   1040 <getchar@plt>
add    $0x1,%rbp
cmp    (%rbx),%eax
jne    1160 <main+0x40>
jmp    1140 <main+0x20>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %r14d,%r14d
cmp    $0x1,%r12d
jne    11ce <main+0xae>
cmp    $0x4e,%r15d
jbe    11bb <main+0x9b>
jmp    11ce <main+0xae>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x1,%r14d
lea    0x51(%rsp),%rbp
movb   $0x0,0x0(%rbp)
lea    0xe3a(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %r14d,%r12d
cmp    (%rbx),%eax
jne    1159 <main+0x39>
jmp    1140 <main+0x20>

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

LLVM IR (-O2):
@EOF = global i32 0
@.str = [4 x i8] c"%-s\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%3 = call i32 (...) @getchar()
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %42, label %6
6: ; preds = %0
%7 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 81
br label %8
8: ; preds = %6, %30
%9 = phi i32 [ %3, %6 ], [ %32, %30 ]
%10 = phi i32 [ 0, %6 ], [ %31, %30 ]
br label %11
11: ; preds = %8, %37
%12 = phi i64 [ 0, %8 ], [ %38, %37 ]
%13 = phi i32 [ %9, %8 ], [ %39, %37 ]
%14 = trunc i32 %13 to i8
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %12
store i8 %14, i8* %15
%16 = icmp eq i32 %13, 10
br i1 %16, label %17, label %35
17: ; preds = %11
%18 = trunc i64 %12 to i32
%19 = icmp eq i32 %10, 1
%20 = icmp ult i32 %18, 79
%21 = select i1 %19, i1 %20, i1 false
br i1 %21, label %22, label %30
22: ; preds = %17
%23 = add nuw i64 %12, 1
%24 = and i64 %23, 4294967295
%25 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %24
br label %26
26: ; preds = %35, %22
%27 = phi i8* [ %25, %22 ], [ %7, %35 ]
%28 = phi i32 [ 0, %22 ], [ 1, %35 ]
store i8 0, i8* %27
%29 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %30
30: ; preds = %26, %17
%31 = phi i32 [ 0, %17 ], [ %28, %26 ]
%32 = call i32 (...) @getchar()
%33 = load i32, i32* @EOF
%34 = icmp eq i32 %32, %33
br i1 %34, label %42, label %8
35: ; preds = %11
%36 = icmp eq i64 %12, 80
br i1 %36, label %26, label %37
37: ; preds = %35
%38 = add nuw nsw i64 %12, 1
%39 = call i32 (...) @getchar()
%40 = load i32, i32* @EOF
%41 = icmp eq i32 %39, %40
br i1 %41, label %42, label %11
42: ; preds = %30, %37, %0
ret i32 0
}