#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 partition(int *, int, int, int);
void quickSort(int *tableau, int gauche, int droite, int min, int max) {
  if (gauche < droite - 1) {
    int milieu = partition(tableau, gauche, droite, (max + min) / 2);
    quickSort(tableau, gauche, milieu, min, (max + min) / 2);
    quickSort(tableau, milieu, droite, (max + min) / 2, max);
  }
}


x86 assembly (clang, -O0):
<quickSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11c6 <quickSort+0xa6>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x28(%rbp),%edx
mov    %eax,%ecx
call   1030 <partition@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    $0x2,%r8d
cltd
idiv   %r8d
mov    -0x24(%rbp),%edx
mov    %eax,%r8d
call   1040 <quickSort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x20(%rbp),%edx
mov    %eax,%ecx
mov    -0x18(%rbp),%r8d
call   1040 <quickSort@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quickSort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%r12d
lea    -0x1(%r12),%eax
cmp    %esi,%eax
jle    1195 <quickSort+0x75>
mov    %ecx,%r13d
mov    %esi,%r14d
mov    %rdi,%r15
mov    %r8,0x10(%rsp)
mov    %eax,0xc(%rsp)
nopl   0x0(%rax)
lea    (%r8,%r13,1),%eax
mov    %eax,%ebx
shr    $0x1f,%ebx
add    %eax,%ebx
sar    %ebx
mov    %r15,%rdi
mov    %r14d,%esi
mov    %r12d,%edx
mov    %ebx,%ecx
call   1030 <partition@plt>
mov    %eax,%ebp
mov    %r15,%rdi
mov    %r14d,%esi
mov    %eax,%edx
mov    %r13d,%ecx
mov    %ebx,%r8d
call   1040 <quickSort@plt>
mov    0xc(%rsp),%eax
mov    0x10(%rsp),%r8
mov    %ebx,%r13d
mov    %ebp,%r14d
cmp    %ebp,%eax
jg     1150 <quickSort+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @quickSort(i32* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = add nsw i32 %2, -1
%7 = icmp sgt i32 %6, %1
br i1 %7, label %8, label %15
8: ; preds = %5, %8
%9 = phi i32 [ %12, %8 ], [ %3, %5 ]
%10 = phi i32 [ %13, %8 ], [ %1, %5 ]
%11 = add nsw i32 %9, %4
%12 = sdiv i32 %11, 2
%13 = tail call i32 @partition(i32* %0, i32 %10, i32 %2, i32 %12)
tail call void @quickSort(i32* %0, i32 %10, i32 %13, i32 %9, i32 %12)
%14 = icmp sgt i32 %6, %13
br i1 %14, label %8, label %15
15: ; preds = %8, %5
ret void
}