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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x60(%rbp),%rdi
mov    $0x50,%esi
call   1060 <getline@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    121c <main+0xdc>
lea    -0x60(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x60(%rbp,%rax,1),%eax
cmp    $0xa,%eax
jne    11f4 <main+0xb4>
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    11e8 <main+0xa8>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    11d3 <main+0x93>
lea    -0xb0(%rbp),%rdi
lea    -0x100(%rbp),%rsi
call   1050 <copy@plt>
jmp    11e3 <main+0xa3>
lea    -0xb0(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1050 <copy@plt>
jmp    11e8 <main+0xa8>
movl   $0x0,-0xc(%rbp)
jmp    1217 <main+0xd7>
cmpl   $0x0,-0xc(%rbp)
jne    120e <main+0xce>
lea    -0x100(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1050 <copy@plt>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1160 <main+0x20>
cmpl   $0x0,-0x10(%rbp)
jle    1275 <main+0x135>
lea    -0xb0(%rbp),%rsi
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xb0(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0xb0(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
je     1270 <main+0x130>
lea    0xd9f(%rip),%rdi
mov    $0xa,%esi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1275 <main+0x135>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xf8,%rsp
lea    0xa0(%rsp),%r13
mov    %r13,%rdi
mov    $0x50,%esi
call   1070 <getline@plt>
test   %eax,%eax
jle    1225 <main+0xd5>
mov    %eax,%ebp
xor    %r12d,%r12d
lea    0x50(%rsp),%r15
xor    %ebx,%ebx
jmp    11af <main+0x5f>
nopl   0x0(%rax)
test   %ebx,%ebx
je     11d7 <main+0x87>
add    %ebx,%ebp
mov    %ebp,%r14d
mov    %r13,%rdi
mov    $0x50,%esi
call   1070 <getline@plt>
mov    %eax,%ebp
mov    %r14d,%ebx
test   %eax,%eax
jle    11f1 <main+0xa1>
mov    %r13,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%r13,1)
jne    1190 <main+0x40>
add    %ebx,%ebp
xor    %r14d,%r14d
cmp    %r12d,%ebp
jle    1199 <main+0x49>
mov    %rsp,%rdi
test   %ebx,%ebx
jg     11e4 <main+0x94>
mov    %r13,%rsi
jmp    11e7 <main+0x97>
mov    %r15,%rdi
mov    %r13,%rsi
call   1060 <copy@plt>
jmp    1194 <main+0x44>
mov    %r15,%rsi
call   1060 <copy@plt>
mov    %ebp,%r12d
jmp    1199 <main+0x49>
test   %r12d,%r12d
jle    1225 <main+0xd5>
lea    0xe03(%rip),%rdi
mov    %rsp,%rbx
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     1225 <main+0xd5>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0xf8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
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 i32
%4 = alloca i32
%5 = alloca [80 x i8]
%6 = alloca [80 x i8]
%7 = alloca [80 x i8]
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %3
br label %8
8: ; preds = %53, %0
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%10 = call i32 @getline(i8* %9, i32 80)
store i32 %10, i32* %2
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %54
12: ; preds = %8
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
%15 = sub nsw i32 %14, 1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 10
br i1 %20, label %21, label %42
21: ; preds = %12
%22 = load i32, i32* %3
%23 = load i32, i32* %2
%24 = add nsw i32 %23, %22
store i32 %24, i32* %2
%25 = load i32, i32* %2
%26 = load i32, i32* %4
%27 = icmp sgt i32 %25, %26
br i1 %27, label %28, label %41
28: ; preds = %21
%29 = load i32, i32* %2
store i32 %29, i32* %4
%30 = load i32, i32* %3
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%34 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%35 = call i32 @copy(i8* %33, i8* %34)
br label %40
36: ; preds = %28
%37 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%38 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%39 = call i32 @copy(i8* %37, i8* %38)
br label %40
40: ; preds = %36, %32
br label %41
41: ; preds = %40, %21
store i32 0, i32* %3
br label %53
42: ; preds = %12
%43 = load i32, i32* %3
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %49
45: ; preds = %42
%46 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%47 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%48 = call i32 @copy(i8* %46, i8* %47)
br label %49
49: ; preds = %45, %42
%50 = load i32, i32* %2
%51 = load i32, i32* %3
%52 = add nsw i32 %51, %50
store i32 %52, i32* %3
br label %53
53: ; preds = %49, %41
br label %8
54: ; preds = %8
%55 = load i32, i32* %4
%56 = icmp sgt i32 %55, 0
br i1 %56, label %57, label %71
57: ; preds = %54
%58 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %58)
%60 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%61 = call i32 @strlen(i8* %60)
%62 = sub nsw i32 %61, 1
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 %63
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = icmp ne i32 %66, 10
br i1 %67, label %68, label %70
68: ; preds = %57
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 10)
br label %70
70: ; preds = %68, %57
br label %71
71: ; preds = %70, %54
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = alloca [80 x i8]
%3 = alloca [80 x i8]
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%7 = call i32 @getline(i8* %4, i32 80)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %51
9: ; preds = %0, %34
%10 = phi i32 [ %37, %34 ], [ %7, %0 ]
%11 = phi i32 [ %36, %34 ], [ 0, %0 ]
%12 = phi i32 [ %35, %34 ], [ 0, %0 ]
%13 = call i32 @strlen(i8* %4)
%14 = add nsw i32 %13, -1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 10
br i1 %18, label %19, label %28
19: ; preds = %9
%20 = add nsw i32 %10, %12
%21 = icmp sgt i32 %20, %11
br i1 %21, label %22, label %34
22: ; preds = %19
%23 = icmp sgt i32 %12, 0
br i1 %23, label %24, label %26
24: ; preds = %22
%25 = call i32 @copy(i8* %5, i8* %6)
br label %34
26: ; preds = %22
%27 = call i32 @copy(i8* %5, i8* %4)
br label %34
28: ; preds = %9
%29 = icmp eq i32 %12, 0
br i1 %29, label %30, label %32
30: ; preds = %28
%31 = call i32 @copy(i8* %6, i8* %4)
br label %32
32: ; preds = %30, %28
%33 = add nsw i32 %10, %12
br label %34
34: ; preds = %19, %26, %24, %32
%35 = phi i32 [ %33, %32 ], [ 0, %24 ], [ 0, %26 ], [ 0, %19 ]
%36 = phi i32 [ %11, %32 ], [ %20, %24 ], [ %20, %26 ], [ %11, %19 ]
%37 = call i32 @getline(i8* %4, i32 80)
%38 = icmp sgt i32 %37, 0
br i1 %38, label %9, label %39
39: ; preds = %34
%40 = icmp sgt i32 %36, 0
br i1 %40, label %41, label %51
41: ; preds = %39
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%43 = call i32 @strlen(i8* %5)
%44 = add nsw i32 %43, -1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = icmp eq i8 %47, 10
br i1 %48, label %51, label %49
49: ; preds = %41
%50 = call i32 @putchar(i32 10)
br label %51
51: ; preds = %0, %41, %49, %39
ret i32 0
}