#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*/ fgets(char *, int, int /*<<< orphan*/);
void *malloc(int);
int /*<<< orphan*/ printTab(char **, int);
int /*<<< orphan*/ selectionsort(char **, int);
int /*<<< orphan*/ stdin;
int main() {
  int maxChars = 10;
  int maxLength = 10;
  char **tab = malloc(maxChars * sizeof(char *));
  for (int i = 0; i < maxChars; i++) {
    *(tab + i) = malloc(maxLength + sizeof(char));
    fgets(*(tab + i), maxLength, stdin);
  }
  printTab(tab, maxLength);
  selectionsort(tab, maxLength);
  printTab(tab, maxLength);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
movl   $0xa,-0xc(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11cc <main+0x8c>
movslq -0xc(%rbp),%rax
add    $0x1,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0xc(%rbp),%esi
mov    0x2e31(%rip),%rax
mov    (%rax),%edx
call   1040 <fgets@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1177 <main+0x37>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <printTab@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1060 <selectionsort@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <printTab@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x50,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    $0xb,%edi
call   1050 <malloc@plt>
mov    %rax,(%rbx)
mov    0x2e83(%rip),%r14
mov    (%r14),%edx
mov    %rax,%rdi
mov    $0xa,%esi
call   1040 <fgets@plt>
mov    $0xb,%edi
call   1050 <malloc@plt>
mov    %rax,0x8(%rbx)
mov    (%r14),%edx
mov    %rax,%rdi
mov    $0xa,%esi
call   1040 <fgets@plt>
mov    $0xb,%edi
call   1050 <malloc@plt>
mov    %rax,0x10(%rbx)
mov    (%r14),%edx
mov    %rax,%rdi
mov    $0xa,%esi
call   1040 <fgets@plt>
mov    $0xb,%edi
call   1050 <malloc@plt>
mov    %rax,0x18(%rbx)
mov    (%r14),%edx
mov    %rax,%rdi
mov    $0xa,%esi
call   1040 <fgets@plt>
mov    $0xb,%edi
call   1050 <malloc@plt>
mov    %rax,0x20(%rbx)
mov    (%r14),%edx
mov    %rax,%rdi
mov    $0xa,%esi
call   1040 <fgets@plt>
mov    $0xb,%edi
call   1050 <malloc@plt>
mov    %rax,0x28(%rbx)
mov    (%r14),%edx
mov    %rax,%rdi
mov    $0xa,%esi
call   1040 <fgets@plt>
mov    $0xb,%edi
call   1050 <malloc@plt>
mov    %rax,0x30(%rbx)
mov    (%r14),%edx
mov    %rax,%rdi
mov    $0xa,%esi
call   1040 <fgets@plt>
mov    $0xb,%edi
call   1050 <malloc@plt>
mov    %rax,0x38(%rbx)
mov    (%r14),%edx
mov    %rax,%rdi
mov    $0xa,%esi
call   1040 <fgets@plt>
mov    $0xb,%edi
call   1050 <malloc@plt>
mov    %rax,0x40(%rbx)
mov    (%r14),%edx
mov    %rax,%rdi
mov    $0xa,%esi
call   1040 <fgets@plt>
mov    $0xb,%edi
call   1050 <malloc@plt>
mov    %rax,0x48(%rbx)
mov    (%r14),%edx
mov    %rax,%rdi
mov    $0xa,%esi
call   1040 <fgets@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1030 <printTab@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1060 <selectionsort@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1030 <printTab@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdin = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %2
store i32 10, i32* %3
%6 = load i32, i32* %2
%7 = sext i32 %6 to i64
%8 = mul i64 %7, 8
%9 = trunc i64 %8 to i32
%10 = call i8* @malloc(i32 %9)
%11 = bitcast i8* %10 to i8**
store i8** %11, i8*** %4
store i32 0, i32* %5
br label %12
12: ; preds = %34, %0
%13 = load i32, i32* %5
%14 = load i32, i32* %2
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %37
16: ; preds = %12
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = add i64 %18, 1
%20 = trunc i64 %19 to i32
%21 = call i8* @malloc(i32 %20)
%22 = load i8**, i8*** %4
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
store i8* %21, i8** %25
%26 = load i8**, i8*** %4
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = load i32, i32* %3
%32 = load i32, i32* @stdin
%33 = call i32 @fgets(i8* %30, i32 %31, i32 %32)
br label %34
34: ; preds = %16
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
br label %12
37: ; preds = %12
%38 = load i8**, i8*** %4
%39 = load i32, i32* %3
%40 = call i32 @printTab(i8** %38, i32 %39)
%41 = load i8**, i8*** %4
%42 = load i32, i32* %3
%43 = call i32 @selectionsort(i8** %41, i32 %42)
%44 = load i8**, i8*** %4
%45 = load i32, i32* %3
%46 = call i32 @printTab(i8** %44, i32 %45)
%47 = load i32, i32* %1
ret i32 %47
}

LLVM IR (-O2):
@stdin = global i32 0
define i32 @main() {
%1 = tail call dereferenceable_or_null(80) i8* @malloc(i32 80)
%2 = bitcast i8* %1 to i8**
%3 = tail call dereferenceable_or_null(11) i8* @malloc(i32 11)
store i8* %3, i8** %2
%4 = load i32, i32* @stdin
%5 = tail call i32 @fgets(i8* %3, i32 10, i32 %4)
%6 = tail call dereferenceable_or_null(11) i8* @malloc(i32 11)
%7 = getelementptr inbounds i8*, i8** %2, i64 1
store i8* %6, i8** %7
%8 = load i32, i32* @stdin
%9 = tail call i32 @fgets(i8* %6, i32 10, i32 %8)
%10 = tail call dereferenceable_or_null(11) i8* @malloc(i32 11)
%11 = getelementptr inbounds i8*, i8** %2, i64 2
store i8* %10, i8** %11
%12 = load i32, i32* @stdin
%13 = tail call i32 @fgets(i8* %10, i32 10, i32 %12)
%14 = tail call dereferenceable_or_null(11) i8* @malloc(i32 11)
%15 = getelementptr inbounds i8*, i8** %2, i64 3
store i8* %14, i8** %15
%16 = load i32, i32* @stdin
%17 = tail call i32 @fgets(i8* %14, i32 10, i32 %16)
%18 = tail call dereferenceable_or_null(11) i8* @malloc(i32 11)
%19 = getelementptr inbounds i8*, i8** %2, i64 4
store i8* %18, i8** %19
%20 = load i32, i32* @stdin
%21 = tail call i32 @fgets(i8* %18, i32 10, i32 %20)
%22 = tail call dereferenceable_or_null(11) i8* @malloc(i32 11)
%23 = getelementptr inbounds i8*, i8** %2, i64 5
store i8* %22, i8** %23
%24 = load i32, i32* @stdin
%25 = tail call i32 @fgets(i8* %22, i32 10, i32 %24)
%26 = tail call dereferenceable_or_null(11) i8* @malloc(i32 11)
%27 = getelementptr inbounds i8*, i8** %2, i64 6
store i8* %26, i8** %27
%28 = load i32, i32* @stdin
%29 = tail call i32 @fgets(i8* %26, i32 10, i32 %28)
%30 = tail call dereferenceable_or_null(11) i8* @malloc(i32 11)
%31 = getelementptr inbounds i8*, i8** %2, i64 7
store i8* %30, i8** %31
%32 = load i32, i32* @stdin
%33 = tail call i32 @fgets(i8* %30, i32 10, i32 %32)
%34 = tail call dereferenceable_or_null(11) i8* @malloc(i32 11)
%35 = getelementptr inbounds i8*, i8** %2, i64 8
store i8* %34, i8** %35
%36 = load i32, i32* @stdin
%37 = tail call i32 @fgets(i8* %34, i32 10, i32 %36)
%38 = tail call dereferenceable_or_null(11) i8* @malloc(i32 11)
%39 = getelementptr inbounds i8*, i8** %2, i64 9
store i8* %38, i8** %39
%40 = load i32, i32* @stdin
%41 = tail call i32 @fgets(i8* %38, i32 10, i32 %40)
%42 = tail call i32 @printTab(i8** %2, i32 10)
%43 = tail call i32 @selectionsort(i8** %2, i32 10)
%44 = tail call i32 @printTab(i8** %2, i32 10)
ret i32 0
}