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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x68(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x64(%rbp)
mov    0x2e91(%rip),%rcx
cmp    (%rcx),%eax
je     11d2 <main+0xa2>
cmpl   $0x50,-0x68(%rbp)
jge    1184 <main+0x54>
mov    -0x64(%rbp),%eax
mov    %al,%cl
mov    -0x68(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x68(%rbp)
cltq
mov    %cl,-0x60(%rbp,%rax,1)
jmp    11bc <main+0x8c>
cmpl   $0x50,-0x68(%rbp)
jne    11af <main+0x7f>
lea    -0x60(%rbp),%rsi
mov    -0x64(%rbp),%edx
lea    0xe64(%rip),%rdi
call   1040 <printf@plt>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    11b7 <main+0x87>
mov    -0x64(%rbp),%edi
call   1030 <putchar@plt>
jmp    11bc <main+0x8c>
cmpl   $0xa,-0x64(%rbp)
jne    11cd <main+0x9d>
movl   $0x0,-0x68(%rbp)
jmp    1146 <main+0x16>
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
xor    %r12d,%r12d
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e99(%rip),%r13
cmp    0x0(%r13),%eax
jne    1166 <main+0x36>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
lea    0xe91(%rip),%r14
mov    %rsp,%r15
xor    %ebx,%ebx
jmp    11a0 <main+0x70>
cs nopw 0x0(%rax,%rax,1)
movslq %ebx,%rax
add    $0x1,%ebx
mov    %bpl,(%rsp,%rax,1)
cmp    $0xa,%ebp
cmove  %r12d,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebp
cmp    0x0(%r13),%eax
je     1155 <main+0x25>
cmp    $0x4f,%ebx
jle    1180 <main+0x50>
cmp    $0x50,%ebx
jne    11c0 <main+0x90>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1040 <printf@plt>
mov    $0x51,%ebx
jmp    118a <main+0x5a>
xchg   %ax,%ax
mov    %ebp,%edi
call   1030 <putchar@plt>
jmp    118a <main+0x5a>

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

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