#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 atoi(char *);
int /*<<< orphan*/ check_is_inc_arr(int *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ heap_sort(int *, int, int);
int /*<<< orphan*/ initArr(int *, int, int, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ srand(int);
scalar_t__ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  if (argc != 4) {
    printf("input array length and the random value range.\n");
    exit(0);
  }
  srand((int)time(NULL));
  int length = atoi(argv[1]);
  int lowV = atoi(argv[2]);
  int upV = atoi(argv[3]);
  int *arr = (int *)malloc(sizeof(int) * (length + 1));
  initArr(arr, lowV, upV, length);
  heap_sort(arr, length, length);
  check_is_inc_arr(arr, length);
  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)
cmpl   $0x4,-0x8(%rbp)
je     11c3 <main+0x33>
lea    0xe49(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1080 <initArr@plt>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <heap_sort@plt>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10b0 <check_is_inc_arr@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x4,%edi
jne    1212 <main+0x82>
mov    %rsi,%r14
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    0x8(%r14),%rdi
call   1090 <atoi@plt>
mov    %eax,%ebx
mov    0x10(%r14),%rdi
call   1090 <atoi@plt>
mov    %eax,%r15d
mov    0x18(%r14),%rdi
call   1090 <atoi@plt>
mov    %eax,%r14d
lea    0x4(,%rbx,4),%edi
call   1070 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
mov    %ebx,%ecx
call   1080 <initArr@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
mov    %ebx,%edx
call   1030 <heap_sort@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
call   10b0 <check_is_inc_arr@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xde7(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [48 x i8] c"input array length and the random value range.\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
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 4
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 0)
unreachable
15: ; preds = %2
%16 = call i64 @time(i32* null)
%17 = trunc i64 %16 to i32
%18 = call i32 @srand(i32 %17)
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %6
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %7
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 3
%29 = load i8*, i8** %28
%30 = call i32 @atoi(i8* %29)
store i32 %30, i32* %8
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = mul i64 4, %33
%35 = trunc i64 %34 to i32
%36 = call i64 @malloc(i32 %35)
%37 = inttoptr i64 %36 to i32*
store i32* %37, i32** %9
%38 = load i32*, i32** %9
%39 = load i32, i32* %7
%40 = load i32, i32* %8
%41 = load i32, i32* %6
%42 = call i32 @initArr(i32* %38, i32 %39, i32 %40, i32 %41)
%43 = load i32*, i32** %9
%44 = load i32, i32* %6
%45 = load i32, i32* %6
%46 = call i32 @heap_sort(i32* %43, i32 %44, i32 %45)
%47 = load i32*, i32** %9
%48 = load i32, i32* %6
%49 = call i32 @check_is_inc_arr(i32* %47, i32 %48)
ret i32 0
}

LLVM IR (-O2):
@str = [47 x i8] c"input array length and the random value range.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @exit(i32 0)
unreachable
7: ; preds = %2
%8 = tail call i64 @time(i32* null)
%9 = trunc i64 %8 to i32
%10 = tail call i32 @srand(i32 %9)
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = tail call i32 @atoi(i8* %15)
%17 = getelementptr inbounds i8*, i8** %1, i64 3
%18 = load i8*, i8** %17
%19 = tail call i32 @atoi(i8* %18)
%20 = shl i32 %13, 2
%21 = add i32 %20, 4
%22 = tail call i64 @malloc(i32 %21)
%23 = inttoptr i64 %22 to i32*
%24 = tail call i32 @initArr(i32* %23, i32 %16, i32 %19, i32 %13)
%25 = tail call i32 @heap_sort(i32* %23, i32 %13, i32 %13)
%26 = tail call i32 @check_is_inc_arr(i32* %23, i32 %13)
ret i32 0
}