#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 *, char *);
main() {
  int len, max;
  char line[1000];
  char longest[1000];
  max = 0;
  while ((len = getLine(line, 1000)) > 0) {
    max = max + len;
    if (max > 80) {
      printf("%s", line);
      if (line[len - 1] == '\n')
        max = 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7f0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x400(%rbp),%rdi
mov    $0x3e8,%esi
call   1040 <getLine@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    11a6 <main+0x86>
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x50,-0xc(%rbp)
jle    11a1 <main+0x81>
lea    -0x400(%rbp),%rsi
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x400(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    119c <main+0x7c>
movl   $0x0,-0xc(%rbp)
jmp    11a1 <main+0x81>
jmp    1139 <main+0x19>
xor    %eax,%eax
add    $0x7f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x3f0,%rsp
mov    %rsp,%rdi
mov    $0x3e8,%esi
call   1040 <getLine@plt>
test   %eax,%eax
jle    1192 <main+0x72>
mov    %eax,%ebx
xor    %r12d,%r12d
lea    0xeb4(%rip),%r14
mov    %rsp,%r15
xor    %ebp,%ebp
jmp    1173 <main+0x53>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
mov    $0x3e8,%esi
call   1040 <getLine@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    1192 <main+0x72>
add    %ebx,%ebp
cmp    $0x51,%ebp
jl     1160 <main+0x40>
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
add    $0xffffffff,%ebx
cmpb   $0xa,(%rsp,%rbx,1)
cmove  %r12d,%ebp
jmp    1160 <main+0x40>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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