#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*/ heap_initialize(void *, int, size_t,
                                   int (*)(void const *, void const *));
int /*<<< orphan*/ heap_up(int, void *, size_t,
                           int (*)(void const *, void const *));
void tieheap_to_heap(void *tieheap, int count, int heap_count, int count_target,
                     size_t size,
                     int (*compar)(const void *elt1, const void *elt2)) {
  int i;
  if (count < count_target)
    heap_initialize(tieheap, count, size, compar);
  else {
    for (i = heap_count + 1; i <= count; ++i)
      heap_up(i, tieheap, size, compar);
  }
}


x86 assembly (clang, -O0):
<tieheap_to_heap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1162 <tieheap_to_heap+0x42>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1030 <heap_initialize@plt>
jmp    119e <tieheap_to_heap+0x7e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1199 <tieheap_to_heap+0x79>
mov    -0x2c(%rbp),%edi
mov    -0x8(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1040 <heap_up@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    116b <tieheap_to_heap+0x4b>
jmp    119e <tieheap_to_heap+0x7e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tieheap_to_heap>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r9,%r14
mov    %r8,%r15
mov    %esi,%r13d
mov    %rdi,%r12
cmp    %ecx,%esi
jge    1153 <tieheap_to_heap+0x33>
mov    %r12,%rdi
mov    %r13d,%esi
mov    %r15,%rdx
mov    %r14,%rcx
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <heap_initialize@plt>
mov    %edx,%ebx
cmp    %r13d,%edx
jge    1183 <tieheap_to_heap+0x63>
neg    %r13d
add    $0x1,%ebx
mov    %ebx,%edi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1040 <heap_up@plt>
lea    (%rbx,%r13,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
jne    1160 <tieheap_to_heap+0x40>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @tieheap_to_heap(i8* %0, i32 %1, i32 %2, i32 %3, i64 %4, i32 (i8*, i8*)* %5) {
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
%12 = alloca i32 (i8*, i8*)*
%13 = alloca i32
store i8* %0, i8** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i64 %4, i64* %11
store i32 (i8*, i8*)* %5, i32 (i8*, i8*)** %12
%14 = load i32, i32* %8
%15 = load i32, i32* %10
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %23
17: ; preds = %6
%18 = load i8*, i8** %7
%19 = load i32, i32* %8
%20 = load i64, i64* %11
%21 = load i32 (i8*, i8*)*, i32 (i8*, i8*)** %12
%22 = call i32 @heap_initialize(i8* %18, i32 %19, i64 %20, i32 (i8*, i8*)* %21)
br label %40
23: ; preds = %6
%24 = load i32, i32* %9
%25 = add nsw i32 %24, 1
store i32 %25, i32* %13
br label %26
26: ; preds = %36, %23
%27 = load i32, i32* %13
%28 = load i32, i32* %8
%29 = icmp sle i32 %27, %28
br i1 %29, label %30, label %39
30: ; preds = %26
%31 = load i32, i32* %13
%32 = load i8*, i8** %7
%33 = load i64, i64* %11
%34 = load i32 (i8*, i8*)*, i32 (i8*, i8*)** %12
%35 = call i32 @heap_up(i32 %31, i8* %32, i64 %33, i32 (i8*, i8*)* %34)
br label %36
36: ; preds = %30
%37 = load i32, i32* %13
%38 = add nsw i32 %37, 1
store i32 %38, i32* %13
br label %26
39: ; preds = %26
br label %40
40: ; preds = %39, %17
ret void
}

LLVM IR (-O2):
define void @tieheap_to_heap(i8* %0, i32 %1, i32 %2, i32 %3, i64 %4, i32 (i8*, i8*)* %5) {
%7 = icmp slt i32 %1, %3
br i1 %7, label %10, label %8
8: ; preds = %6
%9 = icmp slt i32 %2, %1
br i1 %9, label %12, label %17
10: ; preds = %6
%11 = tail call i32 @heap_initialize(i8* %0, i32 %1, i64 %4, i32 (i8*, i8*)* %5)
br label %17
12: ; preds = %8, %12
%13 = phi i32 [ %14, %12 ], [ %2, %8 ]
%14 = add nsw i32 %13, 1
%15 = tail call i32 @heap_up(i32 %14, i8* %0, i64 %4, i32 (i8*, i8*)* %5)
%16 = icmp eq i32 %14, %1
br i1 %16, label %17, label %12
17: ; preds = %12, %8, %10
ret void
}