#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 /*<<< orphan*/ printf(char *, ...);
int readline(char *);
int main() {
  char line[1024], longest_line[1024];
  int length, max_length;
  max_length = 0;
  while ((length = readline(line)) > 0) {
    if (length > max_length) {
      max_length = length;
      copy(line, longest_line);
    }
  }
  if (max_length > 0) {
    printf("Longest line is %d characters (including newline character):\n%s",
           max_length, longest_line);
  } else {
    printf("There were no lines, yoh.\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x818(%rbp)
lea    -0x410(%rbp),%rdi
call   1040 <readline@plt>
mov    %eax,-0x814(%rbp)
cmp    $0x0,%eax
jle    119d <main+0x6d>
mov    -0x814(%rbp),%eax
cmp    -0x818(%rbp),%eax
jle    1198 <main+0x68>
mov    -0x814(%rbp),%eax
mov    %eax,-0x818(%rbp)
lea    -0x410(%rbp),%rdi
lea    -0x810(%rbp),%rsi
call   1050 <copy@plt>
jmp    114c <main+0x1c>
cmpl   $0x0,-0x818(%rbp)
jle    11ca <main+0x9a>
mov    -0x818(%rbp),%esi
lea    -0x810(%rbp),%rdx
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d8 <main+0xa8>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x808,%rsp
lea    0x400(%rsp),%rdi
call   1050 <readline@plt>
test   %eax,%eax
jle    11aa <main+0x6a>
mov    %eax,%ebp
xor    %ebx,%ebx
lea    0x400(%rsp),%r14
mov    %rsp,%r15
jmp    117e <main+0x3e>
nop
mov    %r14,%rdi
call   1050 <readline@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    1191 <main+0x51>
cmp    %ebx,%ebp
jle    1170 <main+0x30>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <copy@plt>
mov    %ebp,%ebx
jmp    1170 <main+0x30>
test   %ebx,%ebx
jle    11aa <main+0x6a>
lea    0xe64(%rip),%rdi
mov    %rsp,%rdx
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11b6 <main+0x76>
lea    0xe8f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [64 x i8] c"Longest line is %d characters (including newline character):\0A%s\00"
@.str.1 = [27 x i8] c"There were no lines, yoh.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
br label %6
6: ; preds = %19, %0
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%8 = call i32 @readline(i8* %7)
store i32 %8, i32* %4
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %20
10: ; preds = %6
%11 = load i32, i32* %4
%12 = load i32, i32* %5
%13 = icmp sgt i32 %11, %12
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = load i32, i32* %4
store i32 %15, i32* %5
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, 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* %5
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %20
%24 = load i32, i32* %5
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i32 %24, i8* %25)
br label %29
27: ; preds = %20
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %29
29: ; preds = %27, %23
ret i32 0
}

LLVM IR (-O2):
@.str = [64 x i8] c"Longest line is %d characters (including newline character):\0A%s\00"
@str = [26 x i8] c"There were no lines, yoh.\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = call i32 @readline(i8* %3)
%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* %3, i8* %4)
br label %13
13: ; preds = %11, %7
%14 = phi i32 [ %8, %11 ], [ %9, %7 ]
%15 = call i32 @readline(i8* %3)
%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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i32 %14, i8* %4)
br label %23
21: ; preds = %0, %17
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %23
23: ; preds = %21, %19
ret i32 0
}