#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*/ assert(int);
int /*<<< orphan*/ bubble(size_t, void const *, void *, size_t,
                          int (*)(void const *, void const *));
void *get_node(void *, int /*<<< orphan*/, size_t);
void *memcpy(void *, void const *, size_t);
void *bheap_insert(void const *src, void *heap, size_t nmemb, size_t size,
                   int (*compar)(void const *, void const *)) {
  void *dest;
  if (src == NULL) {
    return NULL;
  }
  assert(heap != 0);
  assert(size > 0);
  assert(compar != 0);
  dest = get_node(heap, bubble(nmemb, src, heap, size, compar), size);
  return memcpy(dest, src, size);
}


x86 assembly (clang, -O0):
<bheap_insert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1174 <bheap_insert+0x34>
movq   $0x0,-0x8(%rbp)
jmp    11fb <bheap_insert+0xbb>
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpq   $0x0,-0x28(%rbp)
seta   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpq   $0x0,-0x30(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
call   1030 <bubble@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%esi
mov    -0x28(%rbp),%rdx
call   1060 <get_node@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    %rdi,-0x40(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1050 <memcpy@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bheap_insert>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     11bd <bheap_insert+0x7d>
mov    %r8,%r12
mov    %rcx,%rbp
mov    %rdx,%r13
mov    %rsi,%r15
mov    %rdi,%r14
xor    %edi,%edi
test   %rsi,%rsi
setne  %dil
call   1040 <assert@plt>
xor    %edi,%edi
test   %rbp,%rbp
setne  %dil
call   1040 <assert@plt>
xor    %edi,%edi
test   %r12,%r12
setne  %dil
call   1040 <assert@plt>
mov    %r13,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbp,%rcx
mov    %r12,%r8
call   1030 <bubble@plt>
mov    %r15,%rdi
mov    %eax,%esi
mov    %rbp,%rdx
call   1060 <get_node@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1050 <memcpy@plt>
jmp    11bf <bheap_insert+0x7f>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @bheap_insert(i8* %0, i8* %1, i64 %2, i64 %3, i32 (i8*, i8*)* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i32 (i8*, i8*)*
%12 = alloca i8*
store i8* %0, i8** %7
store i8* %1, i8** %8
store i64 %2, i64* %9
store i64 %3, i64* %10
store i32 (i8*, i8*)* %4, i32 (i8*, i8*)** %11
%13 = load i8*, i8** %7
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %16
15: ; preds = %5
store i8* null, i8** %6
br label %41
16: ; preds = %5
%17 = load i8*, i8** %8
%18 = icmp ne i8* %17, null
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = load i64, i64* %10
%22 = icmp ugt i64 %21, 0
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = load i32 (i8*, i8*)*, i32 (i8*, i8*)** %11
%26 = icmp ne i32 (i8*, i8*)* %25, null
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = load i8*, i8** %8
%30 = load i64, i64* %9
%31 = load i8*, i8** %7
%32 = load i8*, i8** %8
%33 = load i64, i64* %10
%34 = load i32 (i8*, i8*)*, i32 (i8*, i8*)** %11
%35 = call i32 @bubble(i64 %30, i8* %31, i8* %32, i64 %33, i32 (i8*, i8*)* %34)
%36 = load i64, i64* %10
%37 = call i8* @get_node(i8* %29, i32 %35, i64 %36)
store i8* %37, i8** %12
%38 = load i8*, i8** %12
%39 = load i8*, i8** %7
%40 = load i64, i64* %10
store i8* %38, i8** %6
br label %41
41: ; preds = %16, %15
%42 = load i8*, i8** %6
ret i8* %42
}

LLVM IR (-O2):
define i8* @bheap_insert(i8* %0, i8* %1, i64 %2, i64 %3, i32 (i8*, i8*)* %4) {
%6 = icmp eq i8* %0, null
br i1 %6, label %19, label %7
7: ; preds = %5
%8 = icmp ne i8* %1, null
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = icmp ne i64 %3, 0
%12 = zext i1 %11 to i32
%13 = tail call i32 @assert(i32 %12)
%14 = icmp ne i32 (i8*, i8*)* %4, null
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
%17 = tail call i32 @bubble(i64 %2, i8* %0, i8* %1, i64 %3, i32 (i8*, i8*)* %4)
%18 = tail call i8* @get_node(i8* %1, i32 %17, i64 %3)
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %18, i8* align 1 %0, i64 %3, i1 false)
br label %19
19: ; preds = %5, %7
%20 = phi i8* [ %18, %7 ], [ null, %5 ]
ret i8* %20
}