#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 bheap_t {
  int dummy;
};

/* Variables and functions */
int bh_bigchild(struct bheap_t *, int);
int bh_primax(struct bheap_t *, int, int);
int /*<<< orphan*/ bh_swap(struct bheap_t *, int, int);
void bh_siftdown(struct bheap_t *bh, int node) {
  int swap;
  while (swap = bh_bigchild(bh, node), swap) {
    if (((bh_primax(bh, node, swap) == swap)) && (swap != node)) {
      bh_swap(bh, node, swap);
      node = swap;
    } else
      break;
  }
}


x86 assembly (clang, -O0):
<bh_siftdown>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <bh_bigchild@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11a0 <bh_siftdown+0x70>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <bh_primax@plt>
cmp    -0x10(%rbp),%eax
jne    1196 <bh_siftdown+0x66>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     1196 <bh_siftdown+0x66>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <bh_swap@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    119b <bh_siftdown+0x6b>
jmp    11a0 <bh_siftdown+0x70>
jmp    113f <bh_siftdown+0xf>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bh_siftdown>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %rdi,%r14
call   1040 <bh_bigchild@plt>
test   %eax,%eax
je     1182 <bh_siftdown+0x52>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %eax,%ebp
mov    %r14,%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1030 <bh_primax@plt>
cmp    %ebx,%ebp
je     1182 <bh_siftdown+0x52>
cmp    %ebp,%eax
jne    1182 <bh_siftdown+0x52>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1050 <bh_swap@plt>
mov    %r14,%rdi
mov    %ebp,%esi
call   1040 <bh_bigchild@plt>
mov    %ebp,%ebx
test   %eax,%eax
jne    1150 <bh_siftdown+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.bheap_t = type { i32 }
define void @bh_siftdown(%struct.bheap_t* %0, i32 %1) {
%3 = alloca %struct.bheap_t*
%4 = alloca i32
%5 = alloca i32
store %struct.bheap_t* %0, %struct.bheap_t** %3
store i32 %1, i32* %4
br label %6
6: ; preds = %30, %2
%7 = load %struct.bheap_t*, %struct.bheap_t** %3
%8 = load i32, i32* %4
%9 = call i32 @bh_bigchild(%struct.bheap_t* %7, i32 %8)
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %31
12: ; preds = %6
%13 = load %struct.bheap_t*, %struct.bheap_t** %3
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = call i32 @bh_primax(%struct.bheap_t* %13, i32 %14, i32 %15)
%17 = load i32, i32* %5
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %29
19: ; preds = %12
%20 = load i32, i32* %5
%21 = load i32, i32* %4
%22 = icmp ne i32 %20, %21
br i1 %22, label %23, label %29
23: ; preds = %19
%24 = load %struct.bheap_t*, %struct.bheap_t** %3
%25 = load i32, i32* %4
%26 = load i32, i32* %5
%27 = call i32 @bh_swap(%struct.bheap_t* %24, i32 %25, i32 %26)
%28 = load i32, i32* %5
store i32 %28, i32* %4
br label %30
29: ; preds = %19, %12
br label %31
30: ; preds = %23
br label %6
31: ; preds = %29, %6
ret void
}

LLVM IR (-O2):
%struct.bheap_t = type { i32 }
define void @bh_siftdown(%struct.bheap_t* %0, i32 %1) {
%3 = tail call i32 @bh_bigchild(%struct.bheap_t* %0, i32 %1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %16, label %5
5: ; preds = %2, %12
%6 = phi i32 [ %14, %12 ], [ %3, %2 ]
%7 = phi i32 [ %6, %12 ], [ %1, %2 ]
%8 = tail call i32 @bh_primax(%struct.bheap_t* %0, i32 %7, i32 %6)
%9 = icmp ne i32 %8, %6
%10 = icmp eq i32 %6, %7
%11 = or i1 %10, %9
br i1 %11, label %16, label %12
12: ; preds = %5
%13 = tail call i32 @bh_swap(%struct.bheap_t* %0, i32 %7, i32 %6)
%14 = tail call i32 @bh_bigchild(%struct.bheap_t* %0, i32 %6)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %5
16: ; preds = %12, %5, %2
ret void
}