#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 int /*<<< orphan*/ uint64_t;
struct qhash_item {
  int dummy;
};
struct qhash {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ _htable_delete(struct qhash *, struct qhash_item *);
int /*<<< orphan*/ _queue_delete(struct qhash *, struct qhash_item *);
struct qhash_item *qhash_find(struct qhash *, int /*<<< orphan*/, void *);
struct qhash_item *qhash_delete(struct qhash *qhash, uint64_t hashcode,
                                void *data) {
  struct qhash_item *item;
  item = qhash_find(qhash, hashcode, data);
  if (!item)
    return NULL;
  _htable_delete(qhash, item);
  _queue_delete(qhash, item);
  return item;
}


x86 assembly (clang, -O0):
<qhash_delete>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1040 <qhash_find@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    116f <qhash_delete+0x3f>
movq   $0x0,-0x8(%rbp)
jmp    1191 <qhash_delete+0x61>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <_htable_delete@plt>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <_queue_delete@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qhash_delete>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <qhash_find@plt>
mov    %rax,%rbx
test   %rax,%rax
je     115a <qhash_delete+0x2a>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <_htable_delete@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <_queue_delete@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.qhash_item = type { i32 }
%struct.qhash = type { i32 }
define %struct.qhash_item* @qhash_delete(%struct.qhash* %0, i32 %1, i8* %2) {
%4 = alloca %struct.qhash_item*
%5 = alloca %struct.qhash*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca %struct.qhash_item*
store %struct.qhash* %0, %struct.qhash** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
%9 = load %struct.qhash*, %struct.qhash** %5
%10 = load i32, i32* %6
%11 = load i8*, i8** %7
%12 = call %struct.qhash_item* @qhash_find(%struct.qhash* %9, i32 %10, i8* %11)
store %struct.qhash_item* %12, %struct.qhash_item** %8
%13 = load %struct.qhash_item*, %struct.qhash_item** %8
%14 = icmp ne %struct.qhash_item* %13, null
br i1 %14, label %16, label %15
15: ; preds = %3
store %struct.qhash_item* null, %struct.qhash_item** %4
br label %24
16: ; preds = %3
%17 = load %struct.qhash*, %struct.qhash** %5
%18 = load %struct.qhash_item*, %struct.qhash_item** %8
%19 = call i32 @_htable_delete(%struct.qhash* %17, %struct.qhash_item* %18)
%20 = load %struct.qhash*, %struct.qhash** %5
%21 = load %struct.qhash_item*, %struct.qhash_item** %8
%22 = call i32 @_queue_delete(%struct.qhash* %20, %struct.qhash_item* %21)
%23 = load %struct.qhash_item*, %struct.qhash_item** %8
store %struct.qhash_item* %23, %struct.qhash_item** %4
br label %24
24: ; preds = %16, %15
%25 = load %struct.qhash_item*, %struct.qhash_item** %4
ret %struct.qhash_item* %25
}

LLVM IR (-O2):
%struct.qhash_item = type { i32 }
%struct.qhash = type { i32 }
define %struct.qhash_item* @qhash_delete(%struct.qhash* %0, i32 %1, i8* %2) {
%4 = tail call %struct.qhash_item* @qhash_find(%struct.qhash* %0, i32 %1, i8* %2)
%5 = icmp eq %struct.qhash_item* %4, null
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = tail call i32 @_htable_delete(%struct.qhash* %0, %struct.qhash_item* %4)
%8 = tail call i32 @_queue_delete(%struct.qhash* %0, %struct.qhash_item* %4)
br label %9
9: ; preds = %3, %6
ret %struct.qhash_item* %4
}