#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 getmyline(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int main() {
  int len;
  char line[1000];
  char longest[1000][1000];
  int offset = 0;
  int flag = 0;
  while ((len = getmyline(line, 1000)) > 0) {
    if (len > flag) {
      copy(longest[offset], line);
      offset++;
    }
  }
  for (int i = 0; i <= offset; i++) {
    printf("%s\n", longest[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf4640,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xf4634(%rbp)
movl   $0x0,-0xf4638(%rbp)
lea    -0x3f0(%rbp),%rdi
mov    $0x3e8,%esi
call   1030 <getmyline@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    11ba <main+0x8a>
mov    -0x8(%rbp),%eax
cmp    -0xf4638(%rbp),%eax
jle    11b5 <main+0x85>
movslq -0xf4634(%rbp),%rax
lea    -0xf4630(%rbp),%rdi
imul   $0x3e8,%rax,%rax
add    %rax,%rdi
lea    -0x3f0(%rbp),%rsi
call   1050 <copy@plt>
mov    -0xf4634(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4634(%rbp)
jmp    1156 <main+0x26>
movl   $0x0,-0xf463c(%rbp)
mov    -0xf463c(%rbp),%eax
cmp    -0xf4634(%rbp),%eax
jg     120e <main+0xde>
movslq -0xf463c(%rbp),%rax
lea    -0xf4630(%rbp),%rsi
imul   $0x3e8,%rax,%rax
add    %rax,%rsi
lea    0xe0b(%rip),%rdi
call   1040 <printf@plt>
mov    -0xf463c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf463c(%rbp)
jmp    11c4 <main+0x94>
xor    %eax,%eax
add    $0xf4640,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xf4630,%rsp
mov    %rsp,%rdi
mov    $0x3e8,%esi
call   1030 <getmyline@plt>
mov    $0x1,%r15d
test   %eax,%eax
jle    118a <main+0x5a>
lea    0x3f0(%rsp),%rbx
mov    %rsp,%r14
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <copy@plt>
mov    %r14,%rdi
mov    $0x3e8,%esi
call   1030 <getmyline@plt>
add    $0x1,%r15
add    $0x3e8,%rbx
test   %eax,%eax
jg     1160 <main+0x30>
mov    %r15d,%r15d
lea    0x3f0(%rsp),%rbx
lea    0xe67(%rip),%r14
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
add    $0x3e8,%rbx
add    $0xffffffffffffffff,%r15
jne    11a0 <main+0x70>
xor    %eax,%eax
add    $0xf4630,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [1000 x i8]
%4 = alloca [1000 x [1000 x i8]]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %6
br label %8
8: ; preds = %25, %0
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%10 = call i32 @getmyline(i8* %9, i32 1000)
store i32 %10, i32* %2
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %26
12: ; preds = %8
%13 = load i32, i32* %2
%14 = load i32, i32* %6
%15 = icmp sgt i32 %13, %14
br i1 %15, label %16, label %25
16: ; preds = %12
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [1000 x [1000 x i8]], [1000 x [1000 x i8]]* %4, i64 0, i64 %18
%20 = getelementptr inbounds [1000 x i8], [1000 x i8]* %19, i64 0, i64 0
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%22 = call i32 @copy(i8* %20, i8* %21)
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %25
25: ; preds = %16, %12
br label %8
26: ; preds = %8
store i32 0, i32* %7
br label %27
27: ; preds = %37, %26
%28 = load i32, i32* %7
%29 = load i32, i32* %5
%30 = icmp sle i32 %28, %29
br i1 %30, label %31, label %40
31: ; preds = %27
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [1000 x [1000 x i8]], [1000 x [1000 x i8]]* %4, i64 0, i64 %33
%35 = getelementptr inbounds [1000 x i8], [1000 x i8]* %34, i64 0, i64 0
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %35)
br label %37
37: ; preds = %31
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
br label %27
40: ; preds = %27
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [1000 x [1000 x i8]]
%3 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1000 x [1000 x i8]], [1000 x [1000 x i8]]* %2, i64 0, i64 0, i64 0
%5 = call i32 @getmyline(i8* %3, i32 1000)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %12, label %10
7: ; preds = %12
%8 = add i64 %13, 2
%9 = and i64 %8, 4294967295
br label %10
10: ; preds = %7, %0
%11 = phi i64 [ 1, %0 ], [ %9, %7 ]
br label %20
12: ; preds = %0, %12
%13 = phi i64 [ %16, %12 ], [ 0, %0 ]
%14 = getelementptr inbounds [1000 x [1000 x i8]], [1000 x [1000 x i8]]* %2, i64 0, i64 %13, i64 0
%15 = call i32 @copy(i8* %14, i8* %3)
%16 = add nuw i64 %13, 1
%17 = call i32 @getmyline(i8* %3, i32 1000)
%18 = icmp sgt i32 %17, 0
br i1 %18, label %12, label %7
19: ; preds = %20
ret i32 0
20: ; preds = %10, %20
%21 = phi i64 [ 0, %10 ], [ %24, %20 ]
%22 = getelementptr inbounds [1000 x [1000 x i8]], [1000 x [1000 x i8]]* %2, i64 0, i64 %21, i64 0
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = add nuw nsw i64 %21, 1
%25 = icmp eq i64 %24, %11
br i1 %25, label %19, label %20
}