#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 */
char EOF;
int /*<<< orphan*/ copy(char *, char *);
char getchar();
int /*<<< orphan*/ printf(char *, int, char *);
int readline(char *, int);
int main() {
  int len;
  int max;
  char line[1000];
  char longest[1000];
  char c;
  max = 0;
  while ((len = readline(line, 1000)) > 0) {
    if (len == (1000 - 1) && line[1000 - 2] != '\n')
      while ((c = getchar()) != EOF && c != '\n')
        len++;
    if (len > max) {
      max = len;
      copy(longest, line);
    }
  }
  if (max > 0)
    printf("max=%d\n%s\n", max, longest);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x800,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x400(%rbp),%rdi
mov    $0x3e8,%esi
call   1040 <readline@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    1222 <main+0xe2>
cmpl   $0x3e7,-0x8(%rbp)
jne    11f8 <main+0xb8>
movsbl -0x1a(%rbp),%eax
cmp    $0xa,%eax
je     11f8 <main+0xb8>
jmp    1195 <main+0x55>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x7f1(%rbp)
movsbl %al,%ecx
mov    0x2e3c(%rip),%rax
movsbl (%rax),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x7f2(%rbp)
je     11d2 <main+0x92>
movsbl -0x7f1(%rbp),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x7f2(%rbp)
mov    -0x7f2(%rbp),%al
test   $0x1,%al
jne    11e5 <main+0xa5>
jmp    11f3 <main+0xb3>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1195 <main+0x55>
jmp    11f8 <main+0xb8>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    121d <main+0xdd>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    -0x7f0(%rbp),%rdi
lea    -0x400(%rbp),%rsi
call   1050 <copy@plt>
jmp    1159 <main+0x19>
cmpl   $0x0,-0xc(%rbp)
jle    1242 <main+0x102>
mov    -0xc(%rbp),%esi
lea    -0x7f0(%rbp),%rdx
lea    0xdc3(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x800,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x7e0,%rsp
mov    %rsp,%rdi
mov    $0x3e8,%esi
call   1040 <readline@plt>
test   %eax,%eax
jle    11f3 <main+0xb3>
mov    %eax,%ebp
mov    0x2e7b(%rip),%rbx
lea    0x3f0(%rsp),%r14
mov    %rsp,%r15
xor    %r12d,%r12d
jmp    1193 <main+0x53>
nopl   (%rax)
mov    %r15,%rdi
mov    $0x3e8,%esi
call   1040 <readline@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    11d7 <main+0x97>
cmp    $0x3e7,%ebp
jne    11c2 <main+0x82>
cmpb   $0xa,0x3e6(%rsp)
0a
je     11c2 <main+0x82>
mov    $0x3e6,%ebp
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getchar@plt>
add    $0x1,%ebp
cmp    $0xa,%al
je     11c2 <main+0x82>
cmp    (%rbx),%al
jne    11b0 <main+0x70>
cmp    %r12d,%ebp
jle    1180 <main+0x40>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <copy@plt>
mov    %ebp,%r12d
jmp    1180 <main+0x40>
test   %r12d,%r12d
jle    11f3 <main+0xb3>
lea    0xe1d(%rip),%rdi
lea    0x3f0(%rsp),%rdx
mov    %r12d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7e0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i8 0
@.str = [11 x i8] c"max=%d\0A%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [1000 x i8]
%5 = alloca [1000 x i8]
%6 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %3
br label %7
7: ; preds = %45, %0
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%9 = call i32 @readline(i8* %8, i32 1000)
store i32 %9, i32* %2
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %46
11: ; preds = %7
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 999
br i1 %13, label %14, label %36
14: ; preds = %11
%15 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 998
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 10
br i1 %18, label %19, label %36
19: ; preds = %14
br label %20
20: ; preds = %32, %19
%21 = call signext i8 (...) @getchar()
store i8 %21, i8* %6
%22 = sext i8 %21 to i32
%23 = load i8, i8* @EOF
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %22, %24
br i1 %25, label %26, label %30
26: ; preds = %20
%27 = load i8, i8* %6
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 10
br label %30
30: ; preds = %26, %20
%31 = phi i1 [ false, %20 ], [ %29, %26 ]
br i1 %31, label %32, label %35
32: ; preds = %30
%33 = load i32, i32* %2
%34 = add nsw i32 %33, 1
store i32 %34, i32* %2
br label %20
35: ; preds = %30
br label %36
36: ; preds = %35, %14, %11
%37 = load i32, i32* %2
%38 = load i32, i32* %3
%39 = icmp sgt i32 %37, %38
br i1 %39, label %40, label %45
40: ; preds = %36
%41 = load i32, i32* %2
store i32 %41, i32* %3
%42 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%43 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%44 = call i32 @copy(i8* %42, i8* %43)
br label %45
45: ; preds = %40, %36
br label %7
46: ; preds = %7
%47 = load i32, i32* %3
%48 = icmp sgt i32 %47, 0
br i1 %48, label %49, label %53
49: ; preds = %46
%50 = load i32, i32* %3
%51 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%52 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %50, i8* %51)
br label %53
53: ; preds = %49, %46
ret i32 0
}

LLVM IR (-O2):
@EOF = global i8 0
@.str = [11 x i8] c"max=%d\0A%s\0A\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 @readline(i8* %3, i32 1000)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %37
7: ; preds = %0
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 998
br label %9
9: ; preds = %7, %29
%10 = phi i32 [ %5, %7 ], [ %31, %29 ]
%11 = phi i32 [ 0, %7 ], [ %30, %29 ]
%12 = icmp eq i32 %10, 999
%13 = load i8, i8* %8
%14 = icmp ne i8 %13, 10
%15 = select i1 %12, i1 %14, i1 false
br i1 %15, label %16, label %24
16: ; preds = %9, %16
%17 = phi i32 [ %23, %16 ], [ 999, %9 ]
%18 = call signext i8 (...) @getchar()
%19 = load i8, i8* @EOF
%20 = icmp ne i8 %18, %19
%21 = icmp ne i8 %18, 10
%22 = and i1 %21, %20
%23 = add nuw nsw i32 %17, 1
br i1 %22, label %16, label %24
24: ; preds = %16, %9
%25 = phi i32 [ %10, %9 ], [ %17, %16 ]
%26 = icmp sgt i32 %25, %11
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = call i32 @copy(i8* %4, i8* %3)
br label %29
29: ; preds = %27, %24
%30 = phi i32 [ %25, %27 ], [ %11, %24 ]
%31 = call i32 @readline(i8* %3, i32 1000)
%32 = icmp sgt i32 %31, 0
br i1 %32, label %9, label %33
33: ; preds = %29
%34 = icmp sgt i32 %30, 0
br i1 %34, label %35, label %37
35: ; preds = %33
%36 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %30, i8* %4)
br label %37
37: ; preds = %0, %35, %33
ret i32 0
}