#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*/ QUICKSORT(int *, int, int);
int /*<<< orphan*/ printf(char *);
int main() {
  int p, r, i, med, aux;
  int A[1000000];
  for (i = 0; i < 1000000; i++)
    A[i] = 1000000 - i;
  p = 0;
  r = 1000000 - 1;
  QUICKSORT(A, p, r);
  printf("\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3d0920,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0xf4240,-0x10(%rbp)
jge    1167 <main+0x47>
mov    $0xf4240,%ecx
sub    -0x10(%rbp),%ecx
movslq -0x10(%rbp),%rax
mov    %ecx,-0x3d0920(%rbp,%rax,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1139 <main+0x19>
movl   $0x0,-0x8(%rbp)
movl   $0xf423f,-0xc(%rbp)
lea    -0x3d0920(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1040 <QUICKSORT@plt>
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x3d0920,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x3d0908,%rsp
movdqa 0xed1(%rip),%xmm0
mov    $0x1c,%eax
movdqa 0xed3(%rip),%xmm8
movdqa 0xeda(%rip),%xmm9
movdqa 0xee1(%rip),%xmm10
movdqa 0xee8(%rip),%xmm11
movdqa 0xef0(%rip),%xmm5
movdqa 0xef8(%rip),%xmm6
movdqa 0xf00(%rip),%xmm7
movdqa 0xf08(%rip),%xmm1
movdqa 0xf10(%rip),%xmm2
movdqa %xmm8,%xmm3
psubd  %xmm0,%xmm3
movdqa %xmm9,%xmm4
psubd  %xmm0,%xmm4
movdqa %xmm3,-0x70(%rsp,%rax,4)
movdqa %xmm4,-0x60(%rsp,%rax,4)
movdqa %xmm10,%xmm3
psubd  %xmm0,%xmm3
movdqa %xmm11,%xmm4
psubd  %xmm0,%xmm4
movdqa %xmm3,-0x50(%rsp,%rax,4)
movdqa %xmm4,-0x40(%rsp,%rax,4)
movdqa %xmm5,%xmm3
psubd  %xmm0,%xmm3
movdqa %xmm6,%xmm4
psubd  %xmm0,%xmm4
movdqa %xmm3,-0x30(%rsp,%rax,4)
movdqa %xmm4,-0x20(%rsp,%rax,4)
movdqa %xmm7,%xmm3
psubd  %xmm0,%xmm3
movdqa %xmm1,%xmm4
psubd  %xmm0,%xmm4
movdqa %xmm3,-0x10(%rsp,%rax,4)
movdqa %xmm4,(%rsp,%rax,4)
paddd  %xmm2,%xmm0
add    $0x20,%rax
cmp    $0xf425c,%rax
jne    1180 <main+0x60>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0xf423f,%edx
call   1040 <QUICKSORT@plt>
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x3d0908,%rsp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [1000000 x i32]
store i32 0, i32* %1
store i32 0, i32* %4
br label %8
8: ; preds = %17, %0
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 1000000
br i1 %10, label %11, label %20
11: ; preds = %8
%12 = load i32, i32* %4
%13 = sub nsw i32 1000000, %12
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %7, i64 0, i64 %15
store i32 %13, i32* %16
br label %17
17: ; preds = %11
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
br label %8
20: ; preds = %8
store i32 0, i32* %2
store i32 999999, i32* %3
%21 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %7, i64 0, i64 0
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = call i32 @QUICKSORT(i32* %21, i32 %22, i32 %23)
%25 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@str = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca [1000000 x i32]
%2 = bitcast [1000000 x i32]* %1 to i8*
br label %3
3: ; preds = %3, %0
%4 = phi i64 [ 0, %0 ], [ %33, %3 ]
%5 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %0 ], [ %34, %3 ]
%6 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %4
%7 = sub <4 x i32> <i32 1000000, i32 1000000, i32 1000000, i32 1000000>, %5
%8 = sub <4 x i32> <i32 999996, i32 999996, i32 999996, i32 999996>, %5
%9 = bitcast i32* %6 to <4 x i32>*
store <4 x i32> %7, <4 x i32>* %9
%10 = getelementptr inbounds i32, i32* %6, i64 4
%11 = bitcast i32* %10 to <4 x i32>*
store <4 x i32> %8, <4 x i32>* %11
%12 = or i64 %4, 8
%13 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %12
%14 = sub <4 x i32> <i32 999992, i32 999992, i32 999992, i32 999992>, %5
%15 = sub <4 x i32> <i32 999988, i32 999988, i32 999988, i32 999988>, %5
%16 = bitcast i32* %13 to <4 x i32>*
store <4 x i32> %14, <4 x i32>* %16
%17 = getelementptr inbounds i32, i32* %13, i64 4
%18 = bitcast i32* %17 to <4 x i32>*
store <4 x i32> %15, <4 x i32>* %18
%19 = or i64 %4, 16
%20 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %19
%21 = sub <4 x i32> <i32 999984, i32 999984, i32 999984, i32 999984>, %5
%22 = sub <4 x i32> <i32 999980, i32 999980, i32 999980, i32 999980>, %5
%23 = bitcast i32* %20 to <4 x i32>*
store <4 x i32> %21, <4 x i32>* %23
%24 = getelementptr inbounds i32, i32* %20, i64 4
%25 = bitcast i32* %24 to <4 x i32>*
store <4 x i32> %22, <4 x i32>* %25
%26 = or i64 %4, 24
%27 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %26
%28 = sub <4 x i32> <i32 999976, i32 999976, i32 999976, i32 999976>, %5
%29 = sub <4 x i32> <i32 999972, i32 999972, i32 999972, i32 999972>, %5
%30 = bitcast i32* %27 to <4 x i32>*
store <4 x i32> %28, <4 x i32>* %30
%31 = getelementptr inbounds i32, i32* %27, i64 4
%32 = bitcast i32* %31 to <4 x i32>*
store <4 x i32> %29, <4 x i32>* %32
%33 = add nuw nsw i64 %4, 32
%34 = add <4 x i32> %5, <i32 32, i32 32, i32 32, i32 32>
%35 = icmp eq i64 %33, 1000000
br i1 %35, label %36, label %3
36: ; preds = %3
%37 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 0
%38 = call i32 @QUICKSORT(i32* %37, i32 0, i32 999999)
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret i32 0
}