#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);
int nextline(char *);
int /*<<< orphan*/ printf(char *, char *);
int main() {
  int len;
  int max;
  char line[1024];
  char longest[1024];
  max = 0;
  while ((len = nextline(line)) > 0) {
    if (len > max) {
      max = len;
      copy(longest, line, len);
    }
  }
  if (max > 0) {
    printf("%s", longest);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x410(%rbp),%rdi
call   1050 <nextline@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    118e <main+0x5e>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    1189 <main+0x59>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    -0x810(%rbp),%rdi
lea    -0x410(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1040 <copy@plt>
jmp    1149 <main+0x19>
cmpl   $0x0,-0xc(%rbp)
jle    11ab <main+0x7b>
lea    -0x810(%rbp),%rsi
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x808,%rsp
lea    0x400(%rsp),%rdi
call   1050 <nextline@plt>
test   %eax,%eax
jle    1196 <main+0x66>
mov    %eax,%ebp
xor    %ebx,%ebx
mov    %rsp,%r14
lea    0x400(%rsp),%r15
jmp    116e <main+0x3e>
nop
mov    %r15,%rdi
call   1050 <nextline@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    1183 <main+0x53>
cmp    %ebx,%ebp
jle    1160 <main+0x30>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1040 <copy@plt>
mov    %ebp,%ebx
jmp    1160 <main+0x30>
test   %ebx,%ebx
jle    1196 <main+0x66>
lea    0xe72(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x808,%rsp
pop    %rbx
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 [1024 x i8]
%5 = alloca [1024 x i8]
store i32 0, i32* %1
store i32 0, i32* %3
br label %6
6: ; preds = %20, %0
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%8 = call i32 @nextline(i8* %7)
store i32 %8, i32* %2
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %21
10: ; preds = %6
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = icmp sgt i32 %11, %12
br i1 %13, label %14, label %20
14: ; preds = %10
%15 = load i32, i32* %2
store i32 %15, i32* %3
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%18 = load i32, i32* %2
%19 = call i32 @copy(i8* %16, i8* %17, i32 %18)
br label %20
20: ; preds = %14, %10
br label %6
21: ; preds = %6
%22 = load i32, i32* %3
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%26 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %24, %21
ret i32 0
}

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