#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 *);
int /*<<< orphan*/ free(char *);
TYPE_1__ *hsearch(TYPE_1__, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int wc_to_key(int /*<<< orphan*/, char *, int);
void ht_del(wchar_t *keys, size_t keyssz) {
  int err;
  size_t i;
  ENTRY entry, *pentry;
  char key[sizeof(wchar_t) + 1];
  for (i = 0; i < keyssz; i++) {
    err = wc_to_key(keys[i], 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)
      free(pentry->key);
  }
}


x86 assembly (clang, -O0):
<ht_del>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1216 <ht_del+0xc6>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
lea    -0x3d(%rbp),%rsi
mov    $0x5,%edx
call   1040 <wc_to_key@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11bf <ht_del+0x6f>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    -0x3d(%rbp),%rax
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x28(%rbp)
mov    0x2dfa(%rip),%rax
mov    (%rax),%edx
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <hsearch@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1200 <ht_del+0xb0>
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
jmp    1205 <ht_del+0xb5>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1168 <ht_del+0x18>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ht_del>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %rsi,%rsi
je     11bb <ht_del+0x6b>
mov    %rsi,%r15
mov    %rdi,%r14
xor    %ebx,%ebx
lea    0xb(%rsp),%r12
mov    0x2e5a(%rip),%r13
jmp    1189 <ht_del+0x39>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%r15
je     11bb <ht_del+0x6b>
mov    (%r14,%rbx,4),%edi
mov    %r12,%rsi
mov    $0x5,%edx
call   1040 <wc_to_key@plt>
test   %eax,%eax
jne    11c9 <ht_del+0x79>
mov    0x0(%r13),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1060 <hsearch@plt>
test   %rax,%rax
je     1180 <ht_del+0x30>
mov    (%rax),%rdi
call   1030 <free@plt>
jmp    1180 <ht_del+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
lea    0xe27(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
call   1070 <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 void @ht_del(i32* %0, i64 %1) {
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i64
%7 = alloca %struct.TYPE_4__
%8 = alloca %struct.TYPE_4__*
%9 = alloca [5 x i8]
store i32* %0, i32** %3
store i64 %1, i64* %4
store i64 0, i64* %6
br label %10
10: ; preds = %47, %2
%11 = load i64, i64* %6
%12 = load i64, i64* %4
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %50
14: ; preds = %10
%15 = load i32*, i32** %3
%16 = load i64, i64* %6
%17 = getelementptr inbounds i32, i32* %15, i64 %16
%18 = load i32, i32* %17
%19 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 0
%20 = call i32 @wc_to_key(i32 %18, i8* %19, i32 5)
store i32 %20, i32* %5
%21 = load i32, i32* %5
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %14
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %14
%29 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 0
%30 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %7, i32 0, i32 0
store i8* %29, i8** %30
%31 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %7, i32 0, i32 1
store i32* null, i32** %31
%32 = load i32, i32* @FIND
%33 = bitcast %struct.TYPE_4__* %7 to { i8*, i32* }*
%34 = getelementptr inbounds { i8*, i32* }, { i8*, i32* }* %33, i32 0, i32 0
%35 = load i8*, i8** %34
%36 = getelementptr inbounds { i8*, i32* }, { i8*, i32* }* %33, i32 0, i32 1
%37 = load i32*, i32** %36
%38 = call %struct.TYPE_4__* @hsearch(i8* %35, i32* %37, i32 %32)
store %struct.TYPE_4__* %38, %struct.TYPE_4__** %8
%39 = load %struct.TYPE_4__*, %struct.TYPE_4__** %8
%40 = icmp ne %struct.TYPE_4__* %39, null
br i1 %40, label %41, label %46
41: ; preds = %28
%42 = load %struct.TYPE_4__*, %struct.TYPE_4__** %8
%43 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %42, i32 0, i32 0
%44 = load i8*, i8** %43
%45 = call i32 @free(i8* %44)
br label %46
46: ; preds = %41, %28
br label %47
47: ; preds = %46
%48 = load i64, i64* %6
%49 = add i64 %48, 1
store i64 %49, i64* %6
br label %10
50: ; preds = %10
ret void
}

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 void @ht_del(i32* nocapture %0, i64 %1) {
%3 = alloca [5 x i8]
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%5 = icmp eq i64 %1, 0
br i1 %5, label %28, label %6
6: ; preds = %2, %25
%7 = phi i64 [ %26, %25 ], [ 0, %2 ]
%8 = getelementptr inbounds i32, i32* %0, i64 %7
%9 = load i32, i32* %8
%10 = call i32 @wc_to_key(i32 %9, i8* %4, i32 5)
%11 = icmp eq i32 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %6
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %6
%18 = load i32, i32* @FIND
%19 = call %struct.TYPE_4__* @hsearch(i8* %4, i32* null, i32 %18)
%20 = icmp eq %struct.TYPE_4__* %19, null
br i1 %20, label %25, label %21
21: ; preds = %17
%22 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %19, i64 0, i32 0
%23 = load i8*, i8** %22
%24 = call i32 @free(i8* %23)
br label %25
25: ; preds = %17, %21
%26 = add nuw i64 %7, 1
%27 = icmp eq i64 %26, %1
br i1 %27, label %28, label %6
28: ; preds = %25, %2
ret void
}