#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*/ memset(char *, int /*<<< orphan*/, int const);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  const int minlen = 60;
  const int maxlen = 300;
  char line[maxlen];
  char ch;
  int count = 0;
  printf("\n_____LONGLINE_____\n\n");
  while ((ch = getchar()) != EOF) {
    if (ch != '\n') {
      line[count] = ch;
      count++;
    } else if (ch == '\n') {
      if (count >= minlen) {
        printf("\n%s\n\n", line);
      }
      memset(line, 0, maxlen);
      count = 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3c,-0x8(%rbp)
movl   $0x12c,-0xc(%rbp)
mov    %rsp,%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x19(%rbp)
movsbl %al,%eax
mov    0x2e68(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1204 <main+0xd4>
movsbl -0x19(%rbp),%eax
cmp    $0xa,%eax
je     11b4 <main+0x84>
mov    -0x19(%rbp),%cl
movslq -0x20(%rbp),%rax
mov    %cl,-0x150(%rbp,%rax,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11ff <main+0xcf>
movsbl -0x19(%rbp),%eax
cmp    $0xa,%eax
jne    11fa <main+0xca>
cmpl   $0x3c,-0x20(%rbp)
jl     11e0 <main+0xb0>
lea    0xe44(%rip),%rdi
lea    -0x150(%rbp),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x150(%rbp),%rdi
xor    %esi,%esi
mov    $0x12c,%edx
call   1040 <memset@plt>
movl   $0x0,-0x20(%rbp)
jmp    11ff <main+0xcf>
jmp    116c <main+0x3c>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x138,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e80(%rip),%r12
cmp    (%r12),%al
jne    117f <main+0x3f>
xor    %eax,%eax
add    $0x138,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe7a(%rip),%r14
mov    %rsp,%r15
xor    %ebx,%ebx
jmp    11ae <main+0x6e>
nopl   (%rax)
xor    %ebx,%ebx
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x12c,%edx
call   1050 <memset@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    (%r12),%al
je     116e <main+0x2e>
cmp    $0xa,%al
jne    11d0 <main+0x90>
cmp    $0x3c,%ebx
jl     1190 <main+0x50>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1190 <main+0x50>
cs nopw 0x0(%rax,%rax,1)
movslq %ebx,%rbx
mov    %al,(%rsp,%rbx,1)
add    $0x1,%ebx
jmp    11a1 <main+0x61>

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

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