#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 */
struct feed_heap {
  int dummy;
};
struct feed_client {
  int dummy;
};

/* Variables and functions */
struct feed_heap *feed_client_get_heap(struct feed_client *const);
int /*<<< orphan*/ feed_heap_free(struct feed_heap *, void *const);
void stub1(void *const);
void feed_object_destroy(struct feed_client *const p_client, void *const p_buf,
                         void (*p_cleanup_cb)(void *const p_buf)) {
  struct feed_heap *p_heap;
  p_heap = feed_client_get_heap(p_client);
  if (p_buf) {
    (*p_cleanup_cb)(p_buf);
    feed_heap_free(p_heap, p_buf);
  }
}


x86 assembly (clang, -O0):
<feed_object_destroy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <feed_client_get_heap@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1163 <feed_object_destroy+0x43>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rdi
call   *%rax
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <feed_heap_free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<feed_object_destroy>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
call   1030 <feed_client_get_heap@plt>
test   %rbx,%rbx
je     114e <feed_object_destroy+0x2e>
mov    %rax,%r15
mov    %rbx,%rdi
call   *%r14
mov    %r15,%rdi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <feed_heap_free@plt>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.feed_client = type { i32 }
%struct.feed_heap = type { i32 }
define void @feed_object_destroy(%struct.feed_client* %0, i8* %1, void (i8*)* %2) {
%4 = alloca %struct.feed_client*
%5 = alloca i8*
%6 = alloca void (i8*)*
%7 = alloca %struct.feed_heap*
store %struct.feed_client* %0, %struct.feed_client** %4
store i8* %1, i8** %5
store void (i8*)* %2, void (i8*)** %6
%8 = load %struct.feed_client*, %struct.feed_client** %4
%9 = call %struct.feed_heap* @feed_client_get_heap(%struct.feed_client* %8)
store %struct.feed_heap* %9, %struct.feed_heap** %7
%10 = load i8*, i8** %5
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %18
12: ; preds = %3
%13 = load void (i8*)*, void (i8*)** %6
%14 = load i8*, i8** %5
%15 = load %struct.feed_heap*, %struct.feed_heap** %7
%16 = load i8*, i8** %5
%17 = call i32 @feed_heap_free(%struct.feed_heap* %15, i8* %16)
br label %18
18: ; preds = %12, %3
ret void
}

LLVM IR (-O2):
%struct.feed_client = type { i32 }
%struct.feed_heap = type { i32 }
define void @feed_object_destroy(%struct.feed_client* %0, i8* %1, void (i8*)* nocapture %2) {
%4 = tail call %struct.feed_heap* @feed_client_get_heap(%struct.feed_client* %0)
%5 = icmp eq i8* %1, null
br i1 %5, label %8, label %6
6: ; preds = %3
tail call void %2(i8* %1)
%7 = tail call i32 @feed_heap_free(%struct.feed_heap* %4, i8* %1)
br label %8
8: ; preds = %6, %3
ret void
}