#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*/ percolate_down(int, double *, int *, int *, int);
int /*<<< orphan*/ percolate_up(int, double *, int *, int *, int);
void update(int node, double *data, int *INDEX, int *INDEX2, int N) {
  int parent = (node - 1) >> 1;
  if (node > 0 && data[node] < data[parent])
    percolate_up(node, data, INDEX, INDEX2, N);
  else
    percolate_down(node, data, INDEX, INDEX2, N);
}


x86 assembly (clang, -O0):
<update>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
sar    $0x1,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    1192 <update+0x72>
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    1192 <update+0x72>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
call   1030 <percolate_up@plt>
jmp    11aa <update+0x8a>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
call   1040 <percolate_down@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update>:
test   %edi,%edi
jle    113e <update+0x1e>
lea    -0x1(%rdi),%eax
shr    %eax
mov    %edi,%r9d
movsd  (%rsi,%rax,8),%xmm0
ucomisd (%rsi,%r9,8),%xmm0
jbe    113e <update+0x1e>
jmp    1030 <percolate_up@plt>
jmp    1040 <percolate_down@plt>

LLVM IR (-O0):
define void @update(i32 %0, double* %1, i32* %2, i32* %3, i32 %4) {
%6 = alloca i32
%7 = alloca double*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %6
store double* %1, double** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store i32 %4, i32* %10
%12 = load i32, i32* %6
%13 = sub nsw i32 %12, 1
%14 = ashr i32 %13, 1
store i32 %14, i32* %11
%15 = load i32, i32* %6
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %36
17: ; preds = %5
%18 = load double*, double** %7
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %18, i64 %20
%22 = load double, double* %21
%23 = load double*, double** %7
%24 = load i32, i32* %11
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
%28 = fcmp olt double %22, %27
br i1 %28, label %29, label %36
29: ; preds = %17
%30 = load i32, i32* %6
%31 = load double*, double** %7
%32 = load i32*, i32** %8
%33 = load i32*, i32** %9
%34 = load i32, i32* %10
%35 = call i32 @percolate_up(i32 %30, double* %31, i32* %32, i32* %33, i32 %34)
br label %43
36: ; preds = %17, %5
%37 = load i32, i32* %6
%38 = load double*, double** %7
%39 = load i32*, i32** %8
%40 = load i32*, i32** %9
%41 = load i32, i32* %10
%42 = call i32 @percolate_down(i32 %37, double* %38, i32* %39, i32* %40, i32 %41)
br label %43
43: ; preds = %36, %29
ret void
}

LLVM IR (-O2):
define void @update(i32 %0, double* %1, i32* %2, i32* %3, i32 %4) {
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %19
7: ; preds = %5
%8 = add nsw i32 %0, -1
%9 = lshr i32 %8, 1
%10 = zext i32 %0 to i64
%11 = getelementptr inbounds double, double* %1, i64 %10
%12 = load double, double* %11
%13 = zext i32 %9 to i64
%14 = getelementptr inbounds double, double* %1, i64 %13
%15 = load double, double* %14
%16 = fcmp olt double %12, %15
br i1 %16, label %17, label %19
17: ; preds = %7
%18 = tail call i32 @percolate_up(i32 %0, double* %1, i32* %2, i32* %3, i32 %4)
br label %21
19: ; preds = %7, %5
%20 = tail call i32 @percolate_down(i32 %0, double* %1, i32* %2, i32* %3, i32 %4)
br label %21
21: ; preds = %19, %17
ret void
}