#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*/ swap(char *, char *);
void bubbleSort(char A[][30], int num) {
  int i, j;
  int temp;
  for (i = 0; i < num - 1; i++) {
    for (j = 0; j < num - i - 1; j++) {
      if (strcmp(A[j], A[j + 1]) > 0) {
        swap(A[j], A[j + 1]);
      }
    }
  }
}


x86 assembly (clang, -O0):
<bubbleSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11e0 <bubbleSort+0xc0>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11cd <bubbleSort+0xad>
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
imul   $0x1e,%rax,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cltq
imul   $0x1e,%rax,%rax
add    %rax,%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jle    11ba <bubbleSort+0x9a>
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
imul   $0x1e,%rax,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cltq
imul   $0x1e,%rax,%rax
add    %rax,%rsi
call   1040 <swap@plt>
jmp    11bf <bubbleSort+0x9f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114e <bubbleSort+0x2e>
jmp    11d2 <bubbleSort+0xb2>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1136 <bubbleSort+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bubbleSort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,0x10(%rsp)
cmp    $0x2,%esi
jl     11aa <bubbleSort+0x8a>
mov    %esi,%r15d
lea    -0x1(%r15),%eax
xor    %ebp,%ebp
mov    %eax,0xc(%rsp)
mov    %eax,%r13d
jmp    115d <bubbleSort+0x3d>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
add    $0xffffffff,%r13d
cmp    0xc(%rsp),%ebp
je     11aa <bubbleSort+0x8a>
mov    %r13d,%r13d
mov    %ebp,%eax
not    %eax
add    %r15d,%eax
test   %eax,%eax
jle    1150 <bubbleSort+0x30>
mov    %r13,%r14
mov    0x10(%rsp),%rbx
jmp    1189 <bubbleSort+0x69>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rbx
add    $0xffffffffffffffff,%r14
je     1150 <bubbleSort+0x30>
lea    0x1e(%rbx),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jle    1180 <bubbleSort+0x60>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <swap@plt>
jmp    1180 <bubbleSort+0x60>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @bubbleSort([30 x i8]* %0, i32 %1) {
%3 = alloca [30 x i8]*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store [30 x i8]* %0, [30 x i8]** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %8
8: ; preds = %53, %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 %56
13: ; preds = %8
store i32 0, i32* %6
br label %14
14: ; preds = %49, %13
%15 = load i32, i32* %6
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = sub nsw i32 %16, %17
%19 = sub nsw i32 %18, 1
%20 = icmp slt i32 %15, %19
br i1 %20, label %21, label %52
21: ; preds = %14
%22 = load [30 x i8]*, [30 x i8]** %3
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [30 x i8], [30 x i8]* %22, i64 %24
%26 = getelementptr inbounds [30 x i8], [30 x i8]* %25, i64 0, i64 0
%27 = load [30 x i8]*, [30 x i8]** %3
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [30 x i8], [30 x i8]* %27, i64 %30
%32 = getelementptr inbounds [30 x i8], [30 x i8]* %31, i64 0, i64 0
%33 = call i64 @strcmp(i8* %26, i8* %32)
%34 = icmp sgt i64 %33, 0
br i1 %34, label %35, label %48
35: ; preds = %21
%36 = load [30 x i8]*, [30 x i8]** %3
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [30 x i8], [30 x i8]* %36, i64 %38
%40 = getelementptr inbounds [30 x i8], [30 x i8]* %39, i64 0, i64 0
%41 = load [30 x i8]*, [30 x i8]** %3
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [30 x i8], [30 x i8]* %41, i64 %44
%46 = getelementptr inbounds [30 x i8], [30 x i8]* %45, i64 0, i64 0
%47 = call i32 @swap(i8* %40, i8* %46)
br label %48
48: ; preds = %35, %21
br label %49
49: ; preds = %48
%50 = load i32, i32* %6
%51 = add nsw i32 %50, 1
store i32 %51, i32* %6
br label %14
52: ; preds = %14
br label %53
53: ; preds = %52
%54 = load i32, i32* %5
%55 = add nsw i32 %54, 1
store i32 %55, i32* %5
br label %8
56: ; preds = %8
ret void
}

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