#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 t_hashtable_item {
  int dummy;
};
struct t_hashtable {
  int dummy;
};

/* Variables and functions */
struct t_hashtable_item *hashtable_get_item(struct t_hashtable *, void const *,
                                            unsigned long *);
int /*<<< orphan*/ hashtable_remove_item(struct t_hashtable *,
                                         struct t_hashtable_item *,
                                         unsigned long);
void hashtable_remove(struct t_hashtable *hashtable, const void *key) {
  struct t_hashtable_item *ptr_item;
  unsigned long hash;
  if (!hashtable || !key)
    return;
  ptr_item = hashtable_get_item(hashtable, key, &hash);
  if (ptr_item)
    hashtable_remove_item(hashtable, ptr_item, hash);
}


x86 assembly (clang, -O0):
<hashtable_remove>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1146 <hashtable_remove+0x26>
cmpq   $0x0,-0x10(%rbp)
jne    114b <hashtable_remove+0x2b>
jmp    117c <hashtable_remove+0x5c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1030 <hashtable_get_item@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     117c <hashtable_remove+0x5c>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <hashtable_remove_item@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hashtable_remove>:
push   %rbx
sub    $0x10,%rsp
test   %rdi,%rdi
je     1151 <hashtable_remove+0x31>
test   %rsi,%rsi
je     1151 <hashtable_remove+0x31>
mov    %rdi,%rbx
lea    0x8(%rsp),%rdx
call   1030 <hashtable_get_item@plt>
test   %rax,%rax
je     1151 <hashtable_remove+0x31>
mov    0x8(%rsp),%rdx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <hashtable_remove_item@plt>
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
%struct.t_hashtable = type { i32 }
%struct.t_hashtable_item = type { i32 }
define void @hashtable_remove(%struct.t_hashtable* %0, i8* %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = icmp ne %struct.t_hashtable* %0, null
%6 = icmp ne i8* %1, null
%7 = and i1 %5, %6
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = call %struct.t_hashtable_item* @hashtable_get_item(%struct.t_hashtable* %0, i8* %1, i64* %3)
%10 = icmp eq %struct.t_hashtable_item* %9, null
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = load i64, i64* %3
%13 = call i32 @hashtable_remove_item(%struct.t_hashtable* %0, %struct.t_hashtable_item* %9, i64 %12)
br label %14
14: ; preds = %8, %11, %2
ret void
}