#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 *, char *, char *, char *, int, ...);
int main() {
  char line[1000];
  char longestline[1000];
  int MAX;
  int length;
  MAX = 0;
  while ((length = _getline(line, 1000)) > 0) {
    if (length > MAX) {
      MAX = length;
      _copy(longestline, line);
    }
    if (length > 20) {
      printf("%s%s\t%s%d\t%s%d\n", "Input line:", line, "Input length:", length,
             "length is bigger than: ", 20);
    }
  }
  if (MAX > 0) {
    printf("%s%s\n%s%d\n", "The max input line is: ", longestline,
           "The length is: ", MAX);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7f0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x7e4(%rbp)
lea    -0x3f0(%rbp),%rdi
mov    $0x3e8,%esi
call   1050 <_getline@plt>
mov    %eax,-0x7e8(%rbp)
cmp    $0x0,%eax
jle    11e7 <main+0xb7>
mov    -0x7e8(%rbp),%eax
cmp    -0x7e4(%rbp),%eax
jle    119d <main+0x6d>
mov    -0x7e8(%rbp),%eax
mov    %eax,-0x7e4(%rbp)
lea    -0x7e0(%rbp),%rdi
lea    -0x3f0(%rbp),%rsi
call   1040 <_copy@plt>
cmpl   $0x14,-0x7e8(%rbp)
jle    11e2 <main+0xb2>
lea    -0x3f0(%rbp),%rdx
mov    -0x7e8(%rbp),%r8d
lea    0xe41(%rip),%rdi
lea    0xe4a(%rip),%rsi
lea    0xe4f(%rip),%rcx
lea    0xe56(%rip),%r9
movl   $0x14,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
jmp    114c <main+0x1c>
cmpl   $0x0,-0x7e4(%rbp)
jle    121e <main+0xee>
lea    -0x7e0(%rbp),%rdx
mov    -0x7e4(%rbp),%r8d
lea    0xe39(%rip),%rdi
lea    0xe3d(%rip),%rsi
lea    0xe4e(%rip),%rcx
mov    $0x0,%al
call   1030 <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    $0x7e8,%rsp
lea    0x400(%rsp),%rdi
mov    $0x3e8,%esi
call   1050 <_getline@plt>
test   %eax,%eax
jle    11fc <main+0xcc>
mov    %eax,%ebx
lea    0x400(%rsp),%r15
lea    0xea4(%rip),%r13
lea    0xea9(%rip),%rbp
lea    0xeb0(%rip),%r12
xor    %r14d,%r14d
jmp    1193 <main+0x63>
nop
mov    %r15,%rdi
mov    $0x3e8,%esi
call   1050 <_getline@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    11d3 <main+0xa3>
cmp    %r14d,%ebx
jle    11a8 <main+0x78>
lea    0x10(%rsp),%rdi
mov    %r15,%rsi
call   1040 <_copy@plt>
mov    %ebx,%r14d
cmp    $0x15,%ebx
jb     1180 <main+0x50>
movl   $0x14,(%rsp)
lea    0xe45(%rip),%rdi
mov    %r13,%rsi
mov    %r15,%rdx
mov    %rbp,%rcx
mov    %ebx,%r8d
mov    %r12,%r9
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1180 <main+0x50>
test   %r14d,%r14d
jle    11fc <main+0xcc>
lea    0xe63(%rip),%rdi
lea    0xe67(%rip),%rsi
lea    0xe78(%rip),%rcx
lea    0x10(%rsp),%rdx
mov    %r14d,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"%s%s\09%s%d\09%s%d\0A\00"
@.str.1 = [12 x i8] c"Input line:\00"
@.str.2 = [14 x i8] c"Input length:\00"
@.str.3 = [24 x i8] c"length is bigger than: \00"
@.str.4 = [11 x i8] c"%s%s\0A%s%d\0A\00"
@.str.5 = [24 x i8] c"The max input line is: \00"
@.str.6 = [16 x i8] c"The length is: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x i8]
%3 = alloca [1000 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %6
6: ; preds = %26, %0
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%8 = call i32 @_getline(i8* %7, i32 1000)
store i32 %8, i32* %5
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %27
10: ; preds = %6
%11 = load i32, i32* %5
%12 = load i32, i32* %4
%13 = icmp sgt i32 %11, %12
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = load i32, i32* %5
store i32 %15, i32* %4
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%17 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%18 = call i32 @_copy(i8* %16, i8* %17)
br label %19
19: ; preds = %14, %10
%20 = load i32, i32* %5
%21 = icmp sgt i32 %20, 20
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%24 = load i32, i32* %5
%25 = call i32 (i8*, i8*, i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %23, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %24, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 20)
br label %26
26: ; preds = %22, %19
br label %6
27: ; preds = %6
%28 = load i32, i32* %4
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %27
%31 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%32 = load i32, i32* %4
%33 = call i32 (i8*, i8*, i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %31, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %30, %27
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"%s%s\09%s%d\09%s%d\0A\00"
@.str.1 = [12 x i8] c"Input line:\00"
@.str.2 = [14 x i8] c"Input length:\00"
@.str.3 = [24 x i8] c"length is bigger than: \00"
@.str.4 = [11 x i8] c"%s%s\0A%s%d\0A\00"
@.str.5 = [24 x i8] c"The max input line is: \00"
@.str.6 = [16 x i8] c"The length is: \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 @_getline(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, 20
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 (i8*, i8*, i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %3, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %8, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 20)
br label %18
18: ; preds = %16, %13
%19 = call i32 @_getline(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, 0
br i1 %22, label %23, label %25
23: ; preds = %21
%24 = call i32 (i8*, i8*, i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %4, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %14)
br label %25
25: ; preds = %0, %23, %21
ret i32 0
}