#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;
TYPE_1__ *hsearch(TYPE_1__, int /*<<< orphan*/);
int final_index_val0(const char *s) {
  ENTRY *p;
  ENTRY e;
  e.key = (char *)s;
  if (!(p = hsearch(e, FIND))) {
    return 0;
  }
  return (int)(p->data);
}


x86 assembly (clang, -O0):
<final_index_val0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    0x2eb5(%rip),%rax
mov    (%rax),%edx
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <hsearch@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1154 <final_index_val0+0x44>
movl   $0x0,-0x4(%rbp)
jmp    115f <final_index_val0+0x4f>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<final_index_val0>:
push   %rax
mov    0x2ec8(%rip),%rax
mov    (%rax),%edx
call   1030 <hsearch@plt>
test   %rax,%rax
je     1129 <final_index_val0+0x19>
mov    0x8(%rax),%eax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i8*, i64 }
@FIND = global i32 0
define i32 @final_index_val0(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.TYPE_4__*
%5 = alloca %struct.TYPE_4__
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %5, i32 0, i32 0
store i8* %6, i8** %7
%8 = load i32, i32* @FIND
%9 = bitcast %struct.TYPE_4__* %5 to { i8*, i64 }*
%10 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %9, i32 0, i32 0
%11 = load i8*, i8** %10
%12 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %9, i32 0, i32 1
%13 = load i64, i64* %12
%14 = call %struct.TYPE_4__* @hsearch(i8* %11, i64 %13, i32 %8)
store %struct.TYPE_4__* %14, %struct.TYPE_4__** %4
%15 = icmp ne %struct.TYPE_4__* %14, null
br i1 %15, label %17, label %16
16: ; preds = %1
store i32 0, i32* %2
br label %22
17: ; preds = %1
%18 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%19 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %18, i32 0, i32 1
%20 = load i64, i64* %19
%21 = trunc i64 %20 to i32
store i32 %21, i32* %2
br label %22
22: ; preds = %17, %16
%23 = load i32, i32* %2
ret i32 %23
}

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