#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 hsearch_data {
  int dummy;
};
struct TYPE_4__ {
  char *key;
  scalar_t__ data;
};
typedef TYPE_1__ ENTRY;

/* Variables and functions */
int /*<<< orphan*/ FIND;
int /*<<< orphan*/ hsearch_r(TYPE_1__, int /*<<< orphan*/, TYPE_1__ **,
                             struct hsearch_data *);
char *search_store(struct hsearch_data *store, char *key) {
  ENTRY search, *search_result;
  search.key = key;
  hsearch_r(search, FIND, &search_result, store);
  if (search_result == NULL) {
    return NULL;
  } else {
    return (char *)search_result->data;
  }
  return 0;
}


x86 assembly (clang, -O0):
<search_store>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    0x2eb1(%rip),%rax
mov    (%rax),%edx
mov    -0x10(%rbp),%r8
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x30(%rbp),%rcx
call   1030 <hsearch_r@plt>
cmpq   $0x0,-0x30(%rbp)
jne    115e <search_store+0x4e>
movq   $0x0,-0x8(%rbp)
jmp    116a <search_store+0x5a>
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search_store>:
push   %rax
mov    %rdi,%r8
mov    0x2ec5(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rcx
mov    %rsi,%rdi
call   1030 <hsearch_r@plt>
mov    (%rsp),%rax
test   %rax,%rax
je     1137 <search_store+0x27>
mov    0x8(%rax),%rax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.hsearch_data = type { i32 }
%struct.TYPE_4__ = type { i8*, i64 }
@FIND = global i32 0
define i8* @search_store(%struct.hsearch_data* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca %struct.hsearch_data*
%5 = alloca i8*
%6 = alloca %struct.TYPE_4__
%7 = alloca %struct.TYPE_4__*
store %struct.hsearch_data* %0, %struct.hsearch_data** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %5
%9 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %6, i32 0, i32 0
store i8* %8, i8** %9
%10 = load i32, i32* @FIND
%11 = load %struct.hsearch_data*, %struct.hsearch_data** %4
%12 = bitcast %struct.TYPE_4__* %6 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 i32 @hsearch_r(i8* %14, i64 %16, i32 %10, %struct.TYPE_4__** %7, %struct.hsearch_data* %11)
%18 = load %struct.TYPE_4__*, %struct.TYPE_4__** %7
%19 = icmp eq %struct.TYPE_4__* %18, null
br i1 %19, label %20, label %21
20: ; preds = %2
store i8* null, i8** %3
br label %26
21: ; preds = %2
%22 = load %struct.TYPE_4__*, %struct.TYPE_4__** %7
%23 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %22, i32 0, i32 1
%24 = load i64, i64* %23
%25 = inttoptr i64 %24 to i8*
store i8* %25, i8** %3
br label %26
26: ; preds = %21, %20
%27 = load i8*, i8** %3
ret i8* %27
}

LLVM IR (-O2):
%struct.hsearch_data = type { i32 }
%struct.TYPE_4__ = type { i8*, i64 }
@FIND = global i32 0
define i8* @search_store(%struct.hsearch_data* %0, i8* %1) {
%3 = alloca %struct.TYPE_4__*
%4 = bitcast %struct.TYPE_4__** %3 to i8*
%5 = load i32, i32* @FIND
%6 = call i32 @hsearch_r(i8* %1, i64 undef, i32 %5, %struct.TYPE_4__** %3, %struct.hsearch_data* %0)
%7 = load %struct.TYPE_4__*, %struct.TYPE_4__** %3
%8 = icmp eq %struct.TYPE_4__* %7, null
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %7, i64 0, i32 1
%11 = load i64, i64* %10
%12 = inttoptr i64 %11 to i8*
br label %13
13: ; preds = %2, %9
%14 = phi i8* [ %12, %9 ], [ null, %2 ]
ret i8* %14
}