#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 */
struct Heap {
  int dummy;
};

/* Variables and functions */
struct Heap *createHeap();
int /*<<< orphan*/ freeHeap(struct Heap **);
int /*<<< orphan*/ insertHNode(struct Heap *, char *, int *);
int /*<<< orphan*/ printHeap(struct Heap *);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int main() {
  struct Heap *heap = createHeap();
  int i;
  int a[] = {33, 5, 1, 4, 20, 17, 31, 35, 99};
  for (i = 0; i < 9; ++i) {
    char tmp[3] = "";
    snprintf(tmp, 3, "%d", a[i]);
    insertHNode(heap, tmp, &i);
  }
  printHeap(heap);
  freeHeap(&heap);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <createHeap@plt>
mov    %rax,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe6b(%rip),%rsi
mov    $0x24,%edx
call   1070 <memcpy@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x9,-0x14(%rbp)
jge    11fc <main+0x8c>
lea    -0x43(%rbp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1060 <memset@plt>
lea    -0x43(%rbp),%rdi
movslq -0x14(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%ecx
mov    $0x3,%esi
lea    0xe4c(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x43(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1090 <insertHNode@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a6 <main+0x36>
mov    -0x10(%rbp),%rdi
call   1030 <printHeap@plt>
lea    -0x10(%rbp),%rdi
call   1080 <freeHeap@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <createHeap@plt>
mov    %rax,%r15
mov    %rax,0x10(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xe82(%rip),%r13
lea    0xe9f(%rip),%r14
lea    0xc(%rsp),%rbx
lea    0x8(%rsp),%r12
nop
movb   $0x0,0xe(%rsp)
movw   $0x0,0xc(%rsp)
movslq %ebp,%rax
mov    0x0(%r13,%rax,4),%ecx
mov    %rbx,%rdi
mov    $0x3,%esi
mov    %r14,%rdx
call   1040 <snprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1070 <insertHNode@plt>
mov    0x8(%rsp),%eax
lea    0x1(%rax),%ebp
mov    %ebp,0x8(%rsp)
cmp    $0x8,%eax
jl     1190 <main+0x40>
mov    %r15,%rdi
call   1030 <printHeap@plt>
lea    0x10(%rsp),%rdi
call   1060 <freeHeap@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.Heap = type { i32 }
@__const.main.a = [9 x i32] [i32 33, i32 5, i32 1, i32 4, i32 20, i32 17, i32 31, i32 35, i32 99]
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.Heap*
%3 = alloca i32
%4 = alloca [9 x i32]
%5 = alloca [3 x i8]
store i32 0, i32* %1
%6 = call %struct.Heap* (...) @createHeap()
store %struct.Heap* %6, %struct.Heap** %2
%7 = bitcast [9 x i32]* %4 to i8*
store i32 0, i32* %3
br label %8
8: ; preds = %22, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 9
br i1 %10, label %11, label %25
11: ; preds = %8
%12 = bitcast [3 x i8]* %5 to i8*
%13 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [9 x i32], [9 x i32]* %4, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = call i32 @snprintf(i8* %13, i32 3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load %struct.Heap*, %struct.Heap** %2
%20 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%21 = call i32 @insertHNode(%struct.Heap* %19, i8* %20, i32* %3)
br label %22
22: ; preds = %11
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %8
25: ; preds = %8
%26 = load %struct.Heap*, %struct.Heap** %2
%27 = call i32 @printHeap(%struct.Heap* %26)
%28 = call i32 @freeHeap(%struct.Heap** %2)
ret i32 0
}

LLVM IR (-O2):
%struct.Heap = type { i32 }
@__const.main.a = [9 x i32] [i32 33, i32 5, i32 1, i32 4, i32 20, i32 17, i32 31, i32 35, i32 99]
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca %struct.Heap*
%2 = alloca i32
%3 = alloca [3 x i8]
%4 = bitcast %struct.Heap** %1 to i8*
%5 = tail call %struct.Heap* (...) @createHeap()
store %struct.Heap* %5, %struct.Heap** %1
%6 = bitcast i32* %2 to i8*
%7 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
store i32 0, i32* %2
br label %8
8: ; preds = %0, %8
%9 = phi i32 [ 0, %0 ], [ %16, %8 ]
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [9 x i32], [9 x i32]* @__const.main.a, i64 0, i64 %10
%12 = load i32, i32* %11
%13 = call i32 @snprintf(i8* %7, i32 3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = call i32 @insertHNode(%struct.Heap* %5, i8* %7, i32* %2)
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
store i32 %16, i32* %2
%17 = icmp slt i32 %15, 8
br i1 %17, label %8, label %18
18: ; preds = %8
%19 = call i32 @printHeap(%struct.Heap* %5)
%20 = call i32 @freeHeap(%struct.Heap** %1)
ret i32 0
}