#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*/ printf(char *, ...);
int /*<<< orphan*/ quicksort(int *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, const char *argv[]) {
  int arrayLength = 0, i = 0;
  printf("Ingresa la longitud del arreglo: ");
  scanf("%d", &arrayLength);
  int array[arrayLength];
  for (i = 0; i < arrayLength; i++) {
    printf("array[%d]: ", i);
    scanf("%d", &array[i]);
  }
  quicksort(array, arrayLength);
  printf("Lista Ordenada \n");
  for (i = 0; i < arrayLength; i++) {
    printf("%d", array[i]);
    if (i < arrayLength - 1) {
      printf(",");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xea5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11e6 <main+0xb6>
mov    -0x18(%rbp),%esi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rsi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe4f(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a0 <main+0x70>
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <quicksort@plt>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    125e <main+0x12e>
mov    -0x30(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    124b <main+0x11b>
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1250 <main+0x120>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1207 <main+0xd7>
movl   $0x0,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x0,-0x2c(%rbp)
lea    0xe91(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xea5(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1070 <scanf@plt>
mov    %rsp,%r15
mov    -0x2c(%rbp),%eax
mov    %rsp,%r12
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    -0x2c(%rbp),%esi
test   %esi,%esi
jle    11ec <main+0x9c>
mov    %r15,-0x38(%rbp)
lea    0xe72(%rip),%r14
lea    0xe68(%rip),%r15
mov    %r12,%r13
xor    %ebx,%ebx
nop
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1070 <scanf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rsi
add    $0x4,%r13
cmp    %rsi,%rbx
jl     11c0 <main+0x70>
mov    -0x38(%rbp),%r15
mov    %r12,%rdi
call   1050 <quicksort@plt>
lea    0xe36(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    1258 <main+0x108>
lea    0xe15(%rip),%r14
xor    %ebx,%ebx
jmp    122b <main+0xdb>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cltq
cmp    %rax,%rbx
jge    1258 <main+0x108>
mov    (%r12,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movslq -0x2c(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
cmp    %rcx,%rbx
jge    1220 <main+0xd0>
mov    $0x2c,%edi
call   1030 <putchar@plt>
mov    -0x2c(%rbp),%eax
jmp    1220 <main+0xd0>
mov    %r15,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Ingresa la longitud del arreglo: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [12 x i8] c"array[%d]: \00"
@.str.3 = [17 x i8] c"Lista Ordenada \0A\00"
@.str.4 = [2 x i8] c",\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%12 = load i32, i32* %6
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %8
%15 = alloca i32, i64 %13
store i64 %13, i64* %9
store i32 0, i32* %7
br label %16
16: ; preds = %27, %2
%17 = load i32, i32* %7
%18 = load i32, i32* %6
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %30
20: ; preds = %16
%21 = load i32, i32* %7
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %15, i64 %24
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %25)
br label %27
27: ; preds = %20
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %16
30: ; preds = %16
%31 = load i32, i32* %6
%32 = call i32 @quicksort(i32* %15, i32 %31)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %7
br label %34
34: ; preds = %51, %30
%35 = load i32, i32* %7
%36 = load i32, i32* %6
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %54
38: ; preds = %34
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %15, i64 %40
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %42)
%44 = load i32, i32* %7
%45 = load i32, i32* %6
%46 = sub nsw i32 %45, 1
%47 = icmp slt i32 %44, %46
br i1 %47, label %48, label %50
48: ; preds = %38
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %50
50: ; preds = %48, %38
br label %51
51: ; preds = %50
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 1
store i32 %53, i32* %7
br label %34
54: ; preds = %34
store i32 0, i32* %3
%55 = load i8*, i8** %8
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@.str = [34 x i8] c"Ingresa la longitud del arreglo: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [12 x i8] c"array[%d]: \00"
@str = [16 x i8] c"Lista Ordenada \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = load i32, i32* %3
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
%10 = alloca i32, i64 %8
%11 = load i32, i32* %3
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %2, %13
%14 = phi i64 [ %19, %13 ], [ 0, %2 ]
%15 = trunc i64 %14 to i32
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds i32, i32* %10, i64 %14
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %17)
%19 = add nuw nsw i64 %14, 1
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = icmp slt i64 %19, %21
br i1 %22, label %13, label %23
23: ; preds = %13, %2
%24 = phi i32 [ %11, %2 ], [ %20, %13 ]
%25 = call i32 @quicksort(i32* %10, i32 %24)
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%27 = load i32, i32* %3
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %46
29: ; preds = %23, %41
%30 = phi i64 [ %43, %41 ], [ 0, %23 ]
%31 = getelementptr inbounds i32, i32* %10, i64 %30
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %3
%35 = add nsw i32 %34, -1
%36 = sext i32 %35 to i64
%37 = icmp slt i64 %30, %36
br i1 %37, label %38, label %41
38: ; preds = %29
%39 = call i32 @putchar(i32 44)
%40 = load i32, i32* %3
br label %41
41: ; preds = %29, %38
%42 = phi i32 [ %34, %29 ], [ %40, %38 ]
%43 = add nuw nsw i64 %30, 1
%44 = sext i32 %42 to i64
%45 = icmp slt i64 %43, %44
br i1 %45, label %29, label %46
46: ; preds = %41, %23
ret i32 0
}