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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
lea    -0x410(%rbp),%rdi
mov    $0x3e8,%esi
call   1040 <gtline@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jle    121c <main+0xdc>
cmpl   $0x3e7,-0x14(%rbp)
jne    1217 <main+0xd7>
movsbl -0x29(%rbp),%eax
cmp    $0xa,%eax
je     1217 <main+0xd7>
jmp    119c <main+0x5c>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0x1c(%rbp)
xor    %eax,%eax
mov    0x2e37(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x801(%rbp)
je     11cc <main+0x8c>
cmpl   $0xa,-0x1c(%rbp)
setne  %al
mov    %al,-0x801(%rbp)
mov    -0x801(%rbp),%al
test   $0x1,%al
jne    11df <main+0x9f>
jmp    11ed <main+0xad>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119c <main+0x5c>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    1212 <main+0xd2>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    -0x800(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1050 <copy@plt>
jmp    1217 <main+0xd7>
jmp    1160 <main+0x20>
cmpl   $0x0,-0x18(%rbp)
jle    1239 <main+0xf9>
lea    -0x800(%rbp),%rsi
lea    0xdcc(%rip),%rdi
call   1030 <printf@plt>
mov    0x2d98(%rip),%rax
mov    (%rax),%eax
add    $0x810,%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   1040 <gtline@plt>
test   %eax,%eax
jle    11f1 <main+0xb1>
mov    0x2e7d(%rip),%rbx
lea    0x3f0(%rsp),%r14
mov    %rsp,%r15
xor    %r12d,%r12d
jmp    1191 <main+0x51>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x3e8,%esi
call   1040 <gtline@plt>
test   %eax,%eax
jle    11d8 <main+0x98>
cmp    $0x3e7,%eax
jne    1180 <main+0x40>
cmpb   $0xa,0x3e7(%rsp)
0a
je     1180 <main+0x40>
mov    $0x3e6,%ebp
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getchar@plt>
add    $0x1,%ebp
cmp    $0xa,%eax
je     11c3 <main+0x83>
cmp    (%rbx),%eax
jne    11b0 <main+0x70>
cmp    %r12d,%ebp
jle    1180 <main+0x40>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <copy@plt>
mov    %ebp,%r12d
jmp    1180 <main+0x40>
test   %r12d,%r12d
jle    11f1 <main+0xb1>
lea    0xe1c(%rip),%rdi
lea    0x3f0(%rsp),%rsi
call   1030 <printf@plt>
mov    0x2de0(%rip),%rax
mov    (%rax),%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"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [1000 x i8]
%10 = alloca [1000 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
br label %11
11: ; preds = %46, %2
%12 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%13 = call i32 @gtline(i8* %12, i32 1000)
store i32 %13, i32* %6
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %47
15: ; preds = %11
%16 = load i32, i32* %6
%17 = icmp eq i32 %16, 999
br i1 %17, label %18, label %46
18: ; preds = %15
%19 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 999
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 10
br i1 %22, label %23, label %46
23: ; preds = %18
br label %24
24: ; preds = %33, %23
%25 = call i32 (...) @getchar()
store i32 %25, i32* %8
%26 = load i32, i32* @EOF
%27 = icmp ne i32 %25, %26
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = load i32, i32* %8
%30 = icmp ne i32 %29, 10
br label %31
31: ; preds = %28, %24
%32 = phi i1 [ false, %24 ], [ %30, %28 ]
br i1 %32, label %33, label %36
33: ; preds = %31
%34 = load i32, i32* %6
%35 = add nsw i32 %34, 1
store i32 %35, i32* %6
br label %24
36: ; preds = %31
%37 = load i32, i32* %6
%38 = load i32, i32* %7
%39 = icmp sgt i32 %37, %38
br i1 %39, label %40, label %45
40: ; preds = %36
%41 = load i32, i32* %6
store i32 %41, i32* %7
%42 = getelementptr inbounds [1000 x i8], [1000 x i8]* %10, i64 0, i64 0
%43 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%44 = call i32 @copy(i8* %42, i8* %43)
br label %45
45: ; preds = %40, %36
br label %46
46: ; preds = %45, %18, %15
br label %11
47: ; preds = %11
%48 = load i32, i32* %7
%49 = icmp sgt i32 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %47
%51 = getelementptr inbounds [1000 x i8], [1000 x i8]* %10, i64 0, i64 0
%52 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %51)
br label %53
53: ; preds = %50, %47
%54 = load i32, i32* @EXIT_SUCCESS
ret i32 %54
}

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