#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*/ isNull(char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ swap(char *, char *, int);
void bubbleSort(char str[][30], int len) {
  int i, j;
  for (i = 0; i < len - 1; i++) {
    for (j = 0; j < len - i - 1; j++) {
      if ((!isNull(str[j])) && (!isNull(str[j + 1])) &&
          (strcmp(str[j], str[j + 1]) > 0)) {
        swap(str[j], str[j + 1], 30);
      }
    }
  }
}


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    1233 <bubbleSort+0x103>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1220 <bubbleSort+0xf0>
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
imul   $0x1e,%rax,%rax
add    %rax,%rdi
call   1040 <isNull@plt>
cmp    $0x0,%eax
jne    120d <bubbleSort+0xdd>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cltq
imul   $0x1e,%rax,%rax
add    %rax,%rdi
call   1040 <isNull@plt>
cmp    $0x0,%eax
jne    120d <bubbleSort+0xdd>
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    120d <bubbleSort+0xdd>
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
mov    $0x1e,%edx
call   1050 <swap@plt>
jmp    1212 <bubbleSort+0xe2>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115e <bubbleSort+0x2e>
jmp    1225 <bubbleSort+0xf5>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1146 <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     11d8 <bubbleSort+0xa8>
mov    %esi,%r15d
lea    -0x1(%r15),%eax
xor    %ebp,%ebp
mov    %eax,0xc(%rsp)
mov    %eax,%r13d
jmp    116d <bubbleSort+0x3d>
xchg   %ax,%ax
add    $0x1,%ebp
add    $0xffffffff,%r13d
cmp    0xc(%rsp),%ebp
je     11d8 <bubbleSort+0xa8>
mov    %r13d,%r13d
mov    %ebp,%eax
not    %eax
add    %r15d,%eax
test   %eax,%eax
jle    1160 <bubbleSort+0x30>
mov    0x10(%rsp),%rbx
mov    %r13,%r14
jmp    119a <bubbleSort+0x6a>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1e,%rbx
add    $0xffffffffffffffff,%r14
je     1160 <bubbleSort+0x30>
mov    %rbx,%rdi
call   1040 <isNull@plt>
test   %eax,%eax
jne    1190 <bubbleSort+0x60>
lea    0x1e(%rbx),%r12
mov    %r12,%rdi
call   1040 <isNull@plt>
test   %eax,%eax
jne    1190 <bubbleSort+0x60>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jle    1190 <bubbleSort+0x60>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x1e,%edx
call   1050 <swap@plt>
jmp    1190 <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
store [30 x i8]* %0, [30 x i8]** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %7
7: ; preds = %69, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = sub nsw i32 %9, 1
%11 = icmp slt i32 %8, %10
br i1 %11, label %12, label %72
12: ; preds = %7
store i32 0, i32* %6
br label %13
13: ; preds = %65, %12
%14 = load i32, i32* %6
%15 = load i32, i32* %4
%16 = load i32, i32* %5
%17 = sub nsw i32 %15, %16
%18 = sub nsw i32 %17, 1
%19 = icmp slt i32 %14, %18
br i1 %19, label %20, label %68
20: ; preds = %13
%21 = load [30 x i8]*, [30 x i8]** %3
%22 = load i32, i32* %6
%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 = call i32 @isNull(i8* %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %64, label %28
28: ; preds = %20
%29 = load [30 x i8]*, [30 x i8]** %3
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [30 x i8], [30 x i8]* %29, i64 %32
%34 = getelementptr inbounds [30 x i8], [30 x i8]* %33, i64 0, i64 0
%35 = call i32 @isNull(i8* %34)
%36 = icmp ne i32 %35, 0
br i1 %36, label %64, label %37
37: ; preds = %28
%38 = load [30 x i8]*, [30 x i8]** %3
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [30 x i8], [30 x i8]* %38, i64 %40
%42 = getelementptr inbounds [30 x i8], [30 x i8]* %41, i64 0, i64 0
%43 = load [30 x i8]*, [30 x i8]** %3
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [30 x i8], [30 x i8]* %43, i64 %46
%48 = getelementptr inbounds [30 x i8], [30 x i8]* %47, i64 0, i64 0
%49 = call i64 @strcmp(i8* %42, i8* %48)
%50 = icmp sgt i64 %49, 0
br i1 %50, label %51, label %64
51: ; preds = %37
%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 = load [30 x i8]*, [30 x i8]** %3
%58 = load i32, i32* %6
%59 = add nsw i32 %58, 1
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [30 x i8], [30 x i8]* %57, i64 %60
%62 = getelementptr inbounds [30 x i8], [30 x i8]* %61, i64 0, i64 0
%63 = call i32 @swap(i8* %56, i8* %62, i32 30)
br label %64
64: ; preds = %51, %37, %28, %20
br label %65
65: ; preds = %64
%66 = load i32, i32* %6
%67 = add nsw i32 %66, 1
store i32 %67, i32* %6
br label %13
68: ; preds = %13
br label %69
69: ; preds = %68
%70 = load i32, i32* %5
%71 = add nsw i32 %70, 1
store i32 %71, i32* %5
br label %7
72: ; preds = %7
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 %34
5: ; preds = %2, %30
%6 = phi i32 [ %32, %30 ], [ %3, %2 ]
%7 = phi i32 [ %31, %30 ], [ 0, %2 ]
%8 = xor i32 %7, -1
%9 = add i32 %8, %1
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %30
11: ; preds = %5
%12 = zext i32 %6 to i64
br label %13
13: ; preds = %11, %28
%14 = phi i64 [ 0, %11 ], [ %18, %28 ]
%15 = getelementptr inbounds [30 x i8], [30 x i8]* %0, i64 %14, i64 0
%16 = tail call i32 @isNull(i8* %15)
%17 = icmp eq i32 %16, 0
%18 = add nuw nsw i64 %14, 1
br i1 %17, label %19, label %28
19: ; preds = %13
%20 = getelementptr inbounds [30 x i8], [30 x i8]* %0, i64 %18, i64 0
%21 = tail call i32 @isNull(i8* %20)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %19
%24 = tail call i64 @strcmp(i8* %15, i8* %20)
%25 = icmp sgt i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = tail call i32 @swap(i8* %15, i8* %20, i32 30)
br label %28
28: ; preds = %13, %19, %23, %26
%29 = icmp eq i64 %18, %12
br i1 %29, label %30, label %13
30: ; preds = %28, %5
%31 = add nuw nsw i32 %7, 1
%32 = add i32 %6, -1
%33 = icmp eq i32 %31, %3
br i1 %33, label %34, label %5
34: ; preds = %30, %2
ret void
}