#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 */
typedef int /*<<< orphan*/ wchar_t;
typedef int /*<<< orphan*/ key;
struct TYPE_4__ {
  char *key;
  int /*<<< orphan*/ *data;
};
typedef TYPE_1__ ENTRY;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ FIND;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
TYPE_1__ *hsearch(TYPE_1__, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int wc_to_key(int /*<<< orphan*/, char *, int);
int ht_get(wchar_t wc) {
  int err;
  ENTRY entry, *pentry;
  char key[sizeof(wchar_t) + 1];
  err = wc_to_key(wc, key, sizeof(key));
  if (err) {
    fprintf(stderr, "FATAL: wc_to_key failed\n");
    exit(EXIT_FAILURE);
  }
  entry.key = key;
  entry.data = NULL;
  pentry = hsearch(entry, FIND);
  if (!pentry)
    return 0;
  return (int)(long)pentry->data;
}


x86 assembly (clang, -O0):
<ht_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x2d(%rbp),%rsi
mov    $0x5,%edx
call   1030 <wc_to_key@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     118c <ht_get+0x4c>
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
lea    0xe87(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
lea    -0x2d(%rbp),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
mov    0x2e2d(%rip),%rax
mov    (%rax),%edx
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <hsearch@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11cd <ht_get+0x8d>
movl   $0x0,-0x4(%rbp)
jmp    11d8 <ht_get+0x98>
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ht_get>:
push   %rbx
sub    $0x10,%rsp
lea    0xb(%rsp),%rsi
mov    $0x5,%edx
call   1030 <wc_to_key@plt>
test   %eax,%eax
jne    117f <ht_get+0x3f>
mov    0x2e71(%rip),%rax
mov    (%rax),%edx
xor    %ebx,%ebx
lea    0xb(%rsp),%rdi
xor    %esi,%esi
call   1050 <hsearch@plt>
test   %rax,%rax
je     1177 <ht_get+0x37>
mov    0x8(%rax),%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
lea    0xe71(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.TYPE_4__ = type { i8*, i32* }
@stderr = global i32 0
@.str = [25 x i8] c"FATAL: wc_to_key failed\0A\00"
@EXIT_FAILURE = global i32 0
@FIND = global i32 0
define i32 @ht_get(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.TYPE_4__
%6 = alloca %struct.TYPE_4__*
%7 = alloca [5 x i8]
store i32 %0, i32* %3
%8 = load i32, i32* %3
%9 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%10 = call i32 @wc_to_key(i32 %8, i8* %9, i32 5)
store i32 %10, i32* %4
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %1
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %1
%19 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%20 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %5, i32 0, i32 0
store i8* %19, i8** %20
%21 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %5, i32 0, i32 1
store i32* null, i32** %21
%22 = load i32, i32* @FIND
%23 = bitcast %struct.TYPE_4__* %5 to { i8*, i32* }*
%24 = getelementptr inbounds { i8*, i32* }, { i8*, i32* }* %23, i32 0, i32 0
%25 = load i8*, i8** %24
%26 = getelementptr inbounds { i8*, i32* }, { i8*, i32* }* %23, i32 0, i32 1
%27 = load i32*, i32** %26
%28 = call %struct.TYPE_4__* @hsearch(i8* %25, i32* %27, i32 %22)
store %struct.TYPE_4__* %28, %struct.TYPE_4__** %6
%29 = load %struct.TYPE_4__*, %struct.TYPE_4__** %6
%30 = icmp ne %struct.TYPE_4__* %29, null
br i1 %30, label %32, label %31
31: ; preds = %18
store i32 0, i32* %2
br label %38
32: ; preds = %18
%33 = load %struct.TYPE_4__*, %struct.TYPE_4__** %6
%34 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %33, i32 0, i32 1
%35 = load i32*, i32** %34
%36 = ptrtoint i32* %35 to i64
%37 = trunc i64 %36 to i32
store i32 %37, i32* %2
br label %38
38: ; preds = %32, %31
%39 = load i32, i32* %2
ret i32 %39
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i8*, i32* }
@stderr = global i32 0
@.str = [25 x i8] c"FATAL: wc_to_key failed\0A\00"
@EXIT_FAILURE = global i32 0
@FIND = global i32 0
define i32 @ht_get(i32 %0) {
%2 = alloca [5 x i8]
%3 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%4 = call i32 @wc_to_key(i32 %0, i8* %3, i32 5)
%5 = icmp eq i32 %4, 0
br i1 %5, label %11, label %6
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @EXIT_FAILURE
%10 = call i32 @exit(i32 %9)
unreachable
11: ; preds = %1
%12 = load i32, i32* @FIND
%13 = call %struct.TYPE_4__* @hsearch(i8* %3, i32* null, i32 %12)
%14 = icmp eq %struct.TYPE_4__* %13, null
br i1 %14, label %20, label %15
15: ; preds = %11
%16 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %13, i64 0, i32 1
%17 = load i32*, i32** %16
%18 = ptrtoint i32* %17 to i64
%19 = trunc i64 %18 to i32
br label %20
20: ; preds = %11, %15
%21 = phi i32 [ %19, %15 ], [ 0, %11 ]
ret i32 %21
}