#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 */
size_t parent(int);
int /*<<< orphan*/ printf(char *);
void heap_increase_key(int *A, int i, int key) {
  if (key < A[i]) {
    printf("Error increasing key.\n");
    return;
  }
  A[i] = key;
  while (i > 1 && A[parent(i)] < A[i]) {
    int temp = A[i];
    A[i] = A[parent(i)];
    A[parent(i)] = temp;
    i = parent(i);
  }
}


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)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%rcx
movslq -0xc(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    1157 <heap_increase_key+0x37>
lea    0xeb3(%rip),%rdi
call   1040 <printf@plt>
jmp    1215 <heap_increase_key+0xf5>
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
xor    %eax,%eax
cmpl   $0x1,-0xc(%rbp)
mov    %al,-0x15(%rbp)
jle    119f <heap_increase_key+0x7f>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <parent@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
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    11af <heap_increase_key+0x8f>
jmp    1215 <heap_increase_key+0xf5>
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),%edi
call   1030 <parent@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
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),%edi
call   1030 <parent@plt>
mov    -0x2c(%rbp),%edx
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    %edx,(%rax,%rcx,4)
mov    -0xc(%rbp),%edi
call   1030 <parent@plt>
mov    %eax,-0xc(%rbp)
jmp    1165 <heap_increase_key+0x45>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<heap_increase_key>:
push   %rbp
push   %r14
push   %rbx
movslq %esi,%rax
cmp    %edx,(%rdi,%rax,4)
jle    113c <heap_increase_key+0x1c>
lea    0xecd(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <puts@plt>
mov    %rdi,%r14
mov    %edx,(%rdi,%rax,4)
cmp    $0x2,%eax
jl     118c <heap_increase_key+0x6c>
mov    %esi,%ebx
nopl   0x0(%rax)
mov    %ebx,%edi
call   1030 <parent@plt>
mov    %ebx,%ebx
mov    (%r14,%rbx,4),%ebp
cmp    %ebp,(%r14,%rax,4)
jge    118c <heap_increase_key+0x6c>
mov    %ebx,%edi
call   1030 <parent@plt>
mov    (%r14,%rax,4),%eax
mov    %eax,(%r14,%rbx,4)
mov    %ebx,%edi
call   1030 <parent@plt>
mov    %ebp,(%r14,%rax,4)
mov    %ebx,%edi
call   1030 <parent@plt>
mov    %rax,%rbx
cmp    $0x1,%ebx
jg     1150 <heap_increase_key+0x30>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Error increasing key.\0A\00"
define void @heap_increase_key(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 ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %63
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 = %40, %17
%24 = load i32, i32* %5
%25 = icmp sgt i32 %24, 1
br i1 %25, label %26, label %38
26: ; preds = %23
%27 = load i32*, i32** %4
%28 = load i32, i32* %5
%29 = call i64 @parent(i32 %28)
%30 = getelementptr inbounds i32, i32* %27, i64 %29
%31 = load i32, i32* %30
%32 = load i32*, i32** %4
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
%36 = load i32, i32* %35
%37 = icmp slt i32 %31, %36
br label %38
38: ; preds = %26, %23
%39 = phi i1 [ false, %23 ], [ %37, %26 ]
br i1 %39, label %40, label %63
40: ; preds = %38
%41 = load i32*, i32** %4
%42 = load i32, i32* %5
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
%45 = load i32, i32* %44
store i32 %45, i32* %7
%46 = load i32*, i32** %4
%47 = load i32, i32* %5
%48 = call i64 @parent(i32 %47)
%49 = getelementptr inbounds i32, i32* %46, i64 %48
%50 = load i32, i32* %49
%51 = load i32*, i32** %4
%52 = load i32, i32* %5
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i32, i32* %51, i64 %53
store i32 %50, i32* %54
%55 = load i32, i32* %7
%56 = load i32*, i32** %4
%57 = load i32, i32* %5
%58 = call i64 @parent(i32 %57)
%59 = getelementptr inbounds i32, i32* %56, i64 %58
store i32 %55, i32* %59
%60 = load i32, i32* %5
%61 = call i64 @parent(i32 %60)
%62 = trunc i64 %61 to i32
store i32 %62, i32* %5
br label %23
63: ; preds = %15, %38
ret void
}

LLVM IR (-O2):
@str = [22 x i8] c"Error increasing key.\00"
define void @heap_increase_key(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 ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %30
10: ; preds = %3
store i32 %2, i32* %5
%11 = icmp sgt i32 %1, 1
br i1 %11, label %12, label %30
12: ; preds = %10, %21
%13 = phi i32 [ %28, %21 ], [ %1, %10 ]
%14 = tail call i64 @parent(i32 %13)
%15 = getelementptr inbounds i32, i32* %0, i64 %14
%16 = load i32, i32* %15
%17 = zext i32 %13 to i64
%18 = getelementptr inbounds i32, i32* %0, i64 %17
%19 = load i32, i32* %18
%20 = icmp slt i32 %16, %19
br i1 %20, label %21, label %30
21: ; preds = %12
%22 = tail call i64 @parent(i32 %13)
%23 = getelementptr inbounds i32, i32* %0, i64 %22
%24 = load i32, i32* %23
store i32 %24, i32* %18
%25 = tail call i64 @parent(i32 %13)
%26 = getelementptr inbounds i32, i32* %0, i64 %25
store i32 %19, i32* %26
%27 = tail call i64 @parent(i32 %13)
%28 = trunc i64 %27 to i32
%29 = icmp sgt i32 %28, 1
br i1 %29, label %12, label %30
30: ; preds = %12, %21, %10, %8
ret void
}