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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
movb   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x61(%rbp)
movsbl %al,%eax
mov    0x2e83(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11dd <main+0xad>
cmpl   $0x0,-0xc(%rbp)
jne    11b4 <main+0x84>
mov    -0x61(%rbp),%cl
movslq -0x8(%rbp),%rax
mov    %cl,-0x60(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x50,-0x8(%rbp)
jle    11af <main+0x7f>
lea    -0x60(%rbp),%rsi
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0xc(%rbp)
jmp    11bd <main+0x8d>
movsbl -0x61(%rbp),%edi
call   1030 <putchar@plt>
movsbl -0x61(%rbp),%eax
cmp    $0xa,%eax
jne    11d8 <main+0xa8>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
jmp    1151 <main+0x21>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
movb   $0x0,0x50(%rsp)
xor    %r13d,%r13d
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e94(%rip),%r12
cmp    (%r12),%al
jne    116b <main+0x3b>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebx
mov    %rsp,%r15
xor    %ebp,%ebp
xor    %r14d,%r14d
jmp    11a8 <main+0x78>
nopw   0x0(%rax,%rax,1)
movsbl %bl,%edi
call   1030 <putchar@plt>
mov    $0x1,%r14d
cmp    $0xa,%bl
cmove  %r13d,%r14d
cmove  %r13d,%ebp
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
cmp    (%r12),%al
je     115a <main+0x2a>
test   %r14d,%r14d
jne    1180 <main+0x50>
movslq %ebp,%rax
mov    %bl,(%rsp,%rax,1)
lea    0x1(%rax),%ebp
xor    %r14d,%r14d
cmp    $0x50,%eax
jl     118e <main+0x5e>
lea    0xe3b(%rip),%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
jmp    1188 <main+0x58>

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

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