#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 */
typedef scalar_t__ uint32_t;
struct heap {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ heap_add(struct heap *, scalar_t__ *);
int /*<<< orphan*/ heap_full(struct heap *);
scalar_t__ *heap_get(struct heap *);
int /*<<< orphan*/ heap_pop(struct heap *);
void __test_head_add_gt(struct heap *h, uint32_t v) {
  if (!heap_full(h)) {
    heap_add(h, &v);
  } else {
    uint32_t *min = heap_get(h);
    if (*min < v) {
      heap_pop(h);
      heap_add(h, &v);
    }
  }
}


x86 assembly (clang, -O0):
<__test_head_add_gt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <heap_full@plt>
cmp    $0x0,%eax
jne    1174 <__test_head_add_gt+0x34>
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <heap_add@plt>
jmp    11ad <__test_head_add_gt+0x6d>
mov    -0x8(%rbp),%rdi
call   1050 <heap_get@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
cmp    -0x10(%rbp),%rax
jge    11a8 <__test_head_add_gt+0x68>
mov    -0x8(%rbp),%rdi
call   1060 <heap_pop@plt>
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <heap_add@plt>
jmp    11ad <__test_head_add_gt+0x6d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__test_head_add_gt>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,(%rsp)
call   1040 <heap_full@plt>
test   %eax,%eax
je     116c <__test_head_add_gt+0x2c>
mov    %rbx,%rdi
call   1050 <heap_get@plt>
cmp    %r14,(%rax)
jge    1177 <__test_head_add_gt+0x37>
mov    %rbx,%rdi
call   1060 <heap_pop@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1030 <heap_add@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.heap = type { i32 }
define void @__test_head_add_gt(%struct.heap* %0, i64 %1) {
%3 = alloca %struct.heap*
%4 = alloca i64
%5 = alloca i64*
store %struct.heap* %0, %struct.heap** %3
store i64 %1, i64* %4
%6 = load %struct.heap*, %struct.heap** %3
%7 = call i32 @heap_full(%struct.heap* %6)
%8 = icmp ne i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load %struct.heap*, %struct.heap** %3
%11 = call i32 @heap_add(%struct.heap* %10, i64* %4)
br label %25
12: ; preds = %2
%13 = load %struct.heap*, %struct.heap** %3
%14 = call i64* @heap_get(%struct.heap* %13)
store i64* %14, i64** %5
%15 = load i64*, i64** %5
%16 = load i64, i64* %15
%17 = load i64, i64* %4
%18 = icmp slt i64 %16, %17
br i1 %18, label %19, label %24
19: ; preds = %12
%20 = load %struct.heap*, %struct.heap** %3
%21 = call i32 @heap_pop(%struct.heap* %20)
%22 = load %struct.heap*, %struct.heap** %3
%23 = call i32 @heap_add(%struct.heap* %22, i64* %4)
br label %24
24: ; preds = %19, %12
br label %25
25: ; preds = %24, %9
ret void
}

LLVM IR (-O2):
%struct.heap = type { i32 }
define void @__test_head_add_gt(%struct.heap* %0, i64 %1) {
%3 = alloca i64
store i64 %1, i64* %3
%4 = tail call i32 @heap_full(%struct.heap* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %12, label %6
6: ; preds = %2
%7 = tail call i64* @heap_get(%struct.heap* %0)
%8 = load i64, i64* %7
%9 = icmp slt i64 %8, %1
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = tail call i32 @heap_pop(%struct.heap* %0)
br label %12
12: ; preds = %2, %10
%13 = call i32 @heap_add(%struct.heap* %0, i64* %3)
br label %14
14: ; preds = %12, %6
ret void
}