#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 parent(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ swap(int *, int, int);
void heap_increase_key(int *A, int i, int key) {
  if (key < A[i]) {
    printf("new key is smaller");
    return;
  }
  A[i] = key;
  while (i > 1 && A[parent(i) < A[i]]) {
    swap(A, parent(i), i);
    i = parent(i);
  }
}


x86 assembly (clang, -O0):
<heap_increase_key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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    1167 <heap_increase_key+0x37>
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
jmp    11f9 <heap_increase_key+0xc9>
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,-0x11(%rbp)
jle    11bb <heap_increase_key+0x8b>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <parent@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%rdx
movslq -0xc(%rbp),%rsi
cmp    (%rdx,%rsi,4),%ecx
setl   %cl
and    $0x1,%cl
movzbl %cl,%ecx
movslq %ecx,%rcx
cmpl   $0x0,(%rax,%rcx,4)
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    11cb <heap_increase_key+0x9b>
jmp    11f9 <heap_increase_key+0xc9>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <parent@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
mov    -0xc(%rbp),%edx
call   1050 <swap@plt>
mov    -0xc(%rbp),%edi
call   1030 <parent@plt>
mov    %eax,-0xc(%rbp)
jmp    1175 <heap_increase_key+0x45>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<heap_increase_key>:
push   %rbp
push   %rbx
push   %rax
movslq %esi,%rax
cmp    %edx,(%rdi,%rax,4)
jle    114d <heap_increase_key+0x1d>
lea    0xebe(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <printf@plt>
mov    %rdi,%rbx
mov    %edx,(%rdi,%rax,4)
cmp    $0x2,%eax
jl     1198 <heap_increase_key+0x68>
mov    %esi,%ebp
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1030 <parent@plt>
mov    %ebp,%ecx
xor    %edx,%edx
cmp    (%rbx,%rcx,4),%eax
setl   %dl
cmpl   $0x0,(%rbx,%rdx,4)
je     1198 <heap_increase_key+0x68>
mov    %ebp,%edi
call   1030 <parent@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    %ebp,%edx
call   1050 <swap@plt>
mov    %ebp,%edi
call   1030 <parent@plt>
mov    %eax,%ebp
cmp    $0x1,%eax
jg     1160 <heap_increase_key+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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