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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e9a(%rip),%rax
movl   $0x0,(%rax)
mov    $0x0,%al
call   1050 <getnewline@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    11ae <main+0x7e>
mov    -0x8(%rbp),%eax
mov    0x2e77(%rip),%rcx
cmp    (%rcx),%eax
jle    1184 <main+0x54>
mov    -0x8(%rbp),%ecx
mov    0x2e65(%rip),%rax
mov    %ecx,(%rax)
mov    $0x0,%al
call   1040 <copy@plt>
mov    0x2e55(%rip),%rax
cmpl   $0x0,(%rax)
jle    11a7 <main+0x77>
lea    0xe65(%rip),%rdi
mov    0x2e36(%rip),%rsi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2ea8(%rip),%rbx
movl   $0x0,(%rbx)
xor    %eax,%eax
call   1050 <getnewline@plt>
test   %eax,%eax
jle    1171 <main+0x41>
mov    (%rbx),%ecx
cmp    %ecx,%eax
jle    115a <main+0x2a>
mov    %eax,(%rbx)
xor    %eax,%eax
call   1040 <copy@plt>
mov    (%rbx),%ecx
test   %ecx,%ecx
jle    1171 <main+0x41>
lea    0xe9b(%rip),%rdi
mov    0x2e6c(%rip),%rsi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@max = external global i32
@.str = [3 x i8] c"%s\00"
@longest = external global [0 x i8]
define i32 @main() {
store i32 0, i32* @max
%1 = tail call i32 (...) @getnewline()
%2 = icmp sgt i32 %1, 0
br i1 %2, label %3, label %14
3: ; preds = %0
%4 = load i32, i32* @max
%5 = icmp sgt i32 %1, %4
br i1 %5, label %6, label %9
6: ; preds = %3
store i32 %1, i32* @max
%7 = tail call i32 (...) @copy()
%8 = load i32, i32* @max
br label %9
9: ; preds = %6, %3
%10 = phi i32 [ %8, %6 ], [ %4, %3 ]
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([0 x i8], [0 x i8]* @longest, i64 0, i64 0))
br label %14
14: ; preds = %0, %9, %12
ret i32 0
}