#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 bubble(char a[8][15], int n) {
  int i, j;
  for (i = 0; i < n - 1; i++)
    for (j = n - 1; j > i; j--)
      if (strcmp(a[j - 1], a[j]) > 0)
        swap(a[j - 1], a[j]);
}


x86 assembly (clang, -O0):
<bubble>:
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    11da <bubble+0xba>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    11c7 <bubble+0xa7>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cltq
imul   $0xf,%rax,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
movslq -0x14(%rbp),%rax
imul   $0xf,%rax,%rax
add    %rax,%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jle    11b4 <bubble+0x94>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cltq
imul   $0xf,%rax,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
movslq -0x14(%rbp),%rax
imul   $0xf,%rax,%rax
add    %rax,%rsi
call   1040 <swap@plt>
jmp    11b9 <bubble+0x99>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1150 <bubble+0x30>
jmp    11cc <bubble+0xac>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%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
mov    %rdi,(%rsp)
cmp    $0x2,%esi
jl     11ad <bubble+0x8d>
mov    %esi,%r15d
mov    %esi,%r14d
add    $0xffffffff,%r15d
add    $0xffffffffffffffff,%r14
lea    (%r14,%r14,4),%rax
lea    (%rax,%rax,2),%rax
add    %rax,(%rsp)
xor    %ebp,%ebp
jmp    1169 <bubble+0x49>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbp
cmp    %r15,%rbp
je     11ad <bubble+0x8d>
mov    (%rsp),%rbx
mov    %r14,%r13
jmp    1188 <bubble+0x68>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rbx
cmp    %rbp,%r13
jle    1160 <bubble+0x40>
add    $0xffffffffffffffff,%r13
lea    -0xf(%rbx),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jle    1180 <bubble+0x60>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <swap@plt>
jmp    1180 <bubble+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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