#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*/ char_array_sort(char **, int);
char getchar();
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  char *p[20];
  int i, j, string_count;
  char ch;
  printf("input sting number:\n");
  scanf("%d", &string_count);
  for (i = 0; i < string_count; i++) {
    p[i] = (char *)malloc(sizeof(char));
    j = 0;
    while ((ch = getchar()) == '\n')
      ;
    p[i][j++] = ch;
    while ((p[i][j] = getchar()) != '\n')
      j++;
    p[i][j] = '\0';
  }
  p[i] = NULL;
  char_array_sort(p, string_count + 1);
  putchar('\n');
  for (i = 0; p[i] != NULL; i++)
    puts(p[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe77(%rip),%rdi
call   1050 <printf@plt>
lea    0xe80(%rip),%rdi
lea    -0xbc(%rbp),%rsi
call   1080 <scanf@plt>
movl   $0x0,-0xb4(%rbp)
mov    -0xb4(%rbp),%eax
cmp    -0xbc(%rbp),%eax
jge    129b <main+0x12b>
mov    $0x1,%edi
call   1070 <malloc@plt>
mov    %rax,%rcx
movslq -0xb4(%rbp),%rax
mov    %rcx,-0xb0(%rbp,%rax,8)
ff
movl   $0x0,-0xb8(%rbp)
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0xbd(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
jne    1201 <main+0x91>
jmp    11e3 <main+0x73>
mov    -0xbd(%rbp),%dl
movslq -0xb4(%rbp),%rax
mov    -0xb0(%rbp,%rax,8),%rax
ff
mov    -0xb8(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0xb8(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    $0x0,%al
call   1060 <getchar@plt>
movslq -0xb4(%rbp),%rcx
mov    -0xb0(%rbp,%rcx,8),%rcx
ff
movslq -0xb8(%rbp),%rdx
mov    %al,(%rcx,%rdx,1)
movsbl %al,%eax
cmp    $0xa,%eax
je     126d <main+0xfd>
mov    -0xb8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb8(%rbp)
jmp    122d <main+0xbd>
movslq -0xb4(%rbp),%rax
mov    -0xb0(%rbp,%rax,8),%rax
ff
movslq -0xb8(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    11ab <main+0x3b>
movslq -0xb4(%rbp),%rax
movq   $0x0,-0xb0(%rbp,%rax,8)
lea    -0xb0(%rbp),%rdi
mov    -0xbc(%rbp),%esi
add    $0x1,%esi
call   1090 <char_array_sort@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,-0xb4(%rbp)
movslq -0xb4(%rbp),%rax
cmpq   $0x0,-0xb0(%rbp,%rax,8)
je     1315 <main+0x1a5>
movslq -0xb4(%rbp),%rax
mov    -0xb0(%rbp,%rax,8),%rdi
ff
call   1040 <puts@plt>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    12d7 <main+0x167>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xb0,%rsp
lea    0xe90(%rip),%rdi
call   1040 <puts@plt>
lea    0xe81(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
jle    1206 <main+0xa6>
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    %rax,0x10(%rsp,%r15,8)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     11c0 <main+0x60>
mov    %al,(%r14)
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x10(%rsp,%r15,8),%rcx
mov    %al,0x1(%rcx,%rbx,1)
add    $0x1,%rbx
cmp    $0xa,%al
jne    11d0 <main+0x70>
mov    %ebx,%eax
mov    0x10(%rsp,%r15,8),%rcx
movb   $0x0,(%rcx,%rax,1)
add    $0x1,%r15
movslq 0xc(%rsp),%rsi
cmp    %rsi,%r15
jl     11a0 <main+0x40>
mov    %r15d,%eax
jmp    1208 <main+0xa8>
xor    %eax,%eax
movq   $0x0,0x10(%rsp,%rax,8)
add    $0x1,%esi
lea    0x10(%rsp),%rdi
call   1080 <char_array_sort@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x10(%rsp),%rdi
test   %rdi,%rdi
je     1251 <main+0xf1>
lea    0x18(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
call   1040 <puts@plt>
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    1240 <main+0xe0>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"input sting number:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8*]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
store i32 0, i32* %1
%7 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
store i32 0, i32* %3
br label %9
9: ; preds = %56, %0
%10 = load i32, i32* %3
%11 = load i32, i32* %5
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %59
13: ; preds = %9
%14 = call i64 @malloc(i32 1)
%15 = inttoptr i64 %14 to i8*
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [20 x i8*], [20 x i8*]* %2, i64 0, i64 %17
store i8* %15, i8** %18
store i32 0, i32* %4
br label %19
19: ; preds = %23, %13
%20 = call signext i8 (...) @getchar()
store i8 %20, i8* %6
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 10
br i1 %22, label %23, label %24
23: ; preds = %19
br label %19
24: ; preds = %19
%25 = load i8, i8* %6
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [20 x i8*], [20 x i8*]* %2, i64 0, i64 %27
%29 = load i8*, i8** %28
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
%32 = sext i32 %30 to i64
%33 = getelementptr inbounds i8, i8* %29, i64 %32
store i8 %25, i8* %33
br label %34
34: ; preds = %45, %24
%35 = call signext i8 (...) @getchar()
%36 = load i32, i32* %3
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [20 x i8*], [20 x i8*]* %2, i64 0, i64 %37
%39 = load i8*, i8** %38
%40 = load i32, i32* %4
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
store i8 %35, i8* %42
%43 = sext i8 %35 to i32
%44 = icmp ne i32 %43, 10
br i1 %44, label %45, label %48
45: ; preds = %34
%46 = load i32, i32* %4
%47 = add nsw i32 %46, 1
store i32 %47, i32* %4
br label %34
48: ; preds = %34
%49 = load i32, i32* %3
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [20 x i8*], [20 x i8*]* %2, i64 0, i64 %50
%52 = load i8*, i8** %51
%53 = load i32, i32* %4
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %52, i64 %54
store i8 0, i8* %55
br label %56
56: ; preds = %48
%57 = load i32, i32* %3
%58 = add nsw i32 %57, 1
store i32 %58, i32* %3
br label %9
59: ; preds = %9
%60 = load i32, i32* %3
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [20 x i8*], [20 x i8*]* %2, i64 0, i64 %61
store i8* null, i8** %62
%63 = getelementptr inbounds [20 x i8*], [20 x i8*]* %2, i64 0, i64 0
%64 = load i32, i32* %5
%65 = add nsw i32 %64, 1
%66 = call i32 @char_array_sort(i8** %63, i32 %65)
%67 = call i32 @putchar(i8 signext 10)
store i32 0, i32* %3
br label %68
68: ; preds = %80, %59
%69 = load i32, i32* %3
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [20 x i8*], [20 x i8*]* %2, i64 0, i64 %70
%72 = load i8*, i8** %71
%73 = icmp ne i8* %72, null
br i1 %73, label %74, label %83
74: ; preds = %68
%75 = load i32, i32* %3
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [20 x i8*], [20 x i8*]* %2, i64 0, i64 %76
%78 = load i8*, i8** %77
%79 = call i32 @puts(i8* %78)
br label %80
80: ; preds = %74
%81 = load i32, i32* %3
%82 = add nsw i32 %81, 1
store i32 %82, i32* %3
br label %68
83: ; preds = %68
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [20 x i8] c"input sting number:\00"
define i32 @main() {
%1 = alloca [20 x i8*]
%2 = alloca i32
%3 = bitcast [20 x i8*]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %35
9: ; preds = %0, %25
%10 = phi i64 [ %29, %25 ], [ 0, %0 ]
%11 = call i64 @malloc(i32 1)
%12 = inttoptr i64 %11 to i8*
%13 = getelementptr inbounds [20 x i8*], [20 x i8*]* %1, i64 0, i64 %10
store i8* %12, i8** %13
br label %14
14: ; preds = %14, %9
%15 = call signext i8 (...) @getchar()
%16 = icmp eq i8 %15, 10
br i1 %16, label %14, label %17
17: ; preds = %14
store i8 %15, i8* %12
br label %18
18: ; preds = %18, %17
%19 = phi i64 [ %24, %18 ], [ 1, %17 ]
%20 = call signext i8 (...) @getchar()
%21 = load i8*, i8** %13
%22 = getelementptr inbounds i8, i8* %21, i64 %19
store i8 %20, i8* %22
%23 = icmp eq i8 %20, 10
%24 = add nuw i64 %19, 1
br i1 %23, label %25, label %18
25: ; preds = %18
%26 = and i64 %19, 4294967295
%27 = load i8*, i8** %13
%28 = getelementptr inbounds i8, i8* %27, i64 %26
store i8 0, i8* %28
%29 = add nuw nsw i64 %10, 1
%30 = load i32, i32* %2
%31 = sext i32 %30 to i64
%32 = icmp slt i64 %29, %31
br i1 %32, label %9, label %33
33: ; preds = %25
%34 = and i64 %29, 4294967295
br label %35
35: ; preds = %33, %0
%36 = phi i64 [ 0, %0 ], [ %34, %33 ]
%37 = phi i32 [ %7, %0 ], [ %30, %33 ]
%38 = getelementptr inbounds [20 x i8*], [20 x i8*]* %1, i64 0, i64 %36
store i8* null, i8** %38
%39 = getelementptr inbounds [20 x i8*], [20 x i8*]* %1, i64 0, i64 0
%40 = add nsw i32 %37, 1
%41 = call i32 @char_array_sort(i8** %39, i32 %40)
%42 = call i32 @putchar(i8 signext 10)
%43 = load i8*, i8** %39
%44 = icmp eq i8* %43, null
br i1 %44, label %53, label %45
45: ; preds = %35, %45
%46 = phi i64 [ %49, %45 ], [ 0, %35 ]
%47 = phi i8* [ %51, %45 ], [ %43, %35 ]
%48 = call i32 @puts(i8* %47)
%49 = add nuw i64 %46, 1
%50 = getelementptr inbounds [20 x i8*], [20 x i8*]* %1, i64 0, i64 %49
%51 = load i8*, i8** %50
%52 = icmp eq i8* %51, null
br i1 %52, label %53, label %45
53: ; preds = %45, %35
ret i32 0
}