#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 *);
void bubble(int size, char *arr[]) {
  void swap(char *[], int, int);
  int j, count;
  for (j = 1; j < size; j++) {
    for (count = 0; count < size - 1; count++)
      if (strcmp(arr[count], arr[count + 1]) > 0)
        swap(arr, count, count + 1);
  }
}


x86 assembly (clang, -O0):
<bubble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11be <bubble+0x9e>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11ab <bubble+0x8b>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jle    1198 <bubble+0x78>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x18(%rbp),%edx
add    $0x1,%edx
call   1040 <swap@plt>
jmp    119d <bubble+0x7d>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1149 <bubble+0x29>
jmp    11b0 <bubble+0x90>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1136 <bubble+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bubble>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     118e <bubble+0x6e>
mov    %rsi,%r15
mov    %edi,%r14d
lea    -0x1(%r14),%r12d
mov    $0x1,%r13d
jmp    1159 <bubble+0x39>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r13d
cmp    %r14d,%r13d
je     118e <bubble+0x6e>
xor    %ebx,%ebx
jmp    1168 <bubble+0x48>
nopl   (%rax)
mov    %rbp,%rbx
cmp    %rbp,%r12
je     1150 <bubble+0x30>
lea    0x1(%rbx),%rbp
mov    (%r15,%rbx,8),%rdi
mov    0x8(%r15,%rbx,8),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jle    1160 <bubble+0x40>
lea    0x1(%rbx),%edx
mov    %r15,%rdi
mov    %ebx,%esi
call   1040 <swap@plt>
jmp    1160 <bubble+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @bubble(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 1, i32* %5
br label %7
7: ; preds = %41, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %44
11: ; preds = %7
store i32 0, i32* %6
br label %12
12: ; preds = %37, %11
%13 = load i32, i32* %6
%14 = load i32, i32* %3
%15 = sub nsw i32 %14, 1
%16 = icmp slt i32 %13, %15
br i1 %16, label %17, label %40
17: ; preds = %12
%18 = load i8**, i8*** %4
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = load i8**, i8*** %4
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %23, i64 %26
%28 = load i8*, i8** %27
%29 = call i64 @strcmp(i8* %22, i8* %28)
%30 = icmp sgt i64 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %17
%32 = load i8**, i8*** %4
%33 = load i32, i32* %6
%34 = load i32, i32* %6
%35 = add nsw i32 %34, 1
br label %36
36: ; preds = %31, %17
br label %37
37: ; preds = %36
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
br label %12
40: ; preds = %12
br label %41
41: ; preds = %40
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
store i32 %43, i32* %5
br label %7
44: ; preds = %7
ret void
}

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