#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 ssize_t;

/* Variables and functions */
int /*<<< orphan*/ list_shiftDown(size_t, void *, int, int,
                                  int (*)(void const *, void const *));
void list_heapify_real(void *const _list, size_t objectsize,
                       int (*compare)(const void *, const void *)) {
  struct {
    void *list;
    ssize_t size;
    size_t maxlength;
    int shmfd;
    void *oldmem;
  } *list = _list;
  ssize_t start;
  for (start = (list->size - 2) / 2; start >= 0; start--)
    list_shiftDown(objectsize, list->list, start, list->size - 1, compare);
}


x86 assembly (clang, -O0):
<list_heapify_real>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%eax
sub    $0x2,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     117a <list_heapify_real+0x6a>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%ecx
sub    $0x1,%ecx
mov    -0x18(%rbp),%r8
call   1030 <list_shiftDown@plt>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    1141 <list_heapify_real+0x31>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<list_heapify_real>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    0x8(%rdi),%r13d
test   %r13d,%r13d
jle    1182 <list_heapify_real+0x72>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
lea    -0x2(%r13),%eax
shr    $0x1f,%eax
lea    (%rax,%r13,1),%ebx
add    $0xfffffffe,%ebx
sar    %ebx
mov    (%rdi),%rsi
lea    -0x1(%r13),%ecx
mov    %r15,%rdi
mov    %ebx,%edx
mov    %r14,%r8
call   1030 <list_shiftDown@plt>
cmp    $0x4,%r13d
jl     1182 <list_heapify_real+0x72>
add    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
lea    -0x2(%rbx),%edx
mov    0x8(%r12),%ecx
mov    (%r12),%rsi
add    $0xffffffff,%ecx
mov    %r15,%rdi
mov    %r14,%r8
call   1030 <list_shiftDown@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
jg     1160 <list_heapify_real+0x50>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.anon = type { i8*, i32, i64, i32, i8* }
define void @list_heapify_real(i8* %0, i64 %1, i32 (i8*, i8*)* %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32 (i8*, i8*)*
%7 = alloca %struct.anon*
%8 = alloca i32
store i8* %0, i8** %4
store i64 %1, i64* %5
store i32 (i8*, i8*)* %2, i32 (i8*, i8*)** %6
%9 = load i8*, i8** %4
%10 = bitcast i8* %9 to %struct.anon*
store %struct.anon* %10, %struct.anon** %7
%11 = load %struct.anon*, %struct.anon** %7
%12 = getelementptr inbounds %struct.anon, %struct.anon* %11, i32 0, i32 1
%13 = load i32, i32* %12
%14 = sub nsw i32 %13, 2
%15 = sdiv i32 %14, 2
store i32 %15, i32* %8
br label %16
16: ; preds = %31, %3
%17 = load i32, i32* %8
%18 = icmp sge i32 %17, 0
br i1 %18, label %19, label %34
19: ; preds = %16
%20 = load i64, i64* %5
%21 = load %struct.anon*, %struct.anon** %7
%22 = getelementptr inbounds %struct.anon, %struct.anon* %21, i32 0, i32 0
%23 = load i8*, i8** %22
%24 = load i32, i32* %8
%25 = load %struct.anon*, %struct.anon** %7
%26 = getelementptr inbounds %struct.anon, %struct.anon* %25, i32 0, i32 1
%27 = load i32, i32* %26
%28 = sub nsw i32 %27, 1
%29 = load i32 (i8*, i8*)*, i32 (i8*, i8*)** %6
%30 = call i32 @list_shiftDown(i64 %20, i8* %23, i32 %24, i32 %28, i32 (i8*, i8*)* %29)
br label %31
31: ; preds = %19
%32 = load i32, i32* %8
%33 = add nsw i32 %32, -1
store i32 %33, i32* %8
br label %16
34: ; preds = %16
ret void
}

LLVM IR (-O2):
define void @list_heapify_real(i8* nocapture %0, i64 %1, i32 (i8*, i8*)* %2) {
%4 = getelementptr inbounds i8, i8* %0, i64 8
%5 = bitcast i8* %4 to i32*
%6 = load i32, i32* %5
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %24
8: ; preds = %3
%9 = add nsw i32 %6, -2
%10 = sdiv i32 %9, 2
%11 = bitcast i8* %0 to i8**
%12 = load i8*, i8** %11
%13 = add nsw i32 %6, -1
%14 = tail call i32 @list_shiftDown(i64 %1, i8* %12, i32 %10, i32 %13, i32 (i8*, i8*)* %2)
%15 = icmp sgt i32 %6, 3
br i1 %15, label %16, label %24
16: ; preds = %8, %16
%17 = phi i32 [ %18, %16 ], [ %10, %8 ]
%18 = add nsw i32 %17, -1
%19 = load i32, i32* %5
%20 = load i8*, i8** %11
%21 = add nsw i32 %19, -1
%22 = tail call i32 @list_shiftDown(i64 %1, i8* %20, i32 %18, i32 %21, i32 (i8*, i8*)* %2)
%23 = icmp sgt i32 %17, 1
br i1 %23, label %16, label %24
24: ; preds = %16, %8, %3
ret void
}