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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x60(%rbp),%rdi
mov    $0x50,%esi
call   1050 <readline@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    11f7 <main+0xb7>
cmpl   $0x4f,-0x8(%rbp)
jne    11f2 <main+0xb2>
movsbl -0x12(%rbp),%eax
cmp    $0xa,%eax
je     11f2 <main+0xb2>
lea    -0x60(%rbp),%rsi
lea    0xe75(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x61(%rbp)
movsbl %al,%ecx
mov    0x2e44(%rip),%rax
movsbl (%rax),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x62(%rbp)
je     11c1 <main+0x81>
movsbl -0x61(%rbp),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x62(%rbp)
mov    -0x62(%rbp),%al
test   $0x1,%al
jne    11d1 <main+0x91>
jmp    11e8 <main+0xa8>
movsbl -0x61(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1190 <main+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    114f <main+0xf>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %rsp,%rdi
mov    $0x50,%esi
call   1050 <readline@plt>
test   %eax,%eax
jle    11c9 <main+0x89>
lea    0xe9f(%rip),%r14
mov    %rsp,%r15
mov    0x2e7d(%rip),%rbx
jmp    118b <main+0x4b>
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
mov    $0x50,%esi
call   1050 <readline@plt>
test   %eax,%eax
jle    11c9 <main+0x89>
cmp    $0x4f,%eax
jne    117a <main+0x3a>
cmpb   $0xa,0x4e(%rsp)
je     117a <main+0x3a>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%al
je     1170 <main+0x30>
cmp    (%rbx),%al
je     1170 <main+0x30>
movsbl %al,%edi
call   1030 <putchar@plt>
jmp    11b0 <main+0x70>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@EOF = global i8 0
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 @readline(i8* %2, i32 80)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %33
5: ; preds = %0
%6 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 78
br label %7
7: ; preds = %5, %30
%8 = phi i32 [ %3, %5 ], [ %31, %30 ]
%9 = icmp eq i32 %8, 79
%10 = load i8, i8* %6
%11 = icmp ne i8 %10, 10
%12 = select i1 %9, i1 %11, i1 false
br i1 %12, label %13, label %30
13: ; preds = %7
%14 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%15 = call signext i8 (...) @getchar()
%16 = load i8, i8* @EOF
%17 = icmp ne i8 %15, %16
%18 = icmp ne i8 %15, 10
%19 = and i1 %18, %17
br i1 %19, label %20, label %28
20: ; preds = %13, %20
%21 = phi i8 [ %23, %20 ], [ %15, %13 ]
%22 = call i32 @putchar(i8 signext %21)
%23 = call signext i8 (...) @getchar()
%24 = load i8, i8* @EOF
%25 = icmp ne i8 %23, %24
%26 = icmp ne i8 %23, 10
%27 = and i1 %26, %25
br i1 %27, label %20, label %28
28: ; preds = %20, %13
%29 = call i32 @putchar(i8 signext 10)
br label %30
30: ; preds = %28, %7
%31 = call i32 @readline(i8* %2, i32 80)
%32 = icmp sgt i32 %31, 0
br i1 %32, label %7, label %33
33: ; preds = %30, %0
ret i32 0
}