#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 EXIT_SUCCESS;
int /*<<< orphan*/ copy(char *, char *);
int gtline(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char **argv) {
  int len, max;
  char line[1000], longest[1000];
  max = 0;
  while ((len = gtline(line, 1000)) > 0) {
    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    $0x7f0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
lea    -0x400(%rbp),%rdi
mov    $0x3e8,%esi
call   1040 <gtline@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jle    1197 <main+0x67>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    1192 <main+0x62>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    -0x7f0(%rbp),%rdi
lea    -0x400(%rbp),%rsi
call   1050 <copy@plt>
jmp    1150 <main+0x20>
cmpl   $0x0,-0x18(%rbp)
jle    11b4 <main+0x84>
lea    -0x7f0(%rbp),%rsi
lea    0xe51(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%eax
add    $0x7f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x7d8,%rsp
lea    0x3f0(%rsp),%rdi
mov    $0x3e8,%esi
call   1040 <gtline@plt>
test   %eax,%eax
jle    11a9 <main+0x79>
mov    %eax,%ebp
xor    %ebx,%ebx
mov    %rsp,%r14
lea    0x3f0(%rsp),%r15
jmp    1183 <main+0x53>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    $0x3e8,%esi
call   1040 <gtline@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    1196 <main+0x66>
cmp    %ebx,%ebp
jle    1170 <main+0x40>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <copy@plt>
mov    %ebp,%ebx
jmp    1170 <main+0x40>
test   %ebx,%ebx
jle    11a9 <main+0x79>
lea    0xe5f(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
mov    0x2e30(%rip),%rax
mov    (%rax),%eax
add    $0x7d8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.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 [1000 x i8]
%9 = 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 %10
10: ; preds = %23, %2
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%12 = call i32 @gtline(i8* %11, i32 1000)
store i32 %12, i32* %6
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %24
14: ; preds = %10
%15 = load i32, i32* %6
%16 = load i32, i32* %7
%17 = icmp sgt i32 %15, %16
br i1 %17, label %18, label %23
18: ; preds = %14
%19 = load i32, i32* %6
store i32 %19, i32* %7
%20 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%22 = call i32 @copy(i8* %20, i8* %21)
br label %23
23: ; preds = %18, %14
br label %10
24: ; preds = %10
%25 = load i32, i32* %7
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%29 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %28)
br label %30
30: ; preds = %27, %24
%31 = load i32, i32* @EXIT_SUCCESS
ret i32 %31
}

LLVM IR (-O2):
@.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 %23
9: ; preds = %2, %15
%10 = phi i32 [ %17, %15 ], [ %7, %2 ]
%11 = phi i32 [ %16, %15 ], [ 0, %2 ]
%12 = icmp sgt i32 %10, %11
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 @copy(i8* %6, i8* %5)
br label %15
15: ; preds = %13, %9
%16 = phi i32 [ %10, %13 ], [ %11, %9 ]
%17 = call i32 @gtline(i8* %5, i32 1000)
%18 = icmp sgt i32 %17, 0
br i1 %18, label %9, label %19
19: ; preds = %15
%20 = icmp sgt i32 %16, 0
br i1 %20, label %21, label %23
21: ; preds = %19
%22 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %23
23: ; preds = %2, %21, %19
%24 = load i32, i32* @EXIT_SUCCESS
ret i32 %24
}