#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 getline(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int main() {
  int len;
  char line[128];
  while ((len = getline(line, 128)) > 0) {
    if (len > 80) {
      printf("%s", line);
      if (line[strlen(line) - 1] != '\n')
        printf("%c", '\n');
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x90(%rbp),%rdi
mov    $0x80,%esi
call   1050 <getline@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    11bd <main+0x8d>
cmpl   $0x50,-0x8(%rbp)
jle    11b8 <main+0x88>
lea    -0x90(%rbp),%rsi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x90(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x90(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
je     11b3 <main+0x83>
lea    0xe5c(%rip),%rdi
mov    $0xa,%esi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11b8 <main+0x88>
jmp    1142 <main+0x12>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
call   1060 <getline@plt>
test   %eax,%eax
jle    11b0 <main+0x70>
lea    0xe9b(%rip),%r14
jmp    1181 <main+0x41>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x80,%esi
call   1060 <getline@plt>
test   %eax,%eax
jle    11b0 <main+0x70>
cmp    $0x51,%eax
jb     1170 <main+0x30>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
je     1170 <main+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1170 <main+0x30>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [128 x i8]
store i32 0, i32* %1
br label %4
4: ; preds = %25, %0
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = call i32 @getline(i8* %5, i32 128)
store i32 %6, i32* %2
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %26
8: ; preds = %4
%9 = load i32, i32* %2
%10 = icmp sgt i32 %9, 80
br i1 %10, label %11, label %25
11: ; preds = %8
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
%16 = sub nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 10
br i1 %21, label %22, label %24
22: ; preds = %11
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 10)
br label %24
24: ; preds = %22, %11
br label %25
25: ; preds = %24, %8
br label %4
26: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%3 = call i32 @getline(i8* %2, i32 128)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %21
5: ; preds = %0, %18
%6 = phi i32 [ %19, %18 ], [ %3, %0 ]
%7 = icmp ugt i32 %6, 80
br i1 %7, label %8, label %18
8: ; preds = %5
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%10 = call i32 @strlen(i8* %2)
%11 = add nsw i32 %10, -1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 10
br i1 %15, label %18, label %16
16: ; preds = %8
%17 = call i32 @putchar(i32 10)
br label %18
18: ; preds = %8, %16, %5
%19 = call i32 @getline(i8* %2, i32 128)
%20 = icmp sgt i32 %19, 0
br i1 %20, label %5, label %21
21: ; preds = %18, %0
ret i32 0
}