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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7f0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x400(%rbp),%rdi
mov    $0x3e8,%esi
call   1040 <getline_tst@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    116d <main+0x4d>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    1168 <main+0x48>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1139 <main+0x19>
cmpl   $0x0,-0xc(%rbp)
jle    118a <main+0x6a>
lea    -0x7f0(%rbp),%rsi
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x7e0,%rsp
mov    %rsp,%rdi
mov    $0x3e8,%esi
call   1040 <getline_tst@plt>
test   %eax,%eax
jle    1165 <main+0x45>
mov    %rsp,%rbx
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1040 <getline_tst@plt>
test   %eax,%eax
jg     1140 <main+0x20>
lea    0xea8(%rip),%rdi
lea    0x3f0(%rsp),%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7e0,%rsp
pop    %rbx
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 [1000 x i8]
%5 = alloca [1000 x i8]
store i32 0, i32* %1
store i32 0, i32* %3
br label %6
6: ; preds = %16, %0
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%8 = call i32 @getline_tst(i8* %7, i32 1000)
store i32 %8, i32* %2
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %17
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 %16
14: ; preds = %10
%15 = load i32, i32* %2
store i32 %15, i32* %3
br label %16
16: ; preds = %14, %10
br label %6
17: ; preds = %6
%18 = load i32, i32* %3
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%22 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %20, %17
ret i32 0
}

LLVM IR (-O2):
@.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_tst(i8* %3, i32 1000)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %0, %7
%8 = call i32 @getline_tst(i8* %3, i32 1000)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %7, label %10
10: ; preds = %7
%11 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
br label %12
12: ; preds = %0, %10
ret i32 0
}