#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;
  scalar_t__ data;
};
typedef TYPE_1__ ENTRY;

/* Variables and functions */
int /*<<< orphan*/ FIND;
int /*<<< orphan*/ error_msg(char *, char const *);
TYPE_1__ *hsearch(TYPE_1__, int /*<<< orphan*/);
int final_index_val(const char *s) {
  ENTRY *p;
  ENTRY e;
  e.key = (char *)s;
  if (!(p = hsearch(e, FIND))) {
    error_msg("can't find final index: %s", s);
  }
  return (int)(p->data);
}


x86 assembly (clang, -O0):
<final_index_val>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2ea5(%rip),%rax
mov    (%rax),%edx
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <hsearch@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1168 <final_index_val+0x48>
mov    -0x8(%rbp),%rsi
lea    0xe9d(%rip),%rdi
call   1030 <error_msg@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<final_index_val>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x2eb2(%rip),%rax
mov    (%rax),%edx
call   1040 <hsearch@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    114c <final_index_val+0x2c>
lea    0xebc(%rip),%rdi
mov    %r14,%rsi
call   1030 <error_msg@plt>
mov    0x8(%rbx),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i8*, i64 }
@FIND = global i32 0
@.str = [27 x i8] c"can't find final index: %s\00"
define i32 @final_index_val(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.TYPE_4__*
%4 = alloca %struct.TYPE_4__
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %4, i32 0, i32 0
store i8* %5, i8** %6
%7 = load i32, i32* @FIND
%8 = bitcast %struct.TYPE_4__* %4 to { i8*, i64 }*
%9 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %8, i32 0, i32 0
%10 = load i8*, i8** %9
%11 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %8, i32 0, i32 1
%12 = load i64, i64* %11
%13 = call %struct.TYPE_4__* @hsearch(i8* %10, i64 %12, i32 %7)
store %struct.TYPE_4__* %13, %struct.TYPE_4__** %3
%14 = icmp ne %struct.TYPE_4__* %13, null
br i1 %14, label %18, label %15
15: ; preds = %1
%16 = load i8*, i8** %2
%17 = call i32 @error_msg(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %15, %1
%19 = load %struct.TYPE_4__*, %struct.TYPE_4__** %3
%20 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %19, i32 0, i32 1
%21 = load i64, i64* %20
%22 = trunc i64 %21 to i32
ret i32 %22
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i8*, i64 }
@FIND = global i32 0
@.str = [27 x i8] c"can't find final index: %s\00"
define i32 @final_index_val(i8* %0) {
%2 = load i32, i32* @FIND
%3 = tail call %struct.TYPE_4__* @hsearch(i8* %0, i64 undef, i32 %2)
%4 = icmp eq %struct.TYPE_4__* %3, null
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @error_msg(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %7
7: ; preds = %5, %1
%8 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %3, i64 0, i32 1
%9 = load i64, i64* %8
%10 = trunc i64 %9 to i32
ret i32 %10
}