#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 */
typedef int /*<<< orphan*/ ssize_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ getline(char **, size_t *, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *, ...);
scalar_t__ strlen(char *);
int main(int argc, char **argv) {
  FILE *f;
  char *line;
  char *tab[2];
  size_t linecap = 0;
  ssize_t linelen;
  if (argc > 1) {
    line = (char *)malloc(sizeof(char) * 1024);
    f = fopen(argv[1], "r");
    tab[0] = "\0";
    tab[1] = "\0";
    while ((linelen = getline(&line, &linecap, f)) > 0) {
      if (strlen(tab[0]) < strlen(line)) {
        tab[1] = tab[0];
        tab[0] = line;
      } else if (strlen(tab[1]) < strlen(line)) {
        tab[1] = line;
      }
      printf("%s", tab[1]);
    }
    printf("%s%s", tab[0], tab[1]);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x38(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    126c <main+0x11c>
mov    $0x400,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    0xe62(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe57(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1070 <getline@plt>
mov    %eax,-0x3c(%rbp)
cmp    $0x0,%eax
jle    1256 <main+0x106>
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
cmp    %rcx,%rax
jge    120c <main+0xbc>
mov    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    123f <main+0xef>
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x50(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x50(%rbp),%rax
cmp    %rcx,%rax
jge    123a <main+0xea>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    123f <main+0xef>
mov    -0x28(%rbp),%rsi
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11b4 <main+0x64>
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x10(%rsp)
cmp    $0x2,%edi
jl     1246 <main+0xf6>
mov    %rsi,%rbx
mov    $0x400,%edi
call   1050 <malloc@plt>
mov    %rax,0x8(%rsp)
mov    0x8(%rbx),%rdi
lea    0xe73(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %rax,%rdx
call   1070 <getline@plt>
test   %eax,%eax
jle    1228 <main+0xd8>
lea    0xe51(%rip),%rbx
mov    %rbx,%rbp
jmp    11f6 <main+0xa6>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rax
mov    %rbp,%r15
mov    %rax,%rbp
mov    %rbp,%rbx
lea    0xe31(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %r14,%rdx
call   1070 <getline@plt>
mov    %r15,%rbp
test   %eax,%eax
jle    1232 <main+0xe2>
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %rax,%r13
mov    0x8(%rsp),%r15
mov    %r15,%rdi
call   1030 <strlen@plt>
cmp    %rax,%r13
jl     11c9 <main+0x79>
mov    %rax,%r12
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    %r12,%rax
jl     11c0 <main+0x70>
mov    %rbx,%r15
jmp    11c0 <main+0x70>
lea    0xdd8(%rip),%r15
mov    %r15,%rbx
lea    0xdc9(%rip),%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] zeroinitializer
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [5 x i8] c"%s%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca [2 x i8*]
%9 = alloca i64
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %9
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %60
13: ; preds = %2
%14 = call i64 @malloc(i32 1024)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %7
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %19, i32** %6
%20 = getelementptr inbounds [2 x i8*], [2 x i8*]* %8, i64 0, i64 0
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %20
%21 = getelementptr inbounds [2 x i8*], [2 x i8*]* %8, i64 0, i64 1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %21
br label %22
22: ; preds = %50, %13
%23 = load i32*, i32** %6
%24 = call i32 @getline(i8** %7, i64* %9, i32* %23)
store i32 %24, i32* %10
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %54
26: ; preds = %22
%27 = getelementptr inbounds [2 x i8*], [2 x i8*]* %8, i64 0, i64 0
%28 = load i8*, i8** %27
%29 = call i64 @strlen(i8* %28)
%30 = load i8*, i8** %7
%31 = call i64 @strlen(i8* %30)
%32 = icmp slt i64 %29, %31
br i1 %32, label %33, label %39
33: ; preds = %26
%34 = getelementptr inbounds [2 x i8*], [2 x i8*]* %8, i64 0, i64 0
%35 = load i8*, i8** %34
%36 = getelementptr inbounds [2 x i8*], [2 x i8*]* %8, i64 0, i64 1
store i8* %35, i8** %36
%37 = load i8*, i8** %7
%38 = getelementptr inbounds [2 x i8*], [2 x i8*]* %8, i64 0, i64 0
store i8* %37, i8** %38
br label %50
39: ; preds = %26
%40 = getelementptr inbounds [2 x i8*], [2 x i8*]* %8, i64 0, i64 1
%41 = load i8*, i8** %40
%42 = call i64 @strlen(i8* %41)
%43 = load i8*, i8** %7
%44 = call i64 @strlen(i8* %43)
%45 = icmp slt i64 %42, %44
br i1 %45, label %46, label %49
46: ; preds = %39
%47 = load i8*, i8** %7
%48 = getelementptr inbounds [2 x i8*], [2 x i8*]* %8, i64 0, i64 1
store i8* %47, i8** %48
br label %49
49: ; preds = %46, %39
br label %50
50: ; preds = %49, %33
%51 = getelementptr inbounds [2 x i8*], [2 x i8*]* %8, i64 0, i64 1
%52 = load i8*, i8** %51
%53 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %52)
br label %22
54: ; preds = %22
%55 = getelementptr inbounds [2 x i8*], [2 x i8*]* %8, i64 0, i64 0
%56 = load i8*, i8** %55
%57 = getelementptr inbounds [2 x i8*], [2 x i8*]* %8, i64 0, i64 1
%58 = load i8*, i8** %57
%59 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %56, i8* %58)
br label %60
60: ; preds = %54, %2
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] zeroinitializer
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [5 x i8] c"%s%s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = bitcast i8** %3 to i8*
%6 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %37
8: ; preds = %2
%9 = tail call i64 @malloc(i32 1024)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %3
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @getline(i8** %3, i64* %4, i32* %13)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %33
16: ; preds = %8, %27
%17 = phi i8* [ %29, %27 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %8 ]
%18 = phi i8* [ %28, %27 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %8 ]
%19 = call i64 @strlen(i8* dereferenceable(1) %18)
%20 = load i8*, i8** %3
%21 = call i64 @strlen(i8* dereferenceable(1) %20)
%22 = icmp slt i64 %19, %21
br i1 %22, label %27, label %23
23: ; preds = %16
%24 = call i64 @strlen(i8* dereferenceable(1) %17)
%25 = icmp slt i64 %24, %21
%26 = select i1 %25, i8* %20, i8* %17
br label %27
27: ; preds = %23, %16
%28 = phi i8* [ %20, %16 ], [ %18, %23 ]
%29 = phi i8* [ %18, %16 ], [ %26, %23 ]
%30 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %29)
%31 = call i32 @getline(i8** %3, i64* %4, i32* %13)
%32 = icmp sgt i32 %31, 0
br i1 %32, label %16, label %33
33: ; preds = %27, %8
%34 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %8 ], [ %28, %27 ]
%35 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %8 ], [ %29, %27 ]
%36 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %34, i8* %35)
br label %37
37: ; preds = %33, %2
ret i32 0
}