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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x800,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    -0x400(%rbp),%rdi
mov    $0x3e8,%esi
call   1060 <getLine@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jle    1214 <main+0xd4>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x400(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
je     11ea <main+0xaa>
jmp    1194 <main+0x54>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0x8(%rbp)
xor    %eax,%eax
mov    0x2e3f(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x7f1(%rbp)
je     11c4 <main+0x84>
cmpl   $0xa,-0x8(%rbp)
setne  %al
mov    %al,-0x7f1(%rbp)
mov    -0x7f1(%rbp),%al
test   $0x1,%al
jne    11d7 <main+0x97>
jmp    11e5 <main+0xa5>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1194 <main+0x54>
jmp    11ea <main+0xaa>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    120f <main+0xcf>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
lea    -0x7f0(%rbp),%rdi
lea    -0x400(%rbp),%rsi
call   1040 <copy@plt>
jmp    1159 <main+0x19>
cmpl   $0x0,-0x10(%rbp)
jle    1231 <main+0xf1>
lea    -0x7f0(%rbp),%rsi
lea    0xdd4(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x800,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x7e0,%rsp
mov    %rsp,%rdi
mov    $0x3e8,%esi
call   1060 <getLine@plt>
test   %eax,%eax
jle    11e0 <main+0xa0>
mov    %eax,%ebx
lea    0x3f0(%rsp),%r14
mov    %rsp,%r15
mov    0x2e70(%rip),%r12
xor    %ebp,%ebp
jmp    1193 <main+0x53>
nopl   0x0(%rax)
mov    %r15,%rdi
mov    $0x3e8,%esi
call   1060 <getLine@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    11c8 <main+0x88>
lea    -0x1(%rbx),%eax
cmpb   $0xa,(%rsp,%rax,1)
je     11b5 <main+0x75>
mov    %eax,%ebx
xchg   %ax,%ax
xor    %eax,%eax
call   1050 <getchar@plt>
add    $0x1,%ebx
cmp    $0xa,%eax
je     11b5 <main+0x75>
cmp    (%r12),%eax
jne    11a0 <main+0x60>
cmp    %ebp,%ebx
jle    1180 <main+0x40>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <copy@plt>
mov    %ebx,%ebp
jmp    1180 <main+0x40>
test   %ebp,%ebp
jle    11e0 <main+0xa0>
lea    0xe2d(%rip),%rdi
lea    0x3f0(%rsp),%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7e0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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