#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 EXIT_SUCCESS;
int /*<<< orphan*/ copy(char *, char *);
int get_line(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int main(void) {
  int len;
  int max;
  int prevlen;
  char line[3];
  char longest[3];
  char temp[3];
  max = prevlen = 0;
  while ((len = get_line(line, 3)) > 0) {
    if (prevlen + len > max) {
      max = prevlen + len;
      if (!prevlen)
        copy(longest, line);
      else
        copy(longest, temp);
    }
    if (line[len - 1] != '\n') {
      if (!prevlen)
        copy(temp, line);
      prevlen += len;
    } else
      prevlen = 0;
  }
  if (max > 0) {
    printf("%s", longest);
    if (longest[max - 1] != '\n')
      putchar('\n');
    printf("%d characters\n", max);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x13(%rbp),%rdi
mov    $0x3,%esi
call   1040 <get_line@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    1204 <main+0xc4>
mov    -0x10(%rbp),%eax
add    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11bd <main+0x7d>
mov    -0x10(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    11ab <main+0x6b>
lea    -0x16(%rbp),%rdi
lea    -0x13(%rbp),%rsi
call   1060 <copy@plt>
jmp    11b8 <main+0x78>
lea    -0x16(%rbp),%rdi
lea    -0x19(%rbp),%rsi
call   1060 <copy@plt>
jmp    11bd <main+0x7d>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x13(%rbp,%rax,1),%eax
cmp    $0xa,%eax
je     11f8 <main+0xb8>
cmpl   $0x0,-0x10(%rbp)
jne    11ea <main+0xaa>
lea    -0x19(%rbp),%rdi
lea    -0x13(%rbp),%rsi
call   1060 <copy@plt>
mov    -0x8(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11ff <main+0xbf>
movl   $0x0,-0x10(%rbp)
jmp    115d <main+0x1d>
cmpl   $0x0,-0xc(%rbp)
jle    1251 <main+0x111>
lea    -0x16(%rbp),%rsi
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x16(%rbp,%rax,1),%eax
cmp    $0xa,%eax
je     1240 <main+0x100>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%esi
lea    0xdb9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2d88(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0x12(%rsp),%rdi
mov    $0x3,%esi
call   1040 <get_line@plt>
test   %eax,%eax
jle    1227 <main+0xe7>
mov    %eax,%ebx
xor    %r14d,%r14d
lea    0x12(%rsp),%r15
lea    0x15(%rsp),%r12
xor    %r13d,%r13d
jmp    1198 <main+0x58>
mov    %ebp,%r13d
nopl   0x0(%rax)
xor    %ebp,%ebp
mov    %r15,%rdi
mov    $0x3,%esi
call   1040 <get_line@plt>
mov    %eax,%ebx
mov    %ebp,%r14d
test   %eax,%eax
jle    11e9 <main+0xa9>
lea    (%rbx,%r14,1),%ebp
cmp    %r13d,%ebp
jle    11b6 <main+0x76>
lea    0xf(%rsp),%rdi
test   %r14d,%r14d
je     11c7 <main+0x87>
mov    %r12,%rsi
call   1060 <copy@plt>
mov    %ebp,%r13d
add    $0xffffffff,%ebx
cmpb   $0xa,0x12(%rsp,%rbx,1)
je     1180 <main+0x40>
test   %r14d,%r14d
jne    1182 <main+0x42>
jmp    11dc <main+0x9c>
mov    %r15,%rsi
call   1060 <copy@plt>
add    $0xffffffff,%ebx
cmpb   $0xa,0x12(%rsp,%rbx,1)
mov    %ebp,%r13d
je     1179 <main+0x39>
mov    %r12,%rdi
mov    %r15,%rsi
call   1060 <copy@plt>
jmp    1182 <main+0x42>
test   %r13d,%r13d
jle    1227 <main+0xe7>
lea    0xe0b(%rip),%rdi
lea    0xf(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    -0x1(%r13),%eax
cmpb   $0xa,0xf(%rsp,%rax,1)
je     1216 <main+0xd6>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xde6(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2db2(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [15 x i8] c"%d characters\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [3 x i8]
%6 = alloca [3 x i8]
%7 = alloca [3 x i8]
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %3
br label %8
8: ; preds = %53, %0
%9 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%10 = call i32 @get_line(i8* %9, i32 3)
store i32 %10, i32* %2
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %54
12: ; preds = %8
%13 = load i32, i32* %4
%14 = load i32, i32* %2
%15 = add nsw i32 %13, %14
%16 = load i32, i32* %3
%17 = icmp sgt i32 %15, %16
br i1 %17, label %18, label %33
18: ; preds = %12
%19 = load i32, i32* %4
%20 = load i32, i32* %2
%21 = add nsw i32 %19, %20
store i32 %21, i32* %3
%22 = load i32, i32* %4
%23 = icmp ne i32 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %18
%25 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%26 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%27 = call i32 @copy(i8* %25, i8* %26)
br label %32
28: ; preds = %18
%29 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%30 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%31 = call i32 @copy(i8* %29, i8* %30)
br label %32
32: ; preds = %28, %24
br label %33
33: ; preds = %32, %12
%34 = load i32, i32* %2
%35 = sub nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 10
br i1 %40, label %41, label %52
41: ; preds = %33
%42 = load i32, i32* %4
%43 = icmp ne i32 %42, 0
br i1 %43, label %48, label %44
44: ; preds = %41
%45 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%46 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%47 = call i32 @copy(i8* %45, i8* %46)
br label %48
48: ; preds = %44, %41
%49 = load i32, i32* %2
%50 = load i32, i32* %4
%51 = add nsw i32 %50, %49
store i32 %51, i32* %4
br label %53
52: ; preds = %33
store i32 0, i32* %4
br label %53
53: ; preds = %52, %48
br label %8
54: ; preds = %8
%55 = load i32, i32* %3
%56 = icmp sgt i32 %55, 0
br i1 %56, label %57, label %72
57: ; preds = %54
%58 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %58)
%60 = load i32, i32* %3
%61 = sub nsw i32 %60, 1
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 %62
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp ne i32 %65, 10
br i1 %66, label %67, label %69
67: ; preds = %57
%68 = call i32 @putchar(i8 signext 10)
br label %69
69: ; preds = %67, %57
%70 = load i32, i32* %3
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %70)
br label %72
72: ; preds = %69, %54
%73 = load i32, i32* @EXIT_SUCCESS
ret i32 %73
}

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