#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*/ free(int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ quickSort(int *, int /*<<< orphan*/, unsigned int);
int /*<<< orphan*/ scanf(char *, ...);
int main(int argc, char *argv[]) {
  unsigned int num;
  unsigned int i;
  int *p;
  printf("number of int:");
  scanf("%d", &num);
  p = (int *)malloc(sizeof(int) * num);
  if (!p)
    return -1;
  printf("numbers:");
  for (i = 0; i < num; i++) {
    scanf("%d", &p[i]);
  }
  quickSort(p, 0, num - 1);
  for (i = 0; i < num; i++) {
    printf("%d ", p[i]);
  }
  printf("\n");
  free(p);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe94(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x14(%rbp),%eax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11af <main+0x5f>
movl   $0xffffffff,-0x4(%rbp)
jmp    1262 <main+0x112>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    11fa <main+0xaa>
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%eax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11c4 <main+0x74>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1070 <quickSort@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1244 <main+0xf4>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    (%rax,%rcx,4),%esi
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1212 <main+0xc2>
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xe92(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe93(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x4(%rsp),%edi
shl    $0x2,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     11e3 <main+0x83>
mov    %rax,%r15
lea    0xe6f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0x4(%rsp)
je     11eb <main+0x8b>
lea    0xe57(%rip),%r14
mov    %r15,%rbx
xor    %ebp,%ebp
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
add    $0x1,%rbp
mov    0x4(%rsp),%edx
add    $0x4,%rbx
cmp    %rdx,%rbp
jb     11c0 <main+0x60>
add    $0xffffffff,%edx
jmp    11f0 <main+0x90>
mov    $0xffffffff,%r14d
jmp    123d <main+0xdd>
mov    $0xffffffff,%edx
xor    %r14d,%r14d
mov    %r15,%rdi
xor    %esi,%esi
call   1080 <quickSort@plt>
cmpl   $0x0,0x4(%rsp)
je     122b <main+0xcb>
lea    0xe10(%rip),%rbx
xor    %ebp,%ebp
nopl   (%rax)
mov    (%r15,%rbp,4),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
mov    0x4(%rsp),%eax
cmp    %rax,%rbp
jb     1210 <main+0xb0>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"number of int:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [9 x i8] c"numbers:\00"
@.str.3 = [4 x i8] c"%d \00"
@.str.4 = [2 x i8] c"\0A\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 i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%11 = load i32, i32* %6
%12 = zext i32 %11 to i64
%13 = mul i64 4, %12
%14 = trunc i64 %13 to i32
%15 = call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i32*
store i32* %16, i32** %8
%17 = load i32*, i32** %8
%18 = icmp ne i32* %17, null
br i1 %18, label %20, label %19
19: ; preds = %2
store i32 -1, i32* %3
br label %58
20: ; preds = %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %7
br label %22
22: ; preds = %32, %20
%23 = load i32, i32* %7
%24 = load i32, i32* %6
%25 = icmp ult i32 %23, %24
br i1 %25, label %26, label %35
26: ; preds = %22
%27 = load i32*, i32** %8
%28 = load i32, i32* %7
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
%31 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %30)
br label %32
32: ; preds = %26
%33 = load i32, i32* %7
%34 = add i32 %33, 1
store i32 %34, i32* %7
br label %22
35: ; preds = %22
%36 = load i32*, i32** %8
%37 = load i32, i32* %6
%38 = sub i32 %37, 1
%39 = call i32 @quickSort(i32* %36, i32 0, i32 %38)
store i32 0, i32* %7
br label %40
40: ; preds = %51, %35
%41 = load i32, i32* %7
%42 = load i32, i32* %6
%43 = icmp ult i32 %41, %42
br i1 %43, label %44, label %54
44: ; preds = %40
%45 = load i32*, i32** %8
%46 = load i32, i32* %7
%47 = zext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %45, i64 %47
%49 = load i32, i32* %48
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %49)
br label %51
51: ; preds = %44
%52 = load i32, i32* %7
%53 = add i32 %52, 1
store i32 %53, i32* %7
br label %40
54: ; preds = %40
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%56 = load i32*, i32** %8
%57 = call i32 @free(i32* %56)
store i32 0, i32* %3
br label %58
58: ; preds = %54, %19
%59 = load i32, i32* %3
ret i32 %59
}

LLVM IR (-O2):
@.str = [15 x i8] c"number of int:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [9 x i8] c"numbers:\00"
@.str.3 = [4 x i8] c"%d \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = load i32, i32* %3
%8 = shl i32 %7, 2
%9 = call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to i32*
%11 = icmp eq i64 %9, 0
br i1 %11, label %43, label %12
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 0
br i1 %15, label %26, label %16
16: ; preds = %12, %16
%17 = phi i64 [ %20, %16 ], [ 0, %12 ]
%18 = getelementptr inbounds i32, i32* %10, i64 %17
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %18)
%20 = add nuw nsw i64 %17, 1
%21 = load i32, i32* %3
%22 = zext i32 %21 to i64
%23 = icmp ult i64 %20, %22
br i1 %23, label %16, label %24
24: ; preds = %16
%25 = add i32 %21, -1
br label %26
26: ; preds = %24, %12
%27 = phi i32 [ -1, %12 ], [ %25, %24 ]
%28 = call i32 @quickSort(i32* %10, i32 0, i32 %27)
%29 = load i32, i32* %3
%30 = icmp eq i32 %29, 0
br i1 %30, label %40, label %31
31: ; preds = %26, %31
%32 = phi i64 [ %36, %31 ], [ 0, %26 ]
%33 = getelementptr inbounds i32, i32* %10, i64 %32
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %34)
%36 = add nuw nsw i64 %32, 1
%37 = load i32, i32* %3
%38 = zext i32 %37 to i64
%39 = icmp ult i64 %36, %38
br i1 %39, label %31, label %40
40: ; preds = %31, %26
%41 = call i32 @putchar(i32 10)
%42 = call i32 @free(i32* %10)
br label %43
43: ; preds = %2, %40
%44 = phi i32 [ 0, %40 ], [ -1, %2 ]
ret i32 %44
}