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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x14,%esi
call   1050 <getline@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    1184 <main+0x54>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    117f <main+0x4f>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <copy@plt>
jmp    1146 <main+0x16>
cmpl   $0x0,-0xc(%rbp)
jle    11a1 <main+0x71>
mov    -0xc(%rbp),%esi
lea    -0x40(%rbp),%rdx
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
lea    0x20(%rsp),%rdi
mov    $0x14,%esi
call   1050 <getline@plt>
test   %eax,%eax
jle    119b <main+0x6b>
mov    %eax,%ebp
xor    %ebx,%ebx
mov    %rsp,%r14
lea    0x20(%rsp),%r15
jmp    1173 <main+0x43>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x14,%esi
call   1050 <getline@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    1186 <main+0x56>
cmp    %ebx,%ebp
jle    1160 <main+0x30>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <copy@plt>
mov    %ebp,%ebx
jmp    1160 <main+0x30>
test   %ebx,%ebx
jle    119b <main+0x6b>
lea    0xe6f(%rip),%rdi
mov    %rsp,%rdx
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [20 x i8]
%5 = alloca [20 x i8]
store i32 0, i32* %1
store i32 0, i32* %3
br label %6
6: ; preds = %19, %0
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%8 = call i32 @getline(i8* %7, i32 20)
store i32 %8, i32* %2
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %20
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 %19
14: ; preds = %10
%15 = load i32, i32* %2
store i32 %15, i32* %3
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%18 = call i32 @copy(i8* %16, i8* %17)
br label %19
19: ; preds = %14, %10
br label %6
20: ; preds = %6
%21 = load i32, i32* %3
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %20
%24 = load i32, i32* %3
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%26 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %24, i8* %25)
br label %27
27: ; preds = %23, %20
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d %s\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%5 = call i32 @getline(i8* %3, i32 20)
%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)
br label %13
13: ; preds = %11, %7
%14 = phi i32 [ %8, %11 ], [ %9, %7 ]
%15 = call i32 @getline(i8* %3, i32 20)
%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 ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %14, i8* %4)
br label %21
21: ; preds = %0, %19, %17
ret i32 0
}