#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 *);
scalar_t__ getmyline(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int main() {
  char line[1024];
  char longest[1024][1024];
  int offset = 0;
  while (getmyline(line, 40) > 0) {
    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    $0x100420,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x100414(%rbp)
lea    -0x410(%rbp),%rdi
mov    $0x28,%esi
call   1030 <getmyline@plt>
cmp    $0x0,%rax
jle    119c <main+0x6c>
movslq -0x100414(%rbp),%rax
lea    -0x100410(%rbp),%rdi
shl    $0xa,%rax
add    %rax,%rdi
lea    -0x410(%rbp),%rsi
call   1050 <copy@plt>
mov    -0x100414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x100414(%rbp)
jmp    114c <main+0x1c>
movl   $0x0,-0x100418(%rbp)
mov    -0x100418(%rbp),%eax
cmp    -0x100414(%rbp),%eax
jg     11ed <main+0xbd>
movslq -0x100418(%rbp),%rax
lea    -0x100410(%rbp),%rsi
shl    $0xa,%rax
add    %rax,%rsi
lea    0xe2c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x100418(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x100418(%rbp)
jmp    11a6 <main+0x76>
xor    %eax,%eax
add    $0x100420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x100400,%rsp
mov    %rsp,%rdi
mov    $0x28,%esi
call   1030 <getmyline@plt>
mov    $0x1,%r15d
test   %rax,%rax
jle    118b <main+0x5b>
lea    0x400(%rsp),%rbx
mov    %rsp,%r14
nop
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <copy@plt>
mov    %r14,%rdi
mov    $0x28,%esi
call   1030 <getmyline@plt>
add    $0x1,%r15
add    $0x400,%rbx
test   %rax,%rax
jg     1160 <main+0x30>
mov    %r15d,%r15d
lea    0x400(%rsp),%rbx
lea    0xe66(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
add    $0x400,%rbx
add    $0xffffffffffffffff,%r15
jne    11a0 <main+0x70>
xor    %eax,%eax
add    $0x100400,%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 [1024 x i8]
%3 = alloca [1024 x [1024 x i8]]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %6
6: ; preds = %10, %0
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%8 = call i64 @getmyline(i8* %7, i32 40)
%9 = icmp sgt i64 %8, 0
br i1 %9, label %10, label %19
10: ; preds = %6
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [1024 x [1024 x i8]], [1024 x [1024 x i8]]* %3, i64 0, i64 %12
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%16 = call i32 @copy(i8* %14, i8* %15)
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
store i32 %18, i32* %4
br label %6
19: ; preds = %6
store i32 0, i32* %5
br label %20
20: ; preds = %30, %19
%21 = load i32, i32* %5
%22 = load i32, i32* %4
%23 = icmp sle i32 %21, %22
br i1 %23, label %24, label %33
24: ; preds = %20
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [1024 x [1024 x i8]], [1024 x [1024 x i8]]* %3, i64 0, i64 %26
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 0
%29 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %28)
br label %30
30: ; preds = %24
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %20
33: ; preds = %20
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = alloca [1024 x [1024 x i8]]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1024 x [1024 x i8]], [1024 x [1024 x i8]]* %2, i64 0, i64 0, i64 0
%5 = call i64 @getmyline(i8* %3, i32 40)
%6 = icmp sgt i64 %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 [1024 x [1024 x i8]], [1024 x [1024 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 i64 @getmyline(i8* %3, i32 40)
%18 = icmp sgt i64 %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 [1024 x [1024 x i8]], [1024 x [1024 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
}