#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 EXIT_SUCCESS;
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sortp(char **, size_t);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int strlen(char *);
int main(void) {
  char buf[10][21];
  char *pbuf[10];
  size_t n = 0;
  printf("Enter string (max %d size)\n", 21 - 1);
  for (int j = 0; j < 10; j++) {
    printf("string %2d of %2d: ", j + 1, 10);
    fgets(buf[n], 21 - 1, stdin);
    buf[n][strlen(buf[n]) - 1] = '\0';
    pbuf[n] = buf[n];
    n++;
  }
  fputs("\nUnsorted strings:\n", stdout);
  for (int i = 0; i < n; i++)
    printf("%s\n", buf[i]);
  sortp(pbuf, n);
  fputs("\nSorted strings:\n", stdout);
  for (int i = 0; i < n; i++)
    printf("%s\n", pbuf[i]);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x138(%rbp)
lea    0xe8c(%rip),%rdi
mov    $0x14,%esi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x13c(%rbp)
cmpl   $0xa,-0x13c(%rbp)
jge    1262 <main+0x112>
mov    -0x13c(%rbp),%esi
add    $0x1,%esi
lea    0xe75(%rip),%rdi
mov    $0xa,%edx
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xe0(%rbp),%rdi
imul   $0x15,-0x138(%rbp),%rax
15
add    %rax,%rdi
mov    0x2e1c(%rip),%rax
mov    (%rax),%edx
mov    $0x14,%esi
call   1060 <fgets@plt>
lea    -0xe0(%rbp),%rax
imul   $0x15,-0x138(%rbp),%rcx
15
add    %rcx,%rax
mov    %rax,-0x150(%rbp)
lea    -0xe0(%rbp),%rdi
imul   $0x15,-0x138(%rbp),%rax
15
add    %rax,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x150(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
lea    -0xe0(%rbp),%rcx
imul   $0x15,-0x138(%rbp),%rax
15
add    %rax,%rcx
mov    -0x138(%rbp),%rax
mov    %rcx,-0x130(%rbp,%rax,8)
ff
mov    -0x138(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x138(%rbp)
mov    -0x13c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x13c(%rbp)
jmp    118a <main+0x3a>
mov    0x2d6f(%rip),%rax
mov    (%rax),%esi
lea    0xdbe(%rip),%rdi
call   1050 <fputs@plt>
movl   $0x0,-0x140(%rbp)
movslq -0x140(%rbp),%rax
cmp    -0x138(%rbp),%rax
jae    12cc <main+0x17c>
movslq -0x140(%rbp),%rax
lea    -0xe0(%rbp),%rsi
imul   $0x15,%rax,%rax
add    %rax,%rsi
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x140(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x140(%rbp)
jmp    1281 <main+0x131>
lea    -0x130(%rbp),%rdi
mov    -0x138(%rbp),%rsi
call   1070 <sortp@plt>
mov    0x2cf2(%rip),%rax
mov    (%rax),%esi
lea    0xd59(%rip),%rdi
call   1050 <fputs@plt>
movl   $0x0,-0x144(%rbp)
movslq -0x144(%rbp),%rax
cmp    -0x138(%rbp),%rax
jae    1343 <main+0x1f3>
movslq -0x144(%rbp),%rax
mov    -0x130(%rbp,%rax,8),%rsi
ff
lea    0xd1c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x144(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x144(%rbp)
jmp    12fe <main+0x1ae>
mov    0x2c86(%rip),%rax
mov    (%rax),%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x130,%rsp
lea    0xe89(%rip),%rdi
mov    $0x14,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x50(%rsp),%rbx
lea    0xe8d(%rip),%r14
mov    0x2e52(%rip),%r12
xor    %r13d,%r13d
nopl   0x0(%rax)
lea    0x1(%r13),%r15
mov    %r14,%rdi
mov    %r15d,%esi
mov    $0xa,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x14,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,(%rsp,%r13,8)
add    $0x15,%rbx
mov    %r15,%r13
cmp    $0xa,%r15
jne    11a0 <main+0x40>
mov    0x2dea(%rip),%rbx
mov    (%rbx),%esi
lea    0xe39(%rip),%rdi
call   1060 <fputs@plt>
lea    0x50(%rsp),%rdi
call   1030 <puts@plt>
lea    0x65(%rsp),%rdi
call   1030 <puts@plt>
lea    0x7a(%rsp),%rdi
call   1030 <puts@plt>
lea    0x8f(%rsp),%rdi
call   1030 <puts@plt>
lea    0xa4(%rsp),%rdi
call   1030 <puts@plt>
lea    0xb9(%rsp),%rdi
call   1030 <puts@plt>
lea    0xce(%rsp),%rdi
call   1030 <puts@plt>
lea    0xe3(%rsp),%rdi
call   1030 <puts@plt>
lea    0xf8(%rsp),%rdi
call   1030 <puts@plt>
lea    0x10d(%rsp),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
mov    $0xa,%esi
call   1080 <sortp@plt>
mov    (%rbx),%esi
lea    0xdb9(%rip),%rdi
call   1060 <fputs@plt>
mov    (%rsp),%rdi
call   1030 <puts@plt>
mov    0x8(%rsp),%rdi
call   1030 <puts@plt>
mov    0x10(%rsp),%rdi
call   1030 <puts@plt>
mov    0x18(%rsp),%rdi
call   1030 <puts@plt>
mov    0x20(%rsp),%rdi
call   1030 <puts@plt>
mov    0x28(%rsp),%rdi
call   1030 <puts@plt>
mov    0x30(%rsp),%rdi
call   1030 <puts@plt>
mov    0x38(%rsp),%rdi
call   1030 <puts@plt>
mov    0x40(%rsp),%rdi
call   1030 <puts@plt>
mov    0x48(%rsp),%rdi
call   1030 <puts@plt>
mov    0x2cd6(%rip),%rax
mov    (%rax),%eax
add    $0x130,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Enter string (max %d size)\0A\00"
@.str.1 = [20 x i8] c"string %2d of %2d: \00"
@stdin = global i32 0
@.str.2 = [20 x i8] c"\0AUnsorted strings:\0A\00"
@stdout = global i32 0
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [18 x i8] c"\0ASorted strings:\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x [21 x i8]]
%3 = alloca [10 x i8*]
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i64 0, i64* %4
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 20)
store i32 0, i32* %5
br label %9
9: ; preds = %37, %0
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 10
br i1 %11, label %12, label %40
12: ; preds = %9
%13 = load i32, i32* %5
%14 = add nsw i32 %13, 1
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 10)
%16 = load i64, i64* %4
%17 = getelementptr inbounds [10 x [21 x i8]], [10 x [21 x i8]]* %2, i64 0, i64 %16
%18 = getelementptr inbounds [21 x i8], [21 x i8]* %17, i64 0, i64 0
%19 = load i32, i32* @stdin
%20 = call i32 @fgets(i8* %18, i32 20, i32 %19)
%21 = load i64, i64* %4
%22 = getelementptr inbounds [10 x [21 x i8]], [10 x [21 x i8]]* %2, i64 0, i64 %21
%23 = load i64, i64* %4
%24 = getelementptr inbounds [10 x [21 x i8]], [10 x [21 x i8]]* %2, i64 0, i64 %23
%25 = getelementptr inbounds [21 x i8], [21 x i8]* %24, i64 0, i64 0
%26 = call i32 @strlen(i8* %25)
%27 = sub nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [21 x i8], [21 x i8]* %22, i64 0, i64 %28
store i8 0, i8* %29
%30 = load i64, i64* %4
%31 = getelementptr inbounds [10 x [21 x i8]], [10 x [21 x i8]]* %2, i64 0, i64 %30
%32 = getelementptr inbounds [21 x i8], [21 x i8]* %31, i64 0, i64 0
%33 = load i64, i64* %4
%34 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 %33
store i8* %32, i8** %34
%35 = load i64, i64* %4
%36 = add i64 %35, 1
store i64 %36, i64* %4
br label %37
37: ; preds = %12
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %9
40: ; preds = %9
%41 = load i32, i32* @stdout
%42 = call i32 @fputs(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %41)
store i32 0, i32* %6
br label %43
43: ; preds = %54, %40
%44 = load i32, i32* %6
%45 = sext i32 %44 to i64
%46 = load i64, i64* %4
%47 = icmp ult i64 %45, %46
br i1 %47, label %48, label %57
48: ; preds = %43
%49 = load i32, i32* %6
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [10 x [21 x i8]], [10 x [21 x i8]]* %2, i64 0, i64 %50
%52 = getelementptr inbounds [21 x i8], [21 x i8]* %51, i64 0, i64 0
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %52)
br label %54
54: ; preds = %48
%55 = load i32, i32* %6
%56 = add nsw i32 %55, 1
store i32 %56, i32* %6
br label %43
57: ; preds = %43
%58 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 0
%59 = load i64, i64* %4
%60 = call i32 @sortp(i8** %58, i64 %59)
%61 = load i32, i32* @stdout
%62 = call i32 @fputs(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %61)
store i32 0, i32* %7
br label %63
63: ; preds = %74, %57
%64 = load i32, i32* %7
%65 = sext i32 %64 to i64
%66 = load i64, i64* %4
%67 = icmp ult i64 %65, %66
br i1 %67, label %68, label %77
68: ; preds = %63
%69 = load i32, i32* %7
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 %70
%72 = load i8*, i8** %71
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %72)
br label %74
74: ; preds = %68
%75 = load i32, i32* %7
%76 = add nsw i32 %75, 1
store i32 %76, i32* %7
br label %63
77: ; preds = %63
%78 = load i32, i32* @EXIT_SUCCESS
ret i32 %78
}

LLVM IR (-O2):
@.str = [28 x i8] c"Enter string (max %d size)\0A\00"
@.str.1 = [20 x i8] c"string %2d of %2d: \00"
@stdin = global i32 0
@.str.2 = [20 x i8] c"\0AUnsorted strings:\0A\00"
@stdout = global i32 0
@.str.4 = [18 x i8] c"\0ASorted strings:\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [10 x [21 x i8]]
%2 = alloca [10 x i8*]
%3 = getelementptr inbounds [10 x [21 x i8]], [10 x [21 x i8]]* %1, i64 0, i64 0, i64 0
%4 = bitcast [10 x i8*]* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 20)
br label %6
6: ; preds = %0, %6
%7 = phi i64 [ 0, %0 ], [ %8, %6 ]
%8 = add nuw nsw i64 %7, 1
%9 = trunc i64 %8 to i32
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 10)
%11 = getelementptr inbounds [10 x [21 x i8]], [10 x [21 x i8]]* %1, i64 0, i64 %7, i64 0
%12 = load i32, i32* @stdin
%13 = call i32 @fgets(i8* %11, i32 20, i32 %12)
%14 = call i32 @strlen(i8* %11)
%15 = add nsw i32 %14, -1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [10 x [21 x i8]], [10 x [21 x i8]]* %1, i64 0, i64 %7, i64 %16
store i8 0, i8* %17
%18 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 %7
store i8* %11, i8** %18
%19 = icmp eq i64 %8, 10
br i1 %19, label %20, label %6
20: ; preds = %6
%21 = load i32, i32* @stdout
%22 = call i32 @fputs(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = call i32 @puts(i8* %3)
%24 = getelementptr inbounds [10 x [21 x i8]], [10 x [21 x i8]]* %1, i64 0, i64 1, i64 0
%25 = call i32 @puts(i8* %24)
%26 = getelementptr inbounds [10 x [21 x i8]], [10 x [21 x i8]]* %1, i64 0, i64 2, i64 0
%27 = call i32 @puts(i8* %26)
%28 = getelementptr inbounds [10 x [21 x i8]], [10 x [21 x i8]]* %1, i64 0, i64 3, i64 0
%29 = call i32 @puts(i8* %28)
%30 = getelementptr inbounds [10 x [21 x i8]], [10 x [21 x i8]]* %1, i64 0, i64 4, i64 0
%31 = call i32 @puts(i8* %30)
%32 = getelementptr inbounds [10 x [21 x i8]], [10 x [21 x i8]]* %1, i64 0, i64 5, i64 0
%33 = call i32 @puts(i8* %32)
%34 = getelementptr inbounds [10 x [21 x i8]], [10 x [21 x i8]]* %1, i64 0, i64 6, i64 0
%35 = call i32 @puts(i8* %34)
%36 = getelementptr inbounds [10 x [21 x i8]], [10 x [21 x i8]]* %1, i64 0, i64 7, i64 0
%37 = call i32 @puts(i8* %36)
%38 = getelementptr inbounds [10 x [21 x i8]], [10 x [21 x i8]]* %1, i64 0, i64 8, i64 0
%39 = call i32 @puts(i8* %38)
%40 = getelementptr inbounds [10 x [21 x i8]], [10 x [21 x i8]]* %1, i64 0, i64 9, i64 0
%41 = call i32 @puts(i8* %40)
%42 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 0
%43 = call i32 @sortp(i8** %42, i64 10)
%44 = load i32, i32* @stdout
%45 = call i32 @fputs(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %44)
%46 = load i8*, i8** %42
%47 = call i32 @puts(i8* dereferenceable(1) %46)
%48 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 1
%49 = load i8*, i8** %48
%50 = call i32 @puts(i8* dereferenceable(1) %49)
%51 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 2
%52 = load i8*, i8** %51
%53 = call i32 @puts(i8* dereferenceable(1) %52)
%54 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 3
%55 = load i8*, i8** %54
%56 = call i32 @puts(i8* dereferenceable(1) %55)
%57 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 4
%58 = load i8*, i8** %57
%59 = call i32 @puts(i8* dereferenceable(1) %58)
%60 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 5
%61 = load i8*, i8** %60
%62 = call i32 @puts(i8* dereferenceable(1) %61)
%63 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 6
%64 = load i8*, i8** %63
%65 = call i32 @puts(i8* dereferenceable(1) %64)
%66 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 7
%67 = load i8*, i8** %66
%68 = call i32 @puts(i8* dereferenceable(1) %67)
%69 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 8
%70 = load i8*, i8** %69
%71 = call i32 @puts(i8* dereferenceable(1) %70)
%72 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 9
%73 = load i8*, i8** %72
%74 = call i32 @puts(i8* dereferenceable(1) %73)
%75 = load i32, i32* @EXIT_SUCCESS
ret i32 %75
}