#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 */
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void sort_array(char a[][30], int n) {
  int i = 0;
  int j = 0;
  char tmp[30];
  for (i = 0; i < n - 1; i++) {
    for (j = i + 1; j < n; j++) {
      if (strcmp(a[i], a[j]) > 0) {
        strcpy(tmp, a[i]);
        strcpy(a[i], a[j]);
        strcpy(a[j], tmp);
      }
    }
  }
}


x86 assembly (clang, -O0):
<sort_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1210 <sort_array+0xf0>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11fd <sort_array+0xdd>
mov    -0x8(%rbp),%rdi
movslq -0x10(%rbp),%rax
imul   $0x1e,%rax,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
movslq -0x14(%rbp),%rax
imul   $0x1e,%rax,%rax
add    %rax,%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jle    11ea <sort_array+0xca>
lea    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x10(%rbp),%rax
imul   $0x1e,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
movslq -0x10(%rbp),%rax
imul   $0x1e,%rax,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
movslq -0x14(%rbp),%rax
imul   $0x1e,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
imul   $0x1e,%rax,%rax
add    %rax,%rdi
lea    -0x40(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11ef <sort_array+0xcf>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115e <sort_array+0x3e>
jmp    1202 <sort_array+0xe2>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1144 <sort_array+0x24>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sort_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rdi,(%rsp)
cmp    $0x2,%esi
jl     11f0 <sort_array+0xd0>
mov    %rsi,%rax
mov    %eax,%ecx
mov    %rcx,0x8(%rsp)
add    $0xffffffff,%eax
mov    %rax,0x10(%rsp)
mov    (%rsp),%rax
lea    0x1e(%rax),%r14
mov    $0x1,%r15d
xor    %eax,%eax
lea    0x20(%rsp),%r12
jmp    1184 <sort_array+0x64>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r15
add    $0x1e,%r14
mov    0x18(%rsp),%rax
cmp    0x10(%rsp),%rax
je     11f0 <sort_array+0xd0>
lea    0x1(%rax),%rcx
mov    %rcx,0x18(%rsp)
cmp    0x8(%rsp),%rcx
jae    1170 <sort_array+0x50>
mov    %rax,%r13
shl    $0x5,%r13
sub    %rax,%r13
sub    %rax,%r13
add    (%rsp),%r13
mov    0x8(%rsp),%rbp
mov    %r14,%rbx
jmp    11bd <sort_array+0x9d>
nop
add    $0x1e,%rbx
add    $0xffffffffffffffff,%rbp
cmp    %rbp,%r15
je     1170 <sort_array+0x50>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jle    11b0 <sort_array+0x90>
mov    %r12,%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
jmp    11b0 <sort_array+0x90>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @sort_array([30 x i8]* %0, i32 %1) {
%3 = alloca [30 x i8]*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [30 x i8]
store [30 x i8]* %0, [30 x i8]** %3
store i32 %1, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %5
br label %8
8: ; preds = %64, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = sub nsw i32 %10, 1
%12 = icmp slt i32 %9, %11
br i1 %12, label %13, label %67
13: ; preds = %8
%14 = load i32, i32* %5
%15 = add nsw i32 %14, 1
store i32 %15, i32* %6
br label %16
16: ; preds = %60, %13
%17 = load i32, i32* %6
%18 = load i32, i32* %4
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %63
20: ; preds = %16
%21 = load [30 x i8]*, [30 x i8]** %3
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [30 x i8], [30 x i8]* %21, i64 %23
%25 = getelementptr inbounds [30 x i8], [30 x i8]* %24, i64 0, i64 0
%26 = load [30 x i8]*, [30 x i8]** %3
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [30 x i8], [30 x i8]* %26, i64 %28
%30 = getelementptr inbounds [30 x i8], [30 x i8]* %29, i64 0, i64 0
%31 = call i64 @strcmp(i8* %25, i8* %30)
%32 = icmp sgt i64 %31, 0
br i1 %32, label %33, label %59
33: ; preds = %20
%34 = getelementptr inbounds [30 x i8], [30 x i8]* %7, i64 0, i64 0
%35 = load [30 x i8]*, [30 x i8]** %3
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [30 x i8], [30 x i8]* %35, i64 %37
%39 = getelementptr inbounds [30 x i8], [30 x i8]* %38, i64 0, i64 0
%40 = call i32 @strcpy(i8* %34, i8* %39)
%41 = load [30 x i8]*, [30 x i8]** %3
%42 = load i32, i32* %5
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [30 x i8], [30 x i8]* %41, i64 %43
%45 = getelementptr inbounds [30 x i8], [30 x i8]* %44, i64 0, i64 0
%46 = load [30 x i8]*, [30 x i8]** %3
%47 = load i32, i32* %6
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [30 x i8], [30 x i8]* %46, i64 %48
%50 = getelementptr inbounds [30 x i8], [30 x i8]* %49, i64 0, i64 0
%51 = call i32 @strcpy(i8* %45, i8* %50)
%52 = load [30 x i8]*, [30 x i8]** %3
%53 = load i32, i32* %6
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [30 x i8], [30 x i8]* %52, i64 %54
%56 = getelementptr inbounds [30 x i8], [30 x i8]* %55, i64 0, i64 0
%57 = getelementptr inbounds [30 x i8], [30 x i8]* %7, i64 0, i64 0
%58 = call i32 @strcpy(i8* %56, i8* %57)
br label %59
59: ; preds = %33, %20
br label %60
60: ; preds = %59
%61 = load i32, i32* %6
%62 = add nsw i32 %61, 1
store i32 %62, i32* %6
br label %16
63: ; preds = %16
br label %64
64: ; preds = %63
%65 = load i32, i32* %5
%66 = add nsw i32 %65, 1
store i32 %66, i32* %5
br label %8
67: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @sort_array([30 x i8]* %0, i32 %1) {
%3 = alloca [30 x i8]
%4 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %1, 1
br i1 %5, label %6, label %33
6: ; preds = %2
%7 = add nsw i32 %1, -1
%8 = zext i32 %1 to i64
%9 = zext i32 %7 to i64
%10 = zext i32 %1 to i64
br label %14
11: ; preds = %30, %14
%12 = add nuw nsw i64 %16, 1
%13 = icmp eq i64 %17, %9
br i1 %13, label %33, label %14
14: ; preds = %6, %11
%15 = phi i64 [ 0, %6 ], [ %17, %11 ]
%16 = phi i64 [ 1, %6 ], [ %12, %11 ]
%17 = add nuw nsw i64 %15, 1
%18 = icmp ult i64 %17, %8
br i1 %18, label %19, label %11
19: ; preds = %14
%20 = getelementptr inbounds [30 x i8], [30 x i8]* %0, i64 %15, i64 0
br label %21
21: ; preds = %19, %30
%22 = phi i64 [ %16, %19 ], [ %31, %30 ]
%23 = getelementptr inbounds [30 x i8], [30 x i8]* %0, i64 %22, i64 0
%24 = call i64 @strcmp(i8* %20, i8* %23)
%25 = icmp sgt i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %21
%27 = call i32 @strcpy(i8* %4, i8* %20)
%28 = call i32 @strcpy(i8* %20, i8* %23)
%29 = call i32 @strcpy(i8* %23, i8* %4)
br label %30
30: ; preds = %21, %26
%31 = add nuw nsw i64 %22, 1
%32 = icmp eq i64 %31, %10
br i1 %32, label %11, label %21
33: ; preds = %11, %2
ret void
}