#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*/ swapBeseda(char **, int);
int /*<<< orphan*/ swapStevilka(int *, int *);
void buuble_sort(char **tabela, int *knjige, int n) {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n - i - 1; ++j) {
      if (knjige[j] < knjige[j + 1]) {
        swapBeseda(tabela, j);
        swapStevilka(&knjige[j], &knjige[j + 1]);
      }
    }
  }
}


x86 assembly (clang, -O0):
<buuble_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11db <buuble_sort+0xbb>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    -0x18(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11c8 <buuble_sort+0xa8>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x10(%rbp),%rcx
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
cmp    (%rcx,%rdx,4),%eax
jge    11b5 <buuble_sort+0x95>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <swapBeseda@plt>
mov    -0x10(%rbp),%rdi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
call   1040 <swapStevilka@plt>
jmp    11ba <buuble_sort+0x9a>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114d <buuble_sort+0x2d>
jmp    11cd <buuble_sort+0xad>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113a <buuble_sort+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<buuble_sort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,0x8(%rsp)
test   %edx,%edx
jle    11b0 <buuble_sort+0x90>
mov    %rdi,%r12
addq   $0x4,0x8(%rsp)
lea    -0x1(%rdx),%ebp
xor    %r14d,%r14d
mov    %rdx,0x10(%rsp)
jmp    1161 <buuble_sort+0x41>
nopl   (%rax)
add    $0x1,%r14d
add    $0xffffffff,%ebp
mov    0x10(%rsp),%rdx
cmp    %edx,%r14d
je     11b0 <buuble_sort+0x90>
mov    %ebp,%ebp
mov    %r14d,%eax
not    %eax
add    %edx,%eax
test   %eax,%eax
jle    1150 <buuble_sort+0x30>
mov    0x8(%rsp),%rbx
xor    %esi,%esi
jmp    118c <buuble_sort+0x6c>
nopw   0x0(%rax,%rax,1)
add    $0x4,%rbx
mov    %r15,%rsi
cmp    %r15,%rbp
je     1150 <buuble_sort+0x30>
mov    -0x4(%rbx),%eax
lea    0x1(%rsi),%r15
cmp    (%rbx),%eax
jge    1180 <buuble_sort+0x60>
lea    -0x4(%rbx),%r13
mov    %r12,%rdi
call   1030 <swapBeseda@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1040 <swapStevilka@plt>
jmp    1180 <buuble_sort+0x60>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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