#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 hashtableitem {
  int dummy;
};
struct hashtable {
  int dummy;
};

/* Variables and functions */
int hashtable_get_item(struct hashtable *, void const *, size_t,
                       struct hashtableitem **);
int hashtable_unset_item(struct hashtable *, struct hashtableitem *);
int hashtable_unset(struct hashtable *ht, const void *key, size_t keylen) {
  int i;
  struct hashtableitem *item;
  i = hashtable_get_item(ht, key, keylen, &item);
  if (i != 0) {
    return i;
  }
  return hashtable_unset_item(ht, item);
}


x86 assembly (clang, -O0):
<hashtable_unset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    -0x30(%rbp),%rcx
call   1040 <hashtable_get_item@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1161 <hashtable_unset+0x41>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1171 <hashtable_unset+0x51>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <hashtable_unset_item@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hashtable_unset>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rcx
call   1040 <hashtable_get_item@plt>
test   %eax,%eax
jne    1143 <hashtable_unset+0x23>
mov    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <hashtable_unset_item@plt>
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
%struct.hashtable = type { i32 }
%struct.hashtableitem = type { i32 }
define i32 @hashtable_unset(%struct.hashtable* %0, i8* %1, i64 %2) {
%4 = alloca %struct.hashtableitem*
%5 = bitcast %struct.hashtableitem** %4 to i8*
%6 = call i32 @hashtable_get_item(%struct.hashtable* %0, i8* %1, i64 %2, %struct.hashtableitem** %4)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %3
%9 = load %struct.hashtableitem*, %struct.hashtableitem** %4
%10 = call i32 @hashtable_unset_item(%struct.hashtable* %0, %struct.hashtableitem* %9)
br label %11
11: ; preds = %3, %8
%12 = phi i32 [ %10, %8 ], [ %6, %3 ]
ret i32 %12
}