#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*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void main() {
  char s[5][20], t[20];
  int i, j;
  printf("\nEnter any five strings: ");
  for (i = 0; i < 5; i++) {
    scanf("%s", s[i]);
  }
  for (i = 1; i < 5; i++) {
    for (j = 1; j < 5; j++) {
      if (strcmp(s[j - 1], s[j]) > 0) {
        strcpy(t, s[j - 1]);
        strcpy(s[j - 1], s[j]);
        strcpy(s[j], t);
      }
    }
  }
  printf("\nStrings in order are: ");
  for (i = 0; i < 5; i++) {
    printf("\n%s", s[i]);
  }
  getchar();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x94(%rbp)
cmpl   $0x5,-0x94(%rbp)
jge    11b2 <main+0x62>
movslq -0x94(%rbp),%rax
lea    -0x70(%rbp),%rsi
imul   $0x14,%rax,%rax
add    %rax,%rsi
lea    0xe9a(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    1173 <main+0x23>
movl   $0x1,-0x94(%rbp)
cmpl   $0x5,-0x94(%rbp)
jge    12b6 <main+0x166>
movl   $0x1,-0x98(%rbp)
cmpl   $0x5,-0x98(%rbp)
jge    129d <main+0x14d>
mov    -0x98(%rbp),%eax
sub    $0x1,%eax
cltq
lea    -0x70(%rbp),%rdi
imul   $0x14,%rax,%rax
add    %rax,%rdi
movslq -0x98(%rbp),%rax
lea    -0x70(%rbp),%rsi
imul   $0x14,%rax,%rax
add    %rax,%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jle    1284 <main+0x134>
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%eax
sub    $0x1,%eax
cltq
lea    -0x70(%rbp),%rsi
imul   $0x14,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x98(%rbp),%eax
sub    $0x1,%eax
cltq
lea    -0x70(%rbp),%rdi
imul   $0x14,%rax,%rax
add    %rax,%rdi
movslq -0x98(%rbp),%rax
lea    -0x70(%rbp),%rsi
imul   $0x14,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
movslq -0x98(%rbp),%rax
lea    -0x70(%rbp),%rdi
imul   $0x14,%rax,%rax
add    %rax,%rdi
lea    -0x90(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    1289 <main+0x139>
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    11d3 <main+0x83>
jmp    12a2 <main+0x152>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    11bc <main+0x6c>
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x94(%rbp)
cmpl   $0x5,-0x94(%rbp)
jge    130f <main+0x1bf>
movslq -0x94(%rbp),%rax
lea    -0x70(%rbp),%rsi
imul   $0x14,%rax,%rax
add    %rax,%rsi
lea    0xd3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    12ce <main+0x17e>
mov    $0x0,%al
call   1060 <getchar@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
lea    0xe98(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebd(%rip),%r14
lea    0x20(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
lea    0x34(%rsp),%rbp
mov    %r14,%rdi
mov    %rbp,%rsi
call   1070 <scanf@plt>
lea    0x48(%rsp),%r13
mov    %r14,%rdi
mov    %r13,%rsi
call   1070 <scanf@plt>
lea    0x5c(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <scanf@plt>
lea    0x70(%rsp),%rsi
mov    %r14,%rdi
call   1070 <scanf@plt>
mov    $0x4,%r12d
mov    %rsp,%r14
jmp    11da <main+0x8a>
xchg   %ax,%ax
add    $0xffffffff,%r12d
je     12bd <main+0x16d>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jle    120b <main+0xbb>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jle    123c <main+0xec>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
mov    %r13,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jle    126d <main+0x11d>
mov    %r14,%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %r15,%rdi
lea    0x70(%rsp),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jle    11d0 <main+0x80>
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %r15,%rdi
mov    %r15,%r14
mov    %r13,%r15
lea    0x70(%rsp),%r13
mov    %r13,%rsi
call   1030 <strcpy@plt>
mov    %r13,%rdi
mov    %r15,%r13
mov    %r14,%r15
mov    %rsp,%r14
mov    %r14,%rsi
call   1030 <strcpy@plt>
jmp    11d0 <main+0x80>
lea    0xd56(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd60(%rip),%rbx
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0x70(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [26 x i8] c"\0AEnter any five strings: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [24 x i8] c"\0AStrings in order are: \00"
@.str.3 = [4 x i8] c"\0A%s\00"
define void @main() {
%1 = alloca [5 x [20 x i8]]
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [5 x [20 x i8]], [5 x [20 x i8]]* %1, i64 0, i64 0, i64 0
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 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), i8* %3)
%7 = getelementptr inbounds [5 x [20 x i8]], [5 x [20 x i8]]* %1, i64 0, i64 1, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [5 x [20 x i8]], [5 x [20 x i8]]* %1, i64 0, i64 2, i64 0
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [5 x [20 x i8]], [5 x [20 x i8]]* %1, i64 0, i64 3, i64 0
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [5 x [20 x i8]], [5 x [20 x i8]]* %1, i64 0, i64 4, i64 0
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %0, %44
%16 = phi i32 [ %45, %44 ], [ 1, %0 ]
%17 = call i64 @strcmp(i8* %3, i8* %7)
%18 = icmp sgt i64 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = call i32 @strcpy(i8* %4, i8* %3)
%21 = call i32 @strcpy(i8* %3, i8* %7)
%22 = call i32 @strcpy(i8* %7, i8* %4)
br label %23
23: ; preds = %15, %19
%24 = call i64 @strcmp(i8* %7, i8* %9)
%25 = icmp sgt i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = call i32 @strcpy(i8* %4, i8* %7)
%28 = call i32 @strcpy(i8* %7, i8* %9)
%29 = call i32 @strcpy(i8* %9, i8* %4)
br label %30
30: ; preds = %26, %23
%31 = call i64 @strcmp(i8* %9, i8* %11)
%32 = icmp sgt i64 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = call i32 @strcpy(i8* %4, i8* %9)
%35 = call i32 @strcpy(i8* %9, i8* %11)
%36 = call i32 @strcpy(i8* %11, i8* %4)
br label %37
37: ; preds = %33, %30
%38 = call i64 @strcmp(i8* %11, i8* %13)
%39 = icmp sgt i64 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %37
%41 = call i32 @strcpy(i8* %4, i8* %11)
%42 = call i32 @strcpy(i8* %11, i8* %13)
%43 = call i32 @strcpy(i8* %13, i8* %4)
br label %44
44: ; preds = %40, %37
%45 = add nuw nsw i32 %16, 1
%46 = icmp eq i32 %45, 5
br i1 %46, label %47, label %15
47: ; preds = %44
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %11)
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%54 = call i32 (...) @getchar()
ret void
}