#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ heapSortInc(int *, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ thePrintf(int *, int);
int main(void) {
  FILE *thisArray;
  int *array, size, i, value;
  char thisString[128];
  thisArray = fopen("randNums.txt", "rb");
  if (NULL == thisArray) {
    fprintf(stderr, "File Open Error.\r\n");
    return -1;
  }
  fscanf(thisArray, "%d", &size);
  array = (int *)malloc(size * sizeof(int));
  if (NULL == array) {
    fprintf(stderr, "Malloc Array Error.\r\n");
    return -1;
  }
  for (i = 0; i < size; i++) {
    fscanf(thisArray, "%d", &value);
    array[i] = value;
  }
  thePrintf(array, size);
  heapSortInc(array, size);
  thePrintf(array, size);
  free(array);
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe67(%rip),%rdi
lea    0xe6d(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    11d6 <main+0x56>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
lea    0xe4b(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12a8 <main+0x128>
mov    -0x10(%rbp),%rdi
lea    0xe42(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1050 <fscanf@plt>
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    122a <main+0xaa>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
lea    0xe0d(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12a8 <main+0x128>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    126d <main+0xed>
mov    -0x10(%rbp),%rdi
lea    0xddb(%rip),%rsi
lea    -0x24(%rbp),%rdx
call   1050 <fscanf@plt>
mov    -0x24(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1231 <main+0xb1>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1090 <thePrintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <heapSortInc@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1090 <thePrintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe6c(%rip),%rdi
lea    0xe72(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1247 <main+0xc7>
mov    %rax,%r13
lea    0xe70(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
call   1050 <fscanf@plt>
mov    0x8(%rsp),%edi
shl    $0x2,%edi
call   1080 <malloc@plt>
test   %rax,%rax
je     1259 <main+0xd9>
mov    %rax,%r14
mov    0x8(%rsp),%esi
test   %esi,%esi
jle    1214 <main+0x94>
xor    %ebx,%ebx
lea    0xe3a(%rip),%r15
lea    0xc(%rsp),%r12
xchg   %ax,%ax
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <fscanf@plt>
mov    0xc(%rsp),%eax
mov    %eax,(%r14,%rbx,4)
add    $0x1,%rbx
movslq 0x8(%rsp),%rsi
cmp    %rsi,%rbx
jl     11f0 <main+0x70>
mov    %r14,%rdi
call   1090 <thePrintf@plt>
mov    0x8(%rsp),%esi
mov    %r14,%rdi
call   1040 <heapSortInc@plt>
mov    0x8(%rsp),%esi
mov    %r14,%rdi
call   1090 <thePrintf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <getchar@plt>
jmp    1273 <main+0xf3>
mov    0x2d92(%rip),%rax
mov    (%rax),%edi
lea    0xdb9(%rip),%rsi
jmp    1269 <main+0xe9>
mov    0x2d80(%rip),%rax
mov    (%rax),%edi
lea    0xdbd(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"randNums.txt\00"
@.str.1 = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.2 = [19 x i8] c"File Open Error.\0D\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [22 x i8] c"Malloc Array Error.\0D\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [128 x i8]
store i32 0, i32* %1
%8 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %2
%9 = load i32*, i32** %2
%10 = icmp eq i32* null, %9
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %57
14: ; preds = %0
%15 = load i32*, i32** %2
%16 = call i32 @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = mul i64 %18, 4
%20 = trunc i64 %19 to i32
%21 = call i64 @malloc(i32 %20)
%22 = inttoptr i64 %21 to i32*
store i32* %22, i32** %3
%23 = load i32*, i32** %3
%24 = icmp eq i32* null, %23
br i1 %24, label %25, label %28
25: ; preds = %14
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %1
br label %57
28: ; preds = %14
store i32 0, i32* %5
br label %29
29: ; preds = %41, %28
%30 = load i32, i32* %5
%31 = load i32, i32* %4
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %44
33: ; preds = %29
%34 = load i32*, i32** %2
%35 = call i32 @fscanf(i32* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %6)
%36 = load i32, i32* %6
%37 = load i32*, i32** %3
%38 = load i32, i32* %5
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %37, i64 %39
store i32 %36, i32* %40
br label %41
41: ; preds = %33
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
store i32 %43, i32* %5
br label %29
44: ; preds = %29
%45 = load i32*, i32** %3
%46 = load i32, i32* %4
%47 = call i32 @thePrintf(i32* %45, i32 %46)
%48 = load i32*, i32** %3
%49 = load i32, i32* %4
%50 = call i32 @heapSortInc(i32* %48, i32 %49)
%51 = load i32*, i32** %3
%52 = load i32, i32* %4
%53 = call i32 @thePrintf(i32* %51, i32 %52)
%54 = load i32*, i32** %3
%55 = call i32 @free(i32* %54)
%56 = call i32 (...) @getchar()
store i32 0, i32* %1
br label %57
57: ; preds = %44, %25, %11
%58 = load i32, i32* %1
ret i32 %58
}

LLVM IR (-O2):
@.str = [13 x i8] c"randNums.txt\00"
@.str.1 = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.2 = [19 x i8] c"File Open Error.\0D\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [22 x i8] c"Malloc Array Error.\0D\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %41
10: ; preds = %0
%11 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%12 = load i32, i32* %1
%13 = shl i32 %12, 2
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i32*
%16 = icmp eq i64 %14, 0
br i1 %16, label %20, label %17
17: ; preds = %10
%18 = load i32, i32* %1
%19 = icmp sgt i32 %18, 0
br i1 %19, label %23, label %32
20: ; preds = %10
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %41
23: ; preds = %17, %23
%24 = phi i64 [ %28, %23 ], [ 0, %17 ]
%25 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%26 = load i32, i32* %2
%27 = getelementptr inbounds i32, i32* %15, i64 %24
store i32 %26, i32* %27
%28 = add nuw nsw i64 %24, 1
%29 = load i32, i32* %1
%30 = sext i32 %29 to i64
%31 = icmp slt i64 %28, %30
br i1 %31, label %23, label %32
32: ; preds = %23, %17
%33 = phi i32 [ %18, %17 ], [ %29, %23 ]
%34 = call i32 @thePrintf(i32* %15, i32 %33)
%35 = load i32, i32* %1
%36 = call i32 @heapSortInc(i32* %15, i32 %35)
%37 = load i32, i32* %1
%38 = call i32 @thePrintf(i32* %15, i32 %37)
%39 = call i32 @free(i32* %15)
%40 = call i32 (...) @getchar()
br label %41
41: ; preds = %32, %20, %7
%42 = phi i32 [ -1, %7 ], [ -1, %20 ], [ 0, %32 ]
ret i32 %42
}