#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*/ printf(char *);
int read_lines(char **);
int /*<<< orphan*/ string_sort(char **, int /*<<< orphan*/, int);
int /*<<< orphan*/ write_lines(char **, int);
int main(void) {
  int line_count;
  char *line_pointer_array[5000];
  if ((line_count = read_lines(line_pointer_array)) >= 0) {
    string_sort(line_pointer_array, 0, line_count - 1);
    write_lines(line_pointer_array, line_count);
    return 0;
  } else {
    printf("error: input too big to sort\n");
    return 1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9c50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x9c50(%rbp),%rdi
call   1060 <read_lines@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jl     1199 <main+0x59>
lea    -0x9c50(%rbp),%rdi
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1040 <string_sort@plt>
lea    -0x9c50(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1030 <write_lines@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ac <main+0x6c>
lea    0xe60(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x9c50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x9c40,%rsp
mov    %rsp,%rdi
call   1060 <read_lines@plt>
test   %eax,%eax
js     1179 <main+0x39>
mov    %eax,%ebx
mov    %eax,%edx
add    $0xffffffff,%edx
mov    %rsp,%r14
xor    %ebp,%ebp
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <string_sort@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <write_lines@plt>
jmp    118a <main+0x4a>
lea    0xe80(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x9c40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"error: input too big to sort\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [5000 x i8*]
store i32 0, i32* %1
%4 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %3, i64 0, i64 0
%5 = call i32 @read_lines(i8** %4)
store i32 %5, i32* %2
%6 = icmp sge i32 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %0
%8 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %3, i64 0, i64 0
%9 = load i32, i32* %2
%10 = sub nsw i32 %9, 1
%11 = call i32 @string_sort(i8** %8, i32 0, i32 %10)
%12 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %3, i64 0, i64 0
%13 = load i32, i32* %2
%14 = call i32 @write_lines(i8** %12, i32 %13)
store i32 0, i32* %1
br label %17
15: ; preds = %0
%16 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %17
17: ; preds = %15, %7
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
@str = [29 x i8] c"error: input too big to sort\00"
define i32 @main() {
%1 = alloca [5000 x i8*]
%2 = bitcast [5000 x i8*]* %1 to i8*
%3 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %1, i64 0, i64 0
%4 = call i32 @read_lines(i8** %3)
%5 = icmp sgt i32 %4, -1
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = add nsw i32 %4, -1
%8 = call i32 @string_sort(i8** %3, i32 0, i32 %7)
%9 = call i32 @write_lines(i8** %3, i32 %4)
br label %12
10: ; preds = %0
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %10, %6
%13 = phi i32 [ 0, %6 ], [ 1, %10 ]
ret i32 %13
}