#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ freelines(char **, size_t);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ readlines(char ***, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ sort(char **, size_t);
int /*<<< orphan*/ stdin;
int main() {
  char **lines = NULL;
  size_t num_lines = 0;
  int i;
  if (readlines(&lines, &num_lines, stdin) < 0) {
    exit(EXIT_FAILURE);
  }
  sort(lines, num_lines);
  for (i = 0; i < num_lines; i++) {
    printf("%s", lines[i]);
  }
  freelines(lines, num_lines);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    0x2e72(%rip),%rax
mov    (%rax),%edx
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <readlines@plt>
cmp    $0x0,%rax
jge    119d <main+0x4d>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <sort@plt>
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11e5 <main+0x95>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe2e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b1 <main+0x61>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <freelines@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
mov    0x2e78(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1070 <readlines@plt>
test   %rax,%rax
js     11e7 <main+0x97>
mov    0x10(%rsp),%rdi
mov    0x8(%rsp),%rsi
call   1040 <sort@plt>
cmpq   $0x0,0x8(%rsp)
je     11d1 <main+0x81>
xor    %ebx,%ebx
lea    0xe5a(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    0x10(%rsp),%rax
mov    (%rax,%rbx,8),%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
mov    0x8(%rsp),%rsi
cmp    %rbx,%rsi
ja     11b0 <main+0x60>
jmp    11d3 <main+0x83>
xor    %esi,%esi
mov    0x10(%rsp),%rdi
call   1050 <freelines@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stdin = global i32 0
@EXIT_FAILURE = global i32 0
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8**
%3 = alloca i64
%4 = alloca i32
store i32 0, i32* %1
store i8** null, i8*** %2
store i64 0, i64* %3
%5 = load i32, i32* @stdin
%6 = call i64 @readlines(i8*** %2, i64* %3, i32 %5)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = load i32, i32* @EXIT_FAILURE
%10 = call i32 @exit(i32 %9)
unreachable
11: ; preds = %0
%12 = load i8**, i8*** %2
%13 = load i64, i64* %3
%14 = call i32 @sort(i8** %12, i64 %13)
store i32 0, i32* %4
br label %15
15: ; preds = %27, %11
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = load i64, i64* %3
%19 = icmp ult i64 %17, %18
br i1 %19, label %20, label %30
20: ; preds = %15
%21 = load i8**, i8*** %2
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %20
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
br label %15
30: ; preds = %15
%31 = load i8**, i8*** %2
%32 = load i64, i64* %3
%33 = call i32 @freelines(i8** %31, i64 %32)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@EXIT_FAILURE = global i32 0
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i8**
%2 = alloca i64
%3 = bitcast i8*** %1 to i8*
store i8** null, i8*** %1
%4 = bitcast i64* %2 to i8*
store i64 0, i64* %2
%5 = load i32, i32* @stdin
%6 = call i64 @readlines(i8*** %1, i64* %2, i32 %5)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = load i32, i32* @EXIT_FAILURE
%10 = call i32 @exit(i32 %9)
unreachable
11: ; preds = %0
%12 = load i8**, i8*** %1
%13 = load i64, i64* %2
%14 = call i32 @sort(i8** %12, i64 %13)
%15 = load i64, i64* %2
%16 = icmp eq i64 %15, 0
br i1 %16, label %26, label %17
17: ; preds = %11, %17
%18 = phi i64 [ %23, %17 ], [ 0, %11 ]
%19 = load i8**, i8*** %1
%20 = getelementptr inbounds i8*, i8** %19, i64 %18
%21 = load i8*, i8** %20
%22 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = add nuw i64 %18, 1
%24 = load i64, i64* %2
%25 = icmp ugt i64 %24, %23
br i1 %25, label %17, label %26
26: ; preds = %17, %11
%27 = phi i64 [ 0, %11 ], [ %24, %17 ]
%28 = load i8**, i8*** %1
%29 = call i32 @freelines(i8** %28, i64 %27)
ret i32 0
}