#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 strs[10][30], int num) {
  int i, j;
  char tmpbuf[32];
  for (i = 0; i < num; i++)
    for (j = i + 1; j < num; j++)
      if (strcmp(strs[i], strs[j]) > 0) {
        strcpy(tmpbuf, strs[i]);
        strcpy(strs[i], strs[j]);
        strcpy(strs[j], tmpbuf);
      }
}


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)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11fd <sort_array+0xdd>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ea <sort_array+0xca>
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    11d7 <sort_array+0xb7>
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    11dc <sort_array+0xbc>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114b <sort_array+0x2b>
jmp    11ef <sort_array+0xcf>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1136 <sort_array+0x16>
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,0x8(%rsp)
test   %esi,%esi
jle    11f0 <sort_array+0xd0>
mov    %esi,%ecx
mov    0x8(%rsp),%rax
lea    0x1e(%rax),%rbp
mov    $0x1,%r14d
xor    %eax,%eax
lea    0x20(%rsp),%r15
mov    %rcx,0x10(%rsp)
jmp    1177 <sort_array+0x57>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r14
add    $0x1e,%rbp
mov    0x10(%rsp),%rcx
mov    0x18(%rsp),%rax
cmp    %rcx,%rax
je     11f0 <sort_array+0xd0>
lea    0x1(%rax),%rdx
mov    %rdx,0x18(%rsp)
cmp    %rcx,%rdx
jae    1160 <sort_array+0x40>
mov    %rax,%r12
shl    $0x5,%r12
sub    %rax,%r12
sub    %rax,%r12
add    0x8(%rsp),%r12
mov    0x10(%rsp),%r13
mov    %rbp,%rbx
jmp    11bd <sort_array+0x9d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1e,%rbx
add    $0xffffffffffffffff,%r13
cmp    %r13,%r14
je     1160 <sort_array+0x40>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jle    11b0 <sort_array+0x90>
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%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 [32 x i8]
store [30 x i8]* %0, [30 x i8]** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %8
8: ; preds = %63, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %66
12: ; preds = %8
%13 = load i32, i32* %5
%14 = add nsw i32 %13, 1
store i32 %14, i32* %6
br label %15
15: ; preds = %59, %12
%16 = load i32, i32* %6
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %62
19: ; preds = %15
%20 = load [30 x i8]*, [30 x i8]** %3
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [30 x i8], [30 x i8]* %20, i64 %22
%24 = getelementptr inbounds [30 x i8], [30 x i8]* %23, i64 0, i64 0
%25 = load [30 x i8]*, [30 x i8]** %3
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [30 x i8], [30 x i8]* %25, i64 %27
%29 = getelementptr inbounds [30 x i8], [30 x i8]* %28, i64 0, i64 0
%30 = call i64 @strcmp(i8* %24, i8* %29)
%31 = icmp sgt i64 %30, 0
br i1 %31, label %32, label %58
32: ; preds = %19
%33 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%34 = load [30 x i8]*, [30 x i8]** %3
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [30 x i8], [30 x i8]* %34, i64 %36
%38 = getelementptr inbounds [30 x i8], [30 x i8]* %37, i64 0, i64 0
%39 = call i32 @strcpy(i8* %33, i8* %38)
%40 = load [30 x i8]*, [30 x i8]** %3
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [30 x i8], [30 x i8]* %40, i64 %42
%44 = getelementptr inbounds [30 x i8], [30 x i8]* %43, i64 0, i64 0
%45 = load [30 x i8]*, [30 x i8]** %3
%46 = load i32, i32* %6
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [30 x i8], [30 x i8]* %45, i64 %47
%49 = getelementptr inbounds [30 x i8], [30 x i8]* %48, i64 0, i64 0
%50 = call i32 @strcpy(i8* %44, i8* %49)
%51 = load [30 x i8]*, [30 x i8]** %3
%52 = load i32, i32* %6
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [30 x i8], [30 x i8]* %51, i64 %53
%55 = getelementptr inbounds [30 x i8], [30 x i8]* %54, i64 0, i64 0
%56 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%57 = call i32 @strcpy(i8* %55, i8* %56)
br label %58
58: ; preds = %32, %19
br label %59
59: ; preds = %58
%60 = load i32, i32* %6
%61 = add nsw i32 %60, 1
store i32 %61, i32* %6
br label %15
62: ; preds = %15
br label %63
63: ; preds = %62
%64 = load i32, i32* %5
%65 = add nsw i32 %64, 1
store i32 %65, i32* %5
br label %8
66: ; preds = %8
ret void
}

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