#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*/ gets(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main() {
  int i, j;
  char str[10][50], temp[50];
  printf("Enter 10 words:\n");
  for (i = 0; i < 10; ++i)
    gets(str[i]);
  for (i = 0; i < 9; ++i)
    for (j = i + 1; j < 10; ++j) {
      if (strcmp(str[i], str[j]) > 0) {
        strcpy(temp, str[i]);
        strcpy(str[i], str[j]);
        strcpy(str[j], temp);
      }
    }
  printf("In lexicographical order: \n");
  for (i = 0; i < 10; ++i) {
    puts(str[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11a4 <main+0x54>
movslq -0x8(%rbp),%rax
lea    -0x200(%rbp),%rdi
imul   $0x32,%rax,%rax
add    %rax,%rdi
call   1070 <gets@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1175 <main+0x25>
movl   $0x0,-0x8(%rbp)
cmpl   $0x9,-0x8(%rbp)
jge    1286 <main+0x136>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    1273 <main+0x123>
movslq -0x8(%rbp),%rax
lea    -0x200(%rbp),%rdi
imul   $0x32,%rax,%rax
add    %rax,%rdi
movslq -0xc(%rbp),%rax
lea    -0x200(%rbp),%rsi
imul   $0x32,%rax,%rax
add    %rax,%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jle    1260 <main+0x110>
lea    -0x240(%rbp),%rdi
movslq -0x8(%rbp),%rax
lea    -0x200(%rbp),%rsi
imul   $0x32,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
movslq -0x8(%rbp),%rax
lea    -0x200(%rbp),%rdi
imul   $0x32,%rax,%rax
add    %rax,%rdi
movslq -0xc(%rbp),%rax
lea    -0x200(%rbp),%rsi
imul   $0x32,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
movslq -0xc(%rbp),%rax
lea    -0x200(%rbp),%rdi
imul   $0x32,%rax,%rax
add    %rax,%rdi
lea    -0x240(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    1265 <main+0x115>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11be <main+0x6e>
jmp    1278 <main+0x128>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11ab <main+0x5b>
lea    0xd84(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    12c8 <main+0x178>
movslq -0x8(%rbp),%rax
lea    -0x200(%rbp),%rdi
imul   $0x32,%rax,%rax
add    %rax,%rdi
call   1040 <puts@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1299 <main+0x149>
xor    %eax,%eax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x238,%rsp
lea    0xea8(%rip),%rdi
call   1040 <puts@plt>
mov    %rsp,%rdi
call   1060 <gets@plt>
lea    0x32(%rsp),%rdi
call   1060 <gets@plt>
lea    0x64(%rsp),%rdi
call   1060 <gets@plt>
lea    0x96(%rsp),%rdi
call   1060 <gets@plt>
lea    0xc8(%rsp),%rdi
call   1060 <gets@plt>
lea    0xfa(%rsp),%rdi
call   1060 <gets@plt>
lea    0x12c(%rsp),%rdi
call   1060 <gets@plt>
lea    0x15e(%rsp),%rdi
call   1060 <gets@plt>
lea    0x190(%rsp),%rdi
call   1060 <gets@plt>
lea    0x1c2(%rsp),%rdi
call   1060 <gets@plt>
mov    $0x32,%r12d
xor    %r15d,%r15d
lea    0x200(%rsp),%r13
jmp    11fa <main+0xba>
nopw   0x0(%rax,%rax,1)
add    $0x32,%r12
cmp    $0x9,%r15
je     1254 <main+0x114>
imul   $0x32,%r15,%rax
add    $0x1,%r15
lea    (%rsp,%rax,1),%rbx
mov    %r12,%r14
jmp    121d <main+0xdd>
nopl   0x0(%rax,%rax,1)
add    $0x32,%r14
cmp    $0x1f4,%r14
je     11f0 <main+0xb0>
lea    (%rsp,%r14,1),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jle    1210 <main+0xd0>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
jmp    1210 <main+0xd0>
lea    0xdb5(%rip),%rdi
call   1040 <puts@plt>
mov    %rsp,%rdi
call   1040 <puts@plt>
lea    0x32(%rsp),%rdi
call   1040 <puts@plt>
lea    0x64(%rsp),%rdi
call   1040 <puts@plt>
lea    0x96(%rsp),%rdi
call   1040 <puts@plt>
lea    0xc8(%rsp),%rdi
call   1040 <puts@plt>
lea    0xfa(%rsp),%rdi
call   1040 <puts@plt>
lea    0x12c(%rsp),%rdi
call   1040 <puts@plt>
lea    0x15e(%rsp),%rdi
call   1040 <puts@plt>
lea    0x190(%rsp),%rdi
call   1040 <puts@plt>
lea    0x1c2(%rsp),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x238,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@str = [16 x i8] c"Enter 10 words:\00"
@str.2 = [27 x i8] c"In lexicographical order: \00"
define i32 @main() {
%1 = alloca [10 x [50 x i8]]
%2 = alloca [50 x i8]
%3 = getelementptr inbounds [10 x [50 x i8]], [10 x [50 x i8]]* %1, i64 0, i64 0, i64 0
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%6 = call i32 @gets(i8* %3)
%7 = getelementptr inbounds [10 x [50 x i8]], [10 x [50 x i8]]* %1, i64 0, i64 1, i64 0
%8 = call i32 @gets(i8* %7)
%9 = getelementptr inbounds [10 x [50 x i8]], [10 x [50 x i8]]* %1, i64 0, i64 2, i64 0
%10 = call i32 @gets(i8* %9)
%11 = getelementptr inbounds [10 x [50 x i8]], [10 x [50 x i8]]* %1, i64 0, i64 3, i64 0
%12 = call i32 @gets(i8* %11)
%13 = getelementptr inbounds [10 x [50 x i8]], [10 x [50 x i8]]* %1, i64 0, i64 4, i64 0
%14 = call i32 @gets(i8* %13)
%15 = getelementptr inbounds [10 x [50 x i8]], [10 x [50 x i8]]* %1, i64 0, i64 5, i64 0
%16 = call i32 @gets(i8* %15)
%17 = getelementptr inbounds [10 x [50 x i8]], [10 x [50 x i8]]* %1, i64 0, i64 6, i64 0
%18 = call i32 @gets(i8* %17)
%19 = getelementptr inbounds [10 x [50 x i8]], [10 x [50 x i8]]* %1, i64 0, i64 7, i64 0
%20 = call i32 @gets(i8* %19)
%21 = getelementptr inbounds [10 x [50 x i8]], [10 x [50 x i8]]* %1, i64 0, i64 8, i64 0
%22 = call i32 @gets(i8* %21)
%23 = getelementptr inbounds [10 x [50 x i8]], [10 x [50 x i8]]* %1, i64 0, i64 9, i64 0
%24 = call i32 @gets(i8* %23)
br label %28
25: ; preds = %42
%26 = add nuw nsw i64 %30, 1
%27 = icmp eq i64 %31, 9
br i1 %27, label %45, label %28
28: ; preds = %25, %0
%29 = phi i64 [ 0, %0 ], [ %31, %25 ]
%30 = phi i64 [ 1, %0 ], [ %26, %25 ]
%31 = add nuw nsw i64 %29, 1
%32 = getelementptr inbounds [10 x [50 x i8]], [10 x [50 x i8]]* %1, i64 0, i64 %29, i64 0
br label %33
33: ; preds = %28, %42
%34 = phi i64 [ %30, %28 ], [ %43, %42 ]
%35 = getelementptr inbounds [10 x [50 x i8]], [10 x [50 x i8]]* %1, i64 0, i64 %34, i64 0
%36 = call i64 @strcmp(i8* %32, i8* %35)
%37 = icmp sgt i64 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %33
%39 = call i32 @strcpy(i8* %4, i8* %32)
%40 = call i32 @strcpy(i8* %32, i8* %35)
%41 = call i32 @strcpy(i8* %35, i8* %4)
br label %42
42: ; preds = %33, %38
%43 = add nuw nsw i64 %34, 1
%44 = icmp eq i64 %43, 10
br i1 %44, label %25, label %33
45: ; preds = %25
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.2, i64 0, i64 0))
%47 = call i32 @puts(i8* %3)
%48 = call i32 @puts(i8* %7)
%49 = call i32 @puts(i8* %9)
%50 = call i32 @puts(i8* %11)
%51 = call i32 @puts(i8* %13)
%52 = call i32 @puts(i8* %15)
%53 = call i32 @puts(i8* %17)
%54 = call i32 @puts(i8* %19)
%55 = call i32 @puts(i8* %21)
%56 = call i32 @puts(i8* %23)
ret i32 0
}