#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 */
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct fdkey {
  int dummy;
};
struct TYPE_4__ {
  char *key;
  void *data;
};
typedef TYPE_1__ ENTRY;

/* Variables and functions */
int /*<<< orphan*/ FIND;
char *fdproxy_keystr(struct fdkey *);
TYPE_1__ *hsearch(TYPE_1__, int /*<<< orphan*/);
int fdtable_unhash(struct fdkey *key) {
  char *buf;
  ENTRY e, *ep;
  int fd;
  buf = fdproxy_keystr(key);
  e.key = buf;
  ep = hsearch(e, FIND);
  if (ep != NULL) {
    fd = (int)(long)ep->data;
    ep->data = (void *)(long)-1;
  } else {
    do {
    } while (0);
    fd = -1;
  }
  do {
  } while (0);
  return fd;
}


x86 assembly (clang, -O0):
<fdtable_unhash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fdproxy_keystr@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e98(%rip),%rax
mov    (%rax),%edx
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <hsearch@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1185 <fdtable_unhash+0x65>
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rax
mov    $0xffffffffffffffff,%rcx
mov    %rcx,0x8(%rax)
jmp    1196 <fdtable_unhash+0x76>
jmp    118a <fdtable_unhash+0x6a>
jmp    118f <fdtable_unhash+0x6f>
movl   $0xffffffff,-0x2c(%rbp)
jmp    119b <fdtable_unhash+0x7b>
jmp    11a0 <fdtable_unhash+0x80>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fdtable_unhash>:
push   %rax
call   1030 <fdproxy_keystr@plt>
mov    0x2eb3(%rip),%rcx
mov    (%rcx),%edx
mov    %rax,%rdi
call   1040 <hsearch@plt>
test   %rax,%rax
je     114c <fdtable_unhash+0x2c>
mov    %rax,%rcx
mov    0x8(%rax),%eax
movq   $0xffffffffffffffff,0x8(%rcx)
ff
pop    %rcx
ret
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.fdkey = type { i32 }
%struct.TYPE_4__ = type { i8*, i8* }
@FIND = global i32 0
define i32 @fdtable_unhash(%struct.fdkey* %0) {
%2 = alloca %struct.fdkey*
%3 = alloca i8*
%4 = alloca %struct.TYPE_4__
%5 = alloca %struct.TYPE_4__*
%6 = alloca i32
store %struct.fdkey* %0, %struct.fdkey** %2
%7 = load %struct.fdkey*, %struct.fdkey** %2
%8 = call i8* @fdproxy_keystr(%struct.fdkey* %7)
store i8* %8, i8** %3
%9 = load i8*, i8** %3
%10 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %4, i32 0, i32 0
store i8* %9, i8** %10
%11 = load i32, i32* @FIND
%12 = bitcast %struct.TYPE_4__* %4 to { i8*, i8* }*
%13 = getelementptr inbounds { i8*, i8* }, { i8*, i8* }* %12, i32 0, i32 0
%14 = load i8*, i8** %13
%15 = getelementptr inbounds { i8*, i8* }, { i8*, i8* }* %12, i32 0, i32 1
%16 = load i8*, i8** %15
%17 = call %struct.TYPE_4__* @hsearch(i8* %14, i8* %16, i32 %11)
store %struct.TYPE_4__* %17, %struct.TYPE_4__** %5
%18 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%19 = icmp ne %struct.TYPE_4__* %18, null
br i1 %19, label %20, label %28
20: ; preds = %1
%21 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%22 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %21, i32 0, i32 1
%23 = load i8*, i8** %22
%24 = ptrtoint i8* %23 to i64
%25 = trunc i64 %24 to i32
store i32 %25, i32* %6
%26 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%27 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %26, i32 0, i32 1
store i8* inttoptr (i64 -1 to i8*), i8** %27
br label %31
28: ; preds = %1
br label %29
29: ; preds = %28
br label %30
30: ; preds = %29
store i32 -1, i32* %6
br label %31
31: ; preds = %30, %20
br label %32
32: ; preds = %31
br label %33
33: ; preds = %32
%34 = load i32, i32* %6
ret i32 %34
}

LLVM IR (-O2):
%struct.fdkey = type { i32 }
%struct.TYPE_4__ = type { i8*, i8* }
@FIND = global i32 0
define i32 @fdtable_unhash(%struct.fdkey* %0) {
%2 = tail call i8* @fdproxy_keystr(%struct.fdkey* %0)
%3 = load i32, i32* @FIND
%4 = tail call %struct.TYPE_4__* @hsearch(i8* %2, i8* undef, i32 %3)
%5 = icmp eq %struct.TYPE_4__* %4, null
br i1 %5, label %11, label %6
6: ; preds = %1
%7 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %4, i64 0, i32 1
%8 = load i8*, i8** %7
%9 = ptrtoint i8* %8 to i64
%10 = trunc i64 %9 to i32
store i8* inttoptr (i64 -1 to i8*), i8** %7
br label %11
11: ; preds = %1, %6
%12 = phi i32 [ %10, %6 ], [ -1, %1 ]
ret i32 %12
}