#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*/ permuter(int *, int *);
int *bubbleSort(int *tab, int taille) {
  int i, j;
  int *address = tab;
  for (i = 0; i < taille; i++) {
    for (j = 0; j < taille - 1; j++) {
      int *inf = tab;
      int *sup = tab + 1;
      int a, b;
      a = *inf;
      b = *sup;
      if (a > b) {
        permuter(inf, sup);
      }
      tab++;
    }
    tab = address;
  }
  return tab;
}


x86 assembly (clang, -O0):
<bubbleSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c1 <bubbleSort+0xb1>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11ab <bubbleSort+0x9b>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x38(%rbp),%eax
jle    1191 <bubbleSort+0x81>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <permuter@plt>
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1141 <bubbleSort+0x31>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112e <bubbleSort+0x1e>
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bubbleSort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,(%rsp)
test   %esi,%esi
jle    117f <bubbleSort+0x6f>
mov    %esi,%r15d
lea    -0x1(%r15),%r14d
mov    (%rsp),%rax
lea    0x4(%rax),%r13
xor    %ebp,%ebp
jmp    1148 <bubbleSort+0x38>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    %r15d,%ebp
je     117f <bubbleSort+0x6f>
cmp    $0x1,%r15d
je     1140 <bubbleSort+0x30>
mov    %r14d,%r12d
mov    %r13,%rbx
jmp    116a <bubbleSort+0x5a>
cs nopw 0x0(%rax,%rax,1)
add    $0x4,%rbx
add    $0xffffffff,%r12d
je     1140 <bubbleSort+0x30>
mov    -0x4(%rbx),%eax
cmp    (%rbx),%eax
jle    1160 <bubbleSort+0x50>
lea    -0x4(%rbx),%rdi
mov    %rbx,%rsi
call   1030 <permuter@plt>
jmp    1160 <bubbleSort+0x50>
mov    (%rsp),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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