#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ print_array(char **, int, int, int);
int /*<<< orphan*/ printf(char *);
int scanf(char *, char *);
int /*<<< orphan*/ selection_sort_asc(void **, int);
int /*<<< orphan*/ str_copy(char *, char *);
int str_len(char *);
int main() {
  char **data;
  char *s = (char *)malloc(sizeof(char) * 256);
  int i = 0, n = 0, col_width = 0, col_num = 0, l = 0;
  while (scanf("%s", s) == 1) {
    l = str_len(s);
    if (col_width < l)
      col_width = l;
    data[i] = (char *)malloc(sizeof(char) * l);
    str_copy(data[i], s);
    i++;
  }
  n = i;
  col_width += 2;
  col_num = 80 / col_width;
  printf("[Before sorting]\n");
  print_array(data, n, col_width, col_num);
  selection_sort_asc((void **)data, n);
  printf("[After sorting]\n");
  print_array(data, n, col_width, col_num);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x100,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe45(%rip),%rdi
call   1070 <scanf@plt>
cmp    $0x1,%eax
jne    1228 <main+0xb8>
mov    -0x18(%rbp),%rdi
call   1090 <str_len@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    11e7 <main+0x77>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x24(%rbp)
movslq -0x2c(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <str_copy@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b0 <main+0x40>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x24(%rbp)
mov    $0x50,%eax
cltd
idivl  -0x24(%rbp)
mov    %eax,-0x28(%rbp)
lea    0xdb9(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
call   1040 <print_array@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1030 <selection_sort_asc@plt>
lea    0xda1(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
call   1040 <print_array@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x100,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe8b(%rip),%rdi
mov    %rax,%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
je     11c7 <main+0x67>
lea    0xe7a(%rip),%rdi
call   1040 <puts@plt>
xor    %esi,%esi
mov    $0x2,%edx
mov    $0x28,%ecx
call   1050 <print_array@plt>
xor    %esi,%esi
call   1030 <selection_sort_asc@plt>
lea    0xe67(%rip),%rdi
call   1040 <puts@plt>
xor    %esi,%esi
mov    $0x2,%edx
mov    $0x28,%ecx
call   1050 <print_array@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    %rbx,%rdi
call   1080 <str_len@plt>
mov    %eax,%edi
call   1060 <malloc@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [18 x i8] c"[Before sorting]\0A\00"
@.str.2 = [17 x i8] c"[After sorting]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8**
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = call i64 @malloc(i32 256)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
br label %11
11: ; preds = %23, %0
%12 = load i8*, i8** %3
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %43
15: ; preds = %11
%16 = load i8*, i8** %3
%17 = call i32 @str_len(i8* %16)
store i32 %17, i32* %8
%18 = load i32, i32* %6
%19 = load i32, i32* %8
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %15
%22 = load i32, i32* %8
store i32 %22, i32* %6
br label %23
23: ; preds = %21, %15
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = mul i64 1, %25
%27 = trunc i64 %26 to i32
%28 = call i64 @malloc(i32 %27)
%29 = inttoptr i64 %28 to i8*
%30 = load i8**, i8*** %2
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8*, i8** %30, i64 %32
store i8* %29, i8** %33
%34 = load i8**, i8*** %2
%35 = load i32, i32* %4
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
%39 = load i8*, i8** %3
%40 = call i32 @str_copy(i8* %38, i8* %39)
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
br label %11
43: ; preds = %11
%44 = load i32, i32* %4
store i32 %44, i32* %5
%45 = load i32, i32* %6
%46 = add nsw i32 %45, 2
store i32 %46, i32* %6
%47 = load i32, i32* %6
%48 = sdiv i32 80, %47
store i32 %48, i32* %7
%49 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%50 = load i8**, i8*** %2
%51 = load i32, i32* %5
%52 = load i32, i32* %6
%53 = load i32, i32* %7
%54 = call i32 @print_array(i8** %50, i32 %51, i32 %52, i32 %53)
%55 = load i8**, i8*** %2
%56 = load i32, i32* %5
%57 = call i32 @selection_sort_asc(i8** %55, i32 %56)
%58 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%59 = load i8**, i8*** %2
%60 = load i32, i32* %5
%61 = load i32, i32* %6
%62 = load i32, i32* %7
%63 = call i32 @print_array(i8** %59, i32 %60, i32 %61, i32 %62)
%64 = load i32, i32* %1
ret i32 %64
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@str = [17 x i8] c"[Before sorting]\00"
@str.3 = [16 x i8] c"[After sorting]\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 256)
%2 = inttoptr i64 %1 to i8*
%3 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = icmp eq i32 %3, 1
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = tail call i32 @str_len(i8* %2)
%7 = tail call i64 @malloc(i32 %6)
unreachable
8: ; preds = %0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @print_array(i8** undef, i32 0, i32 2, i32 40)
%11 = tail call i32 @selection_sort_asc(i8** undef, i32 0)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.3, i64 0, i64 0))
%13 = tail call i32 @print_array(i8** undef, i32 0, i32 2, i32 40)
ret i32 0
}