#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 getaline(char *, int);
int /*<<< orphan*/ printf(char *, char *, int, char *, char *);
int main() {
  int len;
  int max;
  char line[1000];
  char longest[1000];
  max = 0;
  while ((len = getaline(line, 1000)) > 0) {
    if (len > max) {
      max = len;
      copy(longest, line);
    }
    if (len > 80) {
      printf("%s: %3d  %s: %s", "Chars", len, "Line", line);
    }
  }
  if (max > 0 && max > 80) {
    printf("%s: %3d  %s: %s", "Chars", max, "Long", 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   1030 <getaline@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    11be <main+0x8e>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    118b <main+0x5b>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    -0x7f0(%rbp),%rdi
lea    -0x400(%rbp),%rsi
call   1050 <copy@plt>
cmpl   $0x50,-0x8(%rbp)
jle    11b9 <main+0x89>
mov    -0x8(%rbp),%edx
lea    -0x400(%rbp),%r8
lea    0xe5a(%rip),%rdi
lea    0xe63(%rip),%rsi
lea    0xe62(%rip),%rcx
call   1040 <printf@plt>
jmp    1149 <main+0x19>
cmpl   $0x0,-0xc(%rbp)
jle    11f6 <main+0xc6>
cmpl   $0x50,-0xc(%rbp)
jle    11f6 <main+0xc6>
mov    -0xc(%rbp),%edx
lea    -0x7f0(%rbp),%r8
lea    0xe1d(%rip),%rdi
lea    0xe26(%rip),%rsi
lea    0xe2a(%rip),%rcx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x7f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7d8,%rsp
lea    0x3f0(%rsp),%rdi
mov    $0x3e8,%esi
call   1030 <getaline@plt>
test   %eax,%eax
jle    11e6 <main+0xb6>
mov    %eax,%ebx
xor    %r14d,%r14d
lea    0x3f0(%rsp),%r15
lea    0xe91(%rip),%r12
lea    0xe9a(%rip),%r13
lea    0xe99(%rip),%rbp
jmp    1193 <main+0x63>
nop
mov    %r15,%rdi
mov    $0x3e8,%esi
call   1030 <getaline@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    11c0 <main+0x90>
cmp    %r14d,%ebx
jle    11a6 <main+0x76>
mov    %rsp,%rdi
mov    %r15,%rsi
call   1050 <copy@plt>
mov    %ebx,%r14d
cmp    $0x51,%ebx
jb     1180 <main+0x50>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %ebx,%edx
mov    %rbp,%rcx
mov    %r15,%r8
call   1040 <printf@plt>
jmp    1180 <main+0x50>
cmp    $0x51,%r14d
jl     11e6 <main+0xb6>
lea    0xe33(%rip),%rdi
lea    0xe3c(%rip),%rsi
lea    0xe40(%rip),%rcx
mov    %rsp,%r8
mov    %r14d,%edx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x7d8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"%s: %3d %s: %s\00"
@.str.1 = [6 x i8] c"Chars\00"
@.str.2 = [5 x i8] c"Line\00"
@.str.3 = [5 x i8] c"Long\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 = %26, %0
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%8 = call i32 @getaline(i8* %7, i32 1000)
store i32 %8, i32* %2
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %27
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 [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%17 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%18 = call i32 @copy(i8* %16, i8* %17)
br label %19
19: ; preds = %14, %10
%20 = load i32, i32* %2
%21 = icmp sgt i32 %20, 80
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = load i32, i32* %2
%24 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%25 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %22, %19
br label %6
27: ; preds = %6
%28 = load i32, i32* %3
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %37
30: ; preds = %27
%31 = load i32, i32* %3
%32 = icmp sgt i32 %31, 80
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = load i32, i32* %3
%35 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%36 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %35)
br label %37
37: ; preds = %33, %30, %27
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"%s: %3d %s: %s\00"
@.str.1 = [6 x i8] c"Chars\00"
@.str.2 = [5 x i8] c"Line\00"
@.str.3 = [5 x i8] c"Long\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 @getaline(i8* %3, i32 1000)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %25
7: ; preds = %0, %18
%8 = phi i32 [ %19, %18 ], [ %5, %0 ]
%9 = phi i32 [ %14, %18 ], [ 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 = icmp ugt i32 %8, 80
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %3)
br label %18
18: ; preds = %16, %13
%19 = call i32 @getaline(i8* %3, i32 1000)
%20 = icmp sgt i32 %19, 0
br i1 %20, label %7, label %21
21: ; preds = %18
%22 = icmp sgt i32 %14, 80
br i1 %22, label %23, label %25
23: ; preds = %21
%24 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %4)
br label %25
25: ; preds = %0, %23, %21
ret i32 0
}