#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;
  scalar_t__ 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_lookup(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;
  else {
    do {
    } while (0);
    fd = -1;
  }
  do {
  } while (0);
  return fd;
}


x86 assembly (clang, -O0):
<fdtable_lookup>:
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     1176 <fdtable_lookup+0x56>
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rax
mov    %eax,-0x2c(%rbp)
jmp    1187 <fdtable_lookup+0x67>
jmp    117b <fdtable_lookup+0x5b>
jmp    1180 <fdtable_lookup+0x60>
movl   $0xffffffff,-0x2c(%rbp)
jmp    118c <fdtable_lookup+0x6c>
jmp    1191 <fdtable_lookup+0x71>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fdtable_lookup>:
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     1141 <fdtable_lookup+0x21>
mov    0x8(%rax),%eax
pop    %rcx
ret
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.fdkey = type { i32 }
%struct.TYPE_4__ = type { i8*, i64 }
@FIND = global i32 0
define i32 @fdtable_lookup(%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*, i64 }*
%13 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %12, i32 0, i32 0
%14 = load i8*, i8** %13
%15 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %12, i32 0, i32 1
%16 = load i64, i64* %15
%17 = call %struct.TYPE_4__* @hsearch(i8* %14, i64 %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 %25
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 i64, i64* %22
%24 = trunc i64 %23 to i32
store i32 %24, i32* %6
br label %28
25: ; preds = %1
br label %26
26: ; preds = %25
br label %27
27: ; preds = %26
store i32 -1, i32* %6
br label %28
28: ; preds = %27, %20
br label %29
29: ; preds = %28
br label %30
30: ; preds = %29
%31 = load i32, i32* %6
ret i32 %31
}

LLVM IR (-O2):
%struct.fdkey = type { i32 }
%struct.TYPE_4__ = type { i8*, i64 }
@FIND = global i32 0
define i32 @fdtable_lookup(%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, i64 undef, i32 %3)
%5 = icmp eq %struct.TYPE_4__* %4, null
br i1 %5, label %10, label %6
6: ; preds = %1
%7 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %4, i64 0, i32 1
%8 = load i64, i64* %7
%9 = trunc i64 %8 to i32
br label %10
10: ; preds = %1, %6
%11 = phi i32 [ %9, %6 ], [ -1, %1 ]
ret i32 %11
}