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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x330,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x1a0(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <_getline@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    -0x330(%rbp),%rdi
lea    -0x1a0(%rbp),%rsi
call   1040 <copy@plt>
jmp    1149 <main+0x19>
cmpl   $0x0,-0xc(%rbp)
jle    11ab <main+0x7b>
lea    -0x330(%rbp),%rsi
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x330,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x328,%rsp
lea    0x190(%rsp),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
call   1050 <_getline@plt>
test   %eax,%eax
jle    11a6 <main+0x76>
mov    %eax,%ebp
mov    %rsp,%r14
lea    0x190(%rsp),%r15
jmp    1180 <main+0x50>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %ebx,%esi
call   1050 <_getline@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    1193 <main+0x63>
cmp    %ebx,%ebp
jle    1170 <main+0x40>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <copy@plt>
mov    %ebp,%ebx
jmp    1170 <main+0x40>
test   %ebx,%ebx
jle    11a6 <main+0x76>
lea    0xe62(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x328,%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 [100 x i32]
%5 = alloca [100 x i32]
store i32 0, i32* %1
store i32 0, i32* %3
br label %6
6: ; preds = %20, %0
%7 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 0
%8 = load i32, i32* %3
%9 = call i32 @_getline(i32* %7, i32 %8)
store i32 %9, i32* %2
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %6
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = icmp sgt i32 %12, %13
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = load i32, i32* %2
store i32 %16, i32* %3
%17 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 0
%18 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 0
%19 = call i32 @copy(i32* %17, i32* %18)
br label %20
20: ; preds = %15, %11
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 [100 x i32], [100 x i32]* %5, i64 0, i64 0
%26 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %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 [100 x i32]
%2 = alloca [100 x i32]
%3 = bitcast [100 x i32]* %1 to i8*
%4 = bitcast [100 x i32]* %2 to i8*
%5 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%6 = call i32 @_getline(i32* %5, i32 0)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %25
8: ; preds = %0
%9 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
br label %10
10: ; preds = %8, %16
%11 = phi i32 [ %6, %8 ], [ %18, %16 ]
%12 = phi i32 [ 0, %8 ], [ %17, %16 ]
%13 = icmp sgt i32 %11, %12
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 @copy(i32* %9, i32* %5)
br label %16
16: ; preds = %14, %10
%17 = phi i32 [ %11, %14 ], [ %12, %10 ]
%18 = call i32 @_getline(i32* %5, i32 %17)
%19 = icmp sgt i32 %18, 0
br i1 %19, label %10, label %20
20: ; preds = %16
%21 = icmp sgt i32 %17, 0
br i1 %21, label %22, label %25
22: ; preds = %20
%23 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%24 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %23)
br label %25
25: ; preds = %0, %22, %20
ret i32 0
}