#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 /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ sort(char **);
int main() {
  int i;
  char **p1, *p2[5], str[5][20];
  for (i = 0; i < 5; i++)
    p2[i] = str[i];
  printf("input 5 strings:\n");
  for (i = 0; i < 5; i++)
    scanf("%s", p2[i]);
  p1 = p2;
  sort(p1);
  printf("strings sorted:\n");
  for (i = 0; i < 5; i++)
    printf("%s\n", p2[i]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    117c <main+0x4c>
movslq -0x8(%rbp),%rax
lea    -0xb0(%rbp),%rcx
imul   $0x14,%rax,%rax
add    %rax,%rcx
movslq -0x8(%rbp),%rax
mov    %rcx,-0x40(%rbp,%rax,8)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1149 <main+0x19>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    11be <main+0x8e>
movslq -0x8(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rsi
lea    0xe67(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1191 <main+0x61>
lea    -0x40(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <sort@plt>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    1213 <main+0xe3>
movslq -0x8(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rsi
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11e4 <main+0xb4>
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
lea    0x30(%rsp),%rbx
mov    %rbx,(%rsp)
lea    0x44(%rsp),%r14
mov    %r14,0x8(%rsp)
lea    0x58(%rsp),%r15
mov    %r15,0x10(%rsp)
lea    0x6c(%rsp),%r12
mov    %r12,0x18(%rsp)
lea    0x80(%rsp),%r13
mov    %r13,0x20(%rsp)
lea    0xe87(%rip),%rdi
call   1030 <puts@plt>
lea    0xe78(%rip),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1050 <scanf@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
mov    %rsp,%rdi
call   1040 <sort@plt>
lea    0xe46(%rip),%rdi
call   1030 <puts@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>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"input 5 strings:\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [17 x i8] c"strings sorted:\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8**
%4 = alloca [5 x i8*]
%5 = alloca [5 x [20 x i8]]
store i32 0, i32* %1
store i32 0, i32* %2
br label %6
6: ; preds = %17, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 5
br i1 %8, label %9, label %20
9: ; preds = %6
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [5 x [20 x i8]], [5 x [20 x i8]]* %5, i64 0, i64 %11
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 0
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 %15
store i8* %13, i8** %16
br label %17
17: ; preds = %9
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 1
store i32 %19, i32* %2
br label %6
20: ; preds = %6
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %22
22: ; preds = %31, %20
%23 = load i32, i32* %2
%24 = icmp slt i32 %23, 5
br i1 %24, label %25, label %34
25: ; preds = %22
%26 = load i32, i32* %2
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 %27
%29 = load i8*, i8** %28
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %25
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
store i32 %33, i32* %2
br label %22
34: ; preds = %22
%35 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 0
store i8** %35, i8*** %3
%36 = load i8**, i8*** %3
%37 = call i32 @sort(i8** %36)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
br label %39
39: ; preds = %48, %34
%40 = load i32, i32* %2
%41 = icmp slt i32 %40, 5
br i1 %41, label %42, label %51
42: ; preds = %39
%43 = load i32, i32* %2
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 %44
%46 = load i8*, i8** %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %46)
br label %48
48: ; preds = %42
%49 = load i32, i32* %2
%50 = add nsw i32 %49, 1
store i32 %50, i32* %2
br label %39
51: ; preds = %39
%52 = load i32, i32* %1
ret i32 %52
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@str = [17 x i8] c"input 5 strings:\00"
@str.4 = [16 x i8] c"strings sorted:\00"
define i32 @main() {
%1 = alloca [5 x i8*]
%2 = alloca [5 x [20 x i8]]
%3 = bitcast [5 x i8*]* %1 to i8*
%4 = getelementptr inbounds [5 x [20 x i8]], [5 x [20 x i8]]* %2, i64 0, i64 0, i64 0
%5 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 0
store i8* %4, i8** %5
%6 = getelementptr inbounds [5 x [20 x i8]], [5 x [20 x i8]]* %2, i64 0, i64 1, i64 0
%7 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 1
store i8* %6, i8** %7
%8 = getelementptr inbounds [5 x [20 x i8]], [5 x [20 x i8]]* %2, i64 0, i64 2, i64 0
%9 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 2
store i8* %8, i8** %9
%10 = getelementptr inbounds [5 x [20 x i8]], [5 x [20 x i8]]* %2, i64 0, i64 3, i64 0
%11 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 3
store i8* %10, i8** %11
%12 = getelementptr inbounds [5 x [20 x i8]], [5 x [20 x i8]]* %2, i64 0, i64 4, i64 0
%13 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 4
store i8* %12, i8** %13
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%20 = call i32 @sort(i8** %5)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.4, i64 0, i64 0))
%22 = load i8*, i8** %5
%23 = call i32 @puts(i8* dereferenceable(1) %22)
%24 = load i8*, i8** %7
%25 = call i32 @puts(i8* dereferenceable(1) %24)
%26 = load i8*, i8** %9
%27 = call i32 @puts(i8* dereferenceable(1) %26)
%28 = load i8*, i8** %11
%29 = call i32 @puts(i8* dereferenceable(1) %28)
%30 = load i8*, i8** %13
%31 = call i32 @puts(i8* dereferenceable(1) %30)
ret i32 0
}