#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*/ shift_down(void *, int, int, int, int (*)(void *, void *));
void heapify_down(void *array, int asize, int esize,
                  int compare(void *key1, void *key2)) {
  int start = (asize - 2) / 2;
  while (start >= 0) {
    shift_down(array, start, asize - 1, esize, compare);
    start--;
  }
  return;
}


x86 assembly (clang, -O0):
<heapify_down>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     1168 <heapify_down+0x58>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
mov    -0x10(%rbp),%ecx
mov    -0x18(%rbp),%r8
call   1030 <shift_down@plt>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1137 <heapify_down+0x27>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<heapify_down>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %esi,%esi
jle    1157 <heapify_down+0x47>
mov    %rcx,%r14
mov    %edx,%r15d
mov    %esi,%ebx
mov    %rdi,%r12
lea    -0x2(%rbx),%eax
shr    $0x1f,%eax
lea    (%rbx,%rax,1),%ebp
add    $0xfffffffe,%ebp
sar    %ebp
add    $0xffffffff,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r15d,%ecx
mov    %r14,%r8
call   1030 <shift_down@plt>
add    $0xffffffff,%ebp
jb     1140 <heapify_down+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @heapify_down(i8* %0, i32 %1, i32 %2, i32 (i8*, i8*)* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32 (i8*, i8*)*
%9 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 (i8*, i8*)* %3, i32 (i8*, i8*)** %8
%10 = load i32, i32* %6
%11 = sub nsw i32 %10, 2
%12 = sdiv i32 %11, 2
store i32 %12, i32* %9
br label %13
13: ; preds = %16, %4
%14 = load i32, i32* %9
%15 = icmp sge i32 %14, 0
br i1 %15, label %16, label %26
16: ; preds = %13
%17 = load i8*, i8** %5
%18 = load i32, i32* %9
%19 = load i32, i32* %6
%20 = sub nsw i32 %19, 1
%21 = load i32, i32* %7
%22 = load i32 (i8*, i8*)*, i32 (i8*, i8*)** %8
%23 = call i32 @shift_down(i8* %17, i32 %18, i32 %20, i32 %21, i32 (i8*, i8*)* %22)
%24 = load i32, i32* %9
%25 = add nsw i32 %24, -1
store i32 %25, i32* %9
br label %13
26: ; preds = %13
ret void
}

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