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

/* Variables and functions */
int /*<<< orphan*/ ENTER;
scalar_t__ hcreate(int);
TYPE_1__ *hsearch(TYPE_1__, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int main(void) {
  int a = 1;
  int b = 2;
  ENTRY i;
  ENTRY *e;
  if (hcreate(20) == 0) {
    puts("hcreate failed");
    return 1;
  }
  i.key = (char *)"one";
  i.data = &a;
  if (hsearch(i, ENTER) == NULL)
    return 1;
  i.key = (char *)"one";
  i.data = &b;
  e = hsearch(i, ENTER);
  printf("e.data = %d\n", *(int *)e->data);
  if (*(int *)e->data != 1)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
mov    $0x14,%edi
call   1040 <hcreate@plt>
cmp    $0x0,%rax
jne    1189 <main+0x49>
lea    0xe88(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    122f <main+0xef>
lea    0xe7f(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e45(%rip),%rax
mov    (%rax),%edx
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <hsearch@plt>
cmp    $0x0,%rax
jne    11c8 <main+0x88>
movl   $0x1,-0x4(%rbp)
jmp    122f <main+0xef>
lea    0xe40(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0xc(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e06(%rip),%rax
mov    (%rax),%edx
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <hsearch@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%esi
lea    0xe0d(%rip),%rdi
call   1050 <printf@plt>
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rax
cmpl   $0x1,(%rax)
je     1228 <main+0xe8>
movl   $0x1,-0x4(%rbp)
jmp    122f <main+0xef>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x1,0xc(%rsp)
movl   $0x2,0x8(%rsp)
mov    $0x14,%edi
call   1040 <hcreate@plt>
test   %rax,%rax
je     11b9 <main+0x79>
mov    0x2e7d(%rip),%rbx
mov    (%rbx),%edx
lea    0xe9b(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <hsearch@plt>
test   %rax,%rax
je     11c5 <main+0x85>
mov    (%rbx),%edx
lea    0xe83(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1060 <hsearch@plt>
mov    %rax,%rbx
mov    0x8(%rax),%rax
mov    (%rax),%esi
lea    0xe6d(%rip),%rdi
call   1050 <printf@plt>
mov    0x8(%rbx),%rcx
xor    %eax,%eax
cmpl   $0x1,(%rcx)
setne  %al
jmp    11ca <main+0x8a>
lea    0xe40(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i8*, i32* }
@.str = [15 x i8] c"hcreate failed\00"
@.str.1 = [4 x i8] c"one\00"
@ENTER = global i32 0
@.str.2 = [13 x i8] c"e.data = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.TYPE_4__
%5 = alloca %struct.TYPE_4__*
store i32 0, i32* %1
store i32 1, i32* %2
store i32 2, i32* %3
%6 = call i64 @hcreate(i32 20)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %44
10: ; preds = %0
%11 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %4, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %4, i32 0, i32 1
store i32* %2, i32** %12
%13 = load i32, i32* @ENTER
%14 = bitcast %struct.TYPE_4__* %4 to { i8*, i32* }*
%15 = getelementptr inbounds { i8*, i32* }, { i8*, i32* }* %14, i32 0, i32 0
%16 = load i8*, i8** %15
%17 = getelementptr inbounds { i8*, i32* }, { i8*, i32* }* %14, i32 0, i32 1
%18 = load i32*, i32** %17
%19 = call %struct.TYPE_4__* @hsearch(i8* %16, i32* %18, i32 %13)
%20 = icmp eq %struct.TYPE_4__* %19, null
br i1 %20, label %21, label %22
21: ; preds = %10
store i32 1, i32* %1
br label %44
22: ; preds = %10
%23 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %4, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %23
%24 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %4, i32 0, i32 1
store i32* %3, i32** %24
%25 = load i32, i32* @ENTER
%26 = bitcast %struct.TYPE_4__* %4 to { i8*, i32* }*
%27 = getelementptr inbounds { i8*, i32* }, { i8*, i32* }* %26, i32 0, i32 0
%28 = load i8*, i8** %27
%29 = getelementptr inbounds { i8*, i32* }, { i8*, i32* }* %26, i32 0, i32 1
%30 = load i32*, i32** %29
%31 = call %struct.TYPE_4__* @hsearch(i8* %28, i32* %30, i32 %25)
store %struct.TYPE_4__* %31, %struct.TYPE_4__** %5
%32 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%33 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %32, i32 0, i32 1
%34 = load i32*, i32** %33
%35 = load i32, i32* %34
%36 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %35)
%37 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%38 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %37, i32 0, i32 1
%39 = load i32*, i32** %38
%40 = load i32, i32* %39
%41 = icmp ne i32 %40, 1
br i1 %41, label %42, label %43
42: ; preds = %22
store i32 1, i32* %1
br label %44
43: ; preds = %22
store i32 0, i32* %1
br label %44
44: ; preds = %43, %42, %21, %8
%45 = load i32, i32* %1
ret i32 %45
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i8*, i32* }
@.str = [15 x i8] c"hcreate failed\00"
@.str.1 = [4 x i8] c"one\00"
@ENTER = global i32 0
@.str.2 = [13 x i8] c"e.data = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 1, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 2, i32* %2
%5 = tail call i64 @hcreate(i32 20)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %24
9: ; preds = %0
%10 = load i32, i32* @ENTER
%11 = call %struct.TYPE_4__* @hsearch(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32 %10)
%12 = icmp eq %struct.TYPE_4__* %11, null
br i1 %12, label %24, label %13
13: ; preds = %9
%14 = load i32, i32* @ENTER
%15 = call %struct.TYPE_4__* @hsearch(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32 %14)
%16 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %15, i64 0, i32 1
%17 = load i32*, i32** %16
%18 = load i32, i32* %17
%19 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = load i32*, i32** %16
%21 = load i32, i32* %20
%22 = icmp ne i32 %21, 1
%23 = zext i1 %22 to i32
br label %24
24: ; preds = %13, %9, %7
%25 = phi i32 [ 1, %7 ], [ 1, %9 ], [ %23, %13 ]
ret i32 %25
}