#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 */
typedef int /*<<< orphan*/ arreglo;

/* Variables and functions */
int /*<<< orphan*/ burbuja(int *, int);
int /*<<< orphan*/ burbujaM(int *, int);
int /*<<< orphan*/ crearArreglo(int *, int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ quicksort(int *, int);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdin;
int main(void) {
  int arreglo[20000];
  int opc;
  crearArreglo(arreglo, sizeof(arreglo) / sizeof(int));
  do {
    printf("-------------MENU---------------\n");
    printf("1-REALIZAR METODO BURBUJA\n");
    printf("2-REALIZAR METODO BURBUJA MEJORADA\n");
    printf("3-REALIZAR METODO QUICKSORT\n");
    scanf("%d", &opc);
  } while (opc < 0 && opc > 3);
  switch (opc) {
  case 1:
    burbuja(arreglo, sizeof(arreglo) / sizeof(int));
    break;
  case 2:
    burbujaM(arreglo, sizeof(arreglo) / sizeof(int));
    break;
  case 3:
    quicksort(arreglo, sizeof(arreglo) / sizeof(int));
    break;
  }
  fflush(stdin);
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x138a0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x13890(%rbp),%rdi
mov    $0x4e20,%esi
call   1030 <crearArreglo@plt>
lea    0xe56(%rip),%rdi
call   1050 <printf@plt>
lea    0xe6c(%rip),%rdi
call   1050 <printf@plt>
lea    0xe7b(%rip),%rdi
call   1050 <printf@plt>
lea    0xe93(%rip),%rdi
call   1050 <printf@plt>
lea    0xea4(%rip),%rdi
lea    -0x13894(%rbp),%rsi
call   1090 <scanf@plt>
xor    %eax,%eax
cmpl   $0x0,-0x13894(%rbp)
mov    %al,-0x13895(%rbp)
jge    120b <main+0x8b>
cmpl   $0x3,-0x13894(%rbp)
setg   %al
mov    %al,-0x13895(%rbp)
mov    -0x13895(%rbp),%al
test   $0x1,%al
jne    11a3 <main+0x23>
mov    -0x13894(%rbp),%eax
mov    %eax,-0x1389c(%rbp)
sub    $0x1,%eax
je     125b <main+0xdb>
jmp    1233 <main+0xb3>
mov    -0x1389c(%rbp),%eax
sub    $0x2,%eax
je     1271 <main+0xf1>
jmp    1247 <main+0xc7>
mov    -0x1389c(%rbp),%eax
sub    $0x3,%eax
je     1287 <main+0x107>
jmp    1298 <main+0x118>
lea    -0x13890(%rbp),%rdi
mov    $0x4e20,%esi
call   10a0 <burbuja@plt>
jmp    1298 <main+0x118>
lea    -0x13890(%rbp),%rdi
mov    $0x4e20,%esi
call   1080 <burbujaM@plt>
jmp    1298 <main+0x118>
lea    -0x13890(%rbp),%rdi
mov    $0x4e20,%esi
call   1040 <quicksort@plt>
mov    0x2d49(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
xor    %eax,%eax
add    $0x138a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x13898,%rsp
lea    0x10(%rsp),%rdi
mov    $0x4e20,%esi
call   1030 <crearArreglo@plt>
lea    0xe66(%rip),%rdi
call   1040 <puts@plt>
lea    0xe7b(%rip),%rdi
call   1040 <puts@plt>
lea    0xe89(%rip),%rdi
call   1040 <puts@plt>
lea    0xea0(%rip),%rdi
call   1040 <puts@plt>
lea    0xe33(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1090 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x3,%eax
je     11fb <main+0x7b>
cmp    $0x2,%eax
je     120c <main+0x8c>
cmp    $0x1,%eax
jne    121b <main+0x9b>
lea    0x10(%rsp),%rdi
mov    $0x4e20,%esi
call   10a0 <burbuja@plt>
jmp    121b <main+0x9b>
lea    0x10(%rsp),%rdi
mov    $0x4e20,%esi
call   1050 <quicksort@plt>
jmp    121b <main+0x9b>
lea    0x10(%rsp),%rdi
mov    $0x4e20,%esi
call   1080 <burbujaM@plt>
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
xor    %eax,%eax
add    $0x13898,%rsp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"-------------MENU---------------\0A\00"
@.str.1 = [27 x i8] c"1-REALIZAR METODO BURBUJA\0A\00"
@.str.2 = [36 x i8] c"2-REALIZAR METODO BURBUJA MEJORADA\0A\00"
@.str.3 = [29 x i8] c"3-REALIZAR METODO QUICKSORT\0A\00"
@.str.4 = [3 x i8] c"%d\00"
@stdin = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [20000 x i32]
%3 = alloca i32
store i32 0, i32* %1
%4 = getelementptr inbounds [20000 x i32], [20000 x i32]* %2, i64 0, i64 0
%5 = call i32 @crearArreglo(i32* %4, i32 20000)
br label %6
6: ; preds = %18, %0
%7 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
br label %12
12: ; preds = %6
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32, i32* %3
%17 = icmp sgt i32 %16, 3
br label %18
18: ; preds = %15, %12
%19 = phi i1 [ false, %12 ], [ %17, %15 ]
br i1 %19, label %6, label %20
20: ; preds = %18
%21 = load i32, i32* %3
switch i32 %21, label %31 [
i32 1, label %22
i32 2, label %25
i32 3, label %28
]
22: ; preds = %20
%23 = getelementptr inbounds [20000 x i32], [20000 x i32]* %2, i64 0, i64 0
%24 = call i32 @burbuja(i32* %23, i32 20000)
br label %31
25: ; preds = %20
%26 = getelementptr inbounds [20000 x i32], [20000 x i32]* %2, i64 0, i64 0
%27 = call i32 @burbujaM(i32* %26, i32 20000)
br label %31
28: ; preds = %20
%29 = getelementptr inbounds [20000 x i32], [20000 x i32]* %2, i64 0, i64 0
%30 = call i32 @quicksort(i32* %29, i32 20000)
br label %31
31: ; preds = %20, %28, %25, %22
%32 = load i32, i32* @stdin
%33 = call i32 @fflush(i32 %32)
%34 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str.4 = [3 x i8] c"%d\00"
@stdin = global i32 0
@str = [33 x i8] c"-------------MENU---------------\00"
@str.5 = [26 x i8] c"1-REALIZAR METODO BURBUJA\00"
@str.6 = [35 x i8] c"2-REALIZAR METODO BURBUJA MEJORADA\00"
@str.7 = [28 x i8] c"3-REALIZAR METODO QUICKSORT\00"
define i32 @main() {
%1 = alloca [20000 x i32]
%2 = alloca i32
%3 = bitcast [20000 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = getelementptr inbounds [20000 x i32], [20000 x i32]* %1, i64 0, i64 0
%6 = call i32 @crearArreglo(i32* %5, i32 20000)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.5, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.6, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.7, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
switch i32 %12, label %19 [
i32 1, label %13
i32 2, label %15
i32 3, label %17
]
13: ; preds = %0
%14 = call i32 @burbuja(i32* %5, i32 20000)
br label %19
15: ; preds = %0
%16 = call i32 @burbujaM(i32* %5, i32 20000)
br label %19
17: ; preds = %0
%18 = call i32 @quicksort(i32* %5, i32 20000)
br label %19
19: ; preds = %0, %17, %15, %13
%20 = load i32, i32* @stdin
%21 = call i32 @fflush(i32 %20)
%22 = call i32 (...) @getchar()
ret i32 0
}