#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*/ bsort(int *, int /*<<< orphan*/, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, const char *argv[]) {
  int *arr = NULL;
  int num;
  printf("How much numbers you want, guy?: ");
  scanf("%d", &num);
  arr = (int *)malloc(num * sizeof(int));
  printf("Put in the numbers: ");
  for (int i = 0; i < num; i++) {
    scanf("%d", &arr[i]);
  }
  bsort(arr, 0, num - 1);
  for (int i = 0; i < num; i++) {
    printf("The sorted list be %d. %d\n", i + 1, arr[i]);
  }
  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)
movq   $0x0,-0x18(%rbp)
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeaf(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <scanf@plt>
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11d9 <main+0x99>
mov    -0x18(%rbp),%rsi
movslq -0x20(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe5c(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11a4 <main+0x64>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1040 <bsort@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    122a <main+0xea>
mov    -0x24(%rbp),%esi
add    $0x1,%esi
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11f1 <main+0xb1>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec5(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%edi
shl    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%edx
test   %edx,%edx
jle    11bd <main+0x7d>
xor    %r12d,%r12d
lea    0xe8c(%rip),%r15
mov    %r14,%rbx
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
add    $0x1,%r12
movslq 0x4(%rsp),%rdx
add    $0x4,%rbx
cmp    %rdx,%r12
jl     11a0 <main+0x60>
add    $0xffffffff,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <bsort@plt>
cmpl   $0x0,0x4(%rsp)
jle    11fe <main+0xbe>
lea    0xe62(%rip),%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r14,%rbx,4),%edx
add    $0x1,%rbx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
movslq 0x4(%rsp),%rax
cmp    %rax,%rbx
jl     11e0 <main+0xa0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [34 x i8] c"How much numbers you want, guy?: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"Put in the numbers: \00"
@.str.3 = [27 x i8] c"The sorted list be %d. %d\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
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
%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* %7)
%12 = load i32, i32* %7
%13 = sext i32 %12 to i64
%14 = mul i64 %13, 4
%15 = trunc i64 %14 to i32
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i32*
store i32* %17, i32** %6
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %8
br label %19
19: ; preds = %29, %2
%20 = load i32, i32* %8
%21 = load i32, i32* %7
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %32
23: ; preds = %19
%24 = load i32*, i32** %6
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %27)
br label %29
29: ; preds = %23
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
br label %19
32: ; preds = %19
%33 = load i32*, i32** %6
%34 = load i32, i32* %7
%35 = sub nsw i32 %34, 1
%36 = call i32 @bsort(i32* %33, i32 0, i32 %35)
store i32 0, i32* %9
br label %37
37: ; preds = %50, %32
%38 = load i32, i32* %9
%39 = load i32, i32* %7
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %53
41: ; preds = %37
%42 = load i32, i32* %9
%43 = add nsw i32 %42, 1
%44 = load i32*, i32** %6
%45 = load i32, i32* %9
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i32, i32* %44, i64 %46
%48 = load i32, i32* %47
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %43, i32 %48)
br label %50
50: ; preds = %41
%51 = load i32, i32* %9
%52 = add nsw i32 %51, 1
store i32 %52, i32* %9
br label %37
53: ; preds = %37
ret i32 0
}

LLVM IR (-O2):
@.str = [34 x i8] c"How much numbers you want, guy?: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"Put in the numbers: \00"
@.str.3 = [27 x i8] c"The sorted list be %d. %d\0A\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 ([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 = shl i32 %7, 2
%9 = call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to i32*
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%12 = load i32, i32* %3
%13 = icmp sgt i32 %12, 0
br i1 %13, label %20, label %14
14: ; preds = %20, %2
%15 = phi i32 [ %12, %2 ], [ %25, %20 ]
%16 = add nsw i32 %15, -1
%17 = call i32 @bsort(i32* %10, i32 0, i32 %16)
%18 = load i32, i32* %3
%19 = icmp sgt i32 %18, 0
br i1 %19, label %29, label %28
20: ; preds = %2, %20
%21 = phi i64 [ %24, %20 ], [ 0, %2 ]
%22 = getelementptr inbounds i32, i32* %10, i64 %21
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %22)
%24 = add nuw nsw i64 %21, 1
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %24, %26
br i1 %27, label %20, label %14
28: ; preds = %29, %14
ret i32 0
29: ; preds = %14, %29
%30 = phi i64 [ %31, %29 ], [ 0, %14 ]
%31 = add nuw nsw i64 %30, 1
%32 = getelementptr inbounds i32, i32* %10, i64 %30
%33 = load i32, i32* %32
%34 = trunc i64 %31 to i32
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %34, i32 %33)
%36 = load i32, i32* %3
%37 = sext i32 %36 to i64
%38 = icmp slt i64 %31, %37
br i1 %38, label %29, label %28
}