#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*/ exit(int);
size_t parent(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ swap(double *, int, size_t);
void heap_increase_key(double *srcdata, int len, int idx, double dValue) {
  if (srcdata[idx] < dValue) {
    printf("new key is smaller than current key.\n");
    exit(1);
  }
  srcdata[idx] = dValue;
  while (idx > 0 && srcdata[parent(idx)] < srcdata[idx]) {
    swap(srcdata, idx, parent(idx));
    idx = parent(idx);
  }
}


x86 assembly (clang, -O0):
<heap_increase_key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1189 <heap_increase_key+0x49>
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
xor    %eax,%eax
cmpl   $0x0,-0x10(%rbp)
mov    %al,-0x19(%rbp)
jle    11dd <heap_increase_key+0x9d>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <parent@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11ed <heap_increase_key+0xad>
jmp    1222 <heap_increase_key+0xe2>
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <parent@plt>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    %rax,%rdx
call   1060 <swap@plt>
mov    -0x10(%rbp),%edi
call   1030 <parent@plt>
mov    %eax,-0x10(%rbp)
jmp    119b <heap_increase_key+0x5b>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<heap_increase_key>:
push   %r14
push   %rbx
push   %rax
movslq %edx,%rax
ucomisd (%rdi,%rax,8),%xmm0
ja     11a1 <heap_increase_key+0x61>
mov    %rdi,%r14
movsd  %xmm0,(%rdi,%rax,8)
test   %eax,%eax
jle    1199 <heap_increase_key+0x59>
mov    %edx,%ebx
nopl   0x0(%rax)
mov    %ebx,%edi
call   1030 <parent@plt>
mov    %ebx,%ecx
movsd  (%r14,%rcx,8),%xmm0
ucomisd (%r14,%rax,8),%xmm0
jbe    1199 <heap_increase_key+0x59>
mov    %ebx,%edi
call   1030 <parent@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %rax,%rdx
call   1060 <swap@plt>
mov    %ebx,%edi
call   1030 <parent@plt>
mov    %rax,%rbx
test   %ebx,%ebx
jg     1160 <heap_increase_key+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe58(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [38 x i8] c"new key is smaller than current key.\0A\00"
define void @heap_increase_key(double* %0, i32 %1, i32 %2, double %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
store double* %0, double** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store double %3, double* %8
%9 = load double*, double** %5
%10 = load i32, i32* %7
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds double, double* %9, i64 %11
%13 = load double, double* %12
%14 = load double, double* %8
%15 = fcmp olt double %13, %14
br i1 %15, label %16, label %19
16: ; preds = %4
%17 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %4
%20 = load double, double* %8
%21 = load double*, double** %5
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %21, i64 %23
store double %20, double* %24
br label %25
25: ; preds = %42, %19
%26 = load i32, i32* %7
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %40
28: ; preds = %25
%29 = load double*, double** %5
%30 = load i32, i32* %7
%31 = call i64 @parent(i32 %30)
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = load double, double* %32
%34 = load double*, double** %5
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
%38 = load double, double* %37
%39 = fcmp olt double %33, %38
br label %40
40: ; preds = %28, %25
%41 = phi i1 [ false, %25 ], [ %39, %28 ]
br i1 %41, label %42, label %51
42: ; preds = %40
%43 = load double*, double** %5
%44 = load i32, i32* %7
%45 = load i32, i32* %7
%46 = call i64 @parent(i32 %45)
%47 = call i32 @swap(double* %43, i32 %44, i64 %46)
%48 = load i32, i32* %7
%49 = call i64 @parent(i32 %48)
%50 = trunc i64 %49 to i32
store i32 %50, i32* %7
br label %25
51: ; preds = %40
ret void
}

LLVM IR (-O2):
@str = [37 x i8] c"new key is smaller than current key.\00"
define void @heap_increase_key(double* %0, i32 %1, i32 %2, double %3) {
%5 = sext i32 %2 to i64
%6 = getelementptr inbounds double, double* %0, i64 %5
%7 = load double, double* %6
%8 = fcmp olt double %7, %3
br i1 %8, label %9, label %12
9: ; preds = %4
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %4
store double %3, double* %6
%13 = icmp sgt i32 %2, 0
br i1 %13, label %14, label %29
14: ; preds = %12, %23
%15 = phi i32 [ %27, %23 ], [ %2, %12 ]
%16 = tail call i64 @parent(i32 %15)
%17 = getelementptr inbounds double, double* %0, i64 %16
%18 = load double, double* %17
%19 = zext i32 %15 to i64
%20 = getelementptr inbounds double, double* %0, i64 %19
%21 = load double, double* %20
%22 = fcmp olt double %18, %21
br i1 %22, label %23, label %29
23: ; preds = %14
%24 = tail call i64 @parent(i32 %15)
%25 = tail call i32 @swap(double* %0, i32 %15, i64 %24)
%26 = tail call i64 @parent(i32 %15)
%27 = trunc i64 %26 to i32
%28 = icmp sgt i32 %27, 0
br i1 %28, label %14, label %29
29: ; preds = %14, %23, %12
ret void
}