#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*/ printf(char *);
void HeapIncreaseKey(int A[], int i, int key) {
  if (key < A[i]) {
    printf("New key is smaller than current key.\n");
    return;
  }
  A[i] = key;
  while (i > 0 && A[i / 2] < A[i]) {
    int t = A[i];
    A[i] = A[i / 2];
    A[i / 2] = t;
    i = i / 2;
  }
}


x86 assembly (clang, -O0):
<HeapIncreaseKey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%rcx
movslq -0xc(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    1147 <HeapIncreaseKey+0x37>
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
jmp    1217 <HeapIncreaseKey+0x107>
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0x15(%rbp)
jle    1194 <HeapIncreaseKey+0x84>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x8(%rbp),%rcx
movslq -0xc(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
setl   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    11a4 <HeapIncreaseKey+0x94>
jmp    1217 <HeapIncreaseKey+0x107>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x2c(%rbp),%edx
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
jmp    1155 <HeapIncreaseKey+0x45>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HeapIncreaseKey>:
movslq %esi,%rax
cmp    %edx,(%rdi,%rax,4)
jle    1124 <HeapIncreaseKey+0x14>
lea    0xee1(%rip),%rdi
jmp    1030 <puts@plt>
mov    %edx,(%rdi,%rax,4)
test   %eax,%eax
jle    115a <HeapIncreaseKey+0x4a>
mov    %esi,%eax
mov    (%rdi,%rax,4),%r8d
mov    %esi,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
shr    %ecx
mov    (%rdi,%rcx,4),%edx
cmp    %r8d,%edx
jge    115a <HeapIncreaseKey+0x4a>
mov    %esi,%eax
mov    %edx,(%rdi,%rax,4)
mov    %r8d,(%rdi,%rcx,4)
cmp    $0x1,%esi
mov    %ecx,%esi
ja     1140 <HeapIncreaseKey+0x30>
ret

LLVM IR (-O0):
@.str = [38 x i8] c"New key is smaller than current key.\0A\00"
define void @HeapIncreaseKey(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = load i32*, i32** %4
%10 = load i32, i32* %5
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i32, i32* %9, i64 %11
%13 = load i32, i32* %12
%14 = icmp slt i32 %8, %13
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %65
17: ; preds = %3
%18 = load i32, i32* %6
%19 = load i32*, i32** %4
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
store i32 %18, i32* %22
br label %23
23: ; preds = %41, %17
%24 = load i32, i32* %5
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %39
26: ; preds = %23
%27 = load i32*, i32** %4
%28 = load i32, i32* %5
%29 = sdiv i32 %28, 2
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %27, i64 %30
%32 = load i32, i32* %31
%33 = load i32*, i32** %4
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %33, i64 %35
%37 = load i32, i32* %36
%38 = icmp slt i32 %32, %37
br label %39
39: ; preds = %26, %23
%40 = phi i1 [ false, %23 ], [ %38, %26 ]
br i1 %40, label %41, label %65
41: ; preds = %39
%42 = load i32*, i32** %4
%43 = load i32, i32* %5
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %42, i64 %44
%46 = load i32, i32* %45
store i32 %46, i32* %7
%47 = load i32*, i32** %4
%48 = load i32, i32* %5
%49 = sdiv i32 %48, 2
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32, i32* %47, i64 %50
%52 = load i32, i32* %51
%53 = load i32*, i32** %4
%54 = load i32, i32* %5
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i32, i32* %53, i64 %55
store i32 %52, i32* %56
%57 = load i32, i32* %7
%58 = load i32*, i32** %4
%59 = load i32, i32* %5
%60 = sdiv i32 %59, 2
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i32, i32* %58, i64 %61
store i32 %57, i32* %62
%63 = load i32, i32* %5
%64 = sdiv i32 %63, 2
store i32 %64, i32* %5
br label %23
65: ; preds = %15, %39
ret void
}

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