#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 */

/* Type definitions */
struct std_hashtable {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ std_hash_table_destroy(struct std_hashtable *);
int /*<<< orphan*/ std_hash_table_insert(struct std_hashtable *, void *,
                                         void *);
scalar_t__ std_hash_table_lookup(struct std_hashtable *, void *);
struct std_hashtable *std_hash_table_new(int /*<<< orphan*/ *,
                                         int /*<<< orphan*/ *);
int std_hash_table_size(struct std_hashtable *);
void direct_hash_test(void) {
  long i, rc;
  struct std_hashtable *h;
  h = std_hash_table_new(NULL, NULL);
  assert(h != NULL);
  for (i = 1; i <= 20; i++) {
    std_hash_table_insert(h, ((void *)(i)), (void *)(i + 42));
  }
  assert(std_hash_table_size(h) == 20);
  for (i = 1; i <= 20; i++) {
    rc = ((long)(std_hash_table_lookup(h, ((void *)(i)))));
    assert(rc != 0);
    assert((rc - 42) == i);
  }
  std_hash_table_destroy(h);
}


x86 assembly (clang, -O0):
<direct_hash_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %eax,%eax
mov    %eax,%esi
mov    %rsi,%rdi
call   1050 <std_hash_table_new@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movq   $0x1,-0x8(%rbp)
cmpq   $0x14,-0x8(%rbp)
jg     11c3 <direct_hash_test+0x63>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x8(%rbp),%rdx
add    $0x2a,%rdx
call   1060 <std_hash_table_insert@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1192 <direct_hash_test+0x32>
mov    -0x18(%rbp),%rdi
call   1080 <std_hash_table_size@plt>
cmp    $0x14,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movq   $0x1,-0x8(%rbp)
cmpq   $0x14,-0x8(%rbp)
jg     123c <direct_hash_test+0xdc>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1070 <std_hash_table_lookup@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rax
sub    $0x2a,%rax
cmp    -0x8(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11e4 <direct_hash_test+0x84>
mov    -0x18(%rbp),%rdi
call   1030 <std_hash_table_destroy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<direct_hash_test>:
push   %r15
push   %r14
push   %rbx
xor    %edi,%edi
xor    %esi,%esi
call   1050 <std_hash_table_new@plt>
mov    %rax,%r14
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1040 <assert@plt>
mov    $0x1,%r15d
mov    $0x1,%esi
mov    $0x2b,%edx
mov    %r14,%rdi
call   1060 <std_hash_table_insert@plt>
mov    $0x2,%esi
mov    $0x2c,%edx
mov    %r14,%rdi
call   1060 <std_hash_table_insert@plt>
mov    $0x3,%esi
mov    $0x2d,%edx
mov    %r14,%rdi
call   1060 <std_hash_table_insert@plt>
mov    $0x4,%esi
mov    $0x2e,%edx
mov    %r14,%rdi
call   1060 <std_hash_table_insert@plt>
mov    $0x5,%esi
mov    $0x2f,%edx
mov    %r14,%rdi
call   1060 <std_hash_table_insert@plt>
mov    $0x6,%esi
mov    $0x30,%edx
mov    %r14,%rdi
call   1060 <std_hash_table_insert@plt>
mov    $0x7,%esi
mov    $0x31,%edx
mov    %r14,%rdi
call   1060 <std_hash_table_insert@plt>
mov    $0x8,%esi
mov    $0x32,%edx
mov    %r14,%rdi
call   1060 <std_hash_table_insert@plt>
mov    $0x9,%esi
mov    $0x33,%edx
mov    %r14,%rdi
call   1060 <std_hash_table_insert@plt>
mov    $0xa,%esi
mov    $0x34,%edx
mov    %r14,%rdi
call   1060 <std_hash_table_insert@plt>
mov    $0xb,%esi
mov    $0x35,%edx
mov    %r14,%rdi
call   1060 <std_hash_table_insert@plt>
mov    $0xc,%esi
mov    $0x36,%edx
mov    %r14,%rdi
call   1060 <std_hash_table_insert@plt>
mov    $0xd,%esi
mov    $0x37,%edx
mov    %r14,%rdi
call   1060 <std_hash_table_insert@plt>
mov    $0xe,%esi
mov    $0x38,%edx
mov    %r14,%rdi
call   1060 <std_hash_table_insert@plt>
mov    $0xf,%esi
mov    $0x39,%edx
mov    %r14,%rdi
call   1060 <std_hash_table_insert@plt>
mov    $0x10,%esi
mov    $0x3a,%edx
mov    %r14,%rdi
call   1060 <std_hash_table_insert@plt>
mov    $0x11,%esi
mov    $0x3b,%edx
mov    %r14,%rdi
call   1060 <std_hash_table_insert@plt>
mov    $0x12,%esi
mov    $0x3c,%edx
mov    %r14,%rdi
call   1060 <std_hash_table_insert@plt>
mov    $0x13,%esi
mov    $0x3d,%edx
mov    %r14,%rdi
call   1060 <std_hash_table_insert@plt>
mov    $0x14,%esi
mov    $0x3e,%edx
mov    %r14,%rdi
call   1060 <std_hash_table_insert@plt>
mov    %r14,%rdi
call   1080 <std_hash_table_size@plt>
xor    %edi,%edi
cmp    $0x14,%eax
sete   %dil
call   1040 <assert@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <std_hash_table_lookup@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1040 <assert@plt>
add    $0xffffffffffffffd6,%rbx
xor    %edi,%edi
cmp    %rbx,%r15
sete   %dil
call   1040 <assert@plt>
add    $0x1,%r15
cmp    $0x15,%r15
jne    1310 <direct_hash_test+0x1b0>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <std_hash_table_destroy@plt>

LLVM IR (-O0):
%struct.std_hashtable = type { i32 }
define void @direct_hash_test() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca %struct.std_hashtable*
%4 = call %struct.std_hashtable* @std_hash_table_new(i32* null, i32* null)
store %struct.std_hashtable* %4, %struct.std_hashtable** %3
%5 = load %struct.std_hashtable*, %struct.std_hashtable** %3
%6 = icmp ne %struct.std_hashtable* %5, null
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
store i64 1, i64* %1
br label %9
9: ; preds = %20, %0
%10 = load i64, i64* %1
%11 = icmp sle i64 %10, 20
br i1 %11, label %12, label %23
12: ; preds = %9
%13 = load %struct.std_hashtable*, %struct.std_hashtable** %3
%14 = load i64, i64* %1
%15 = inttoptr i64 %14 to i8*
%16 = load i64, i64* %1
%17 = add nsw i64 %16, 42
%18 = inttoptr i64 %17 to i8*
%19 = call i32 @std_hash_table_insert(%struct.std_hashtable* %13, i8* %15, i8* %18)
br label %20
20: ; preds = %12
%21 = load i64, i64* %1
%22 = add nsw i64 %21, 1
store i64 %22, i64* %1
br label %9
23: ; preds = %9
%24 = load %struct.std_hashtable*, %struct.std_hashtable** %3
%25 = call i32 @std_hash_table_size(%struct.std_hashtable* %24)
%26 = icmp eq i32 %25, 20
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
store i64 1, i64* %1
br label %29
29: ; preds = %47, %23
%30 = load i64, i64* %1
%31 = icmp sle i64 %30, 20
br i1 %31, label %32, label %50
32: ; preds = %29
%33 = load %struct.std_hashtable*, %struct.std_hashtable** %3
%34 = load i64, i64* %1
%35 = inttoptr i64 %34 to i8*
%36 = call i64 @std_hash_table_lookup(%struct.std_hashtable* %33, i8* %35)
store i64 %36, i64* %2
%37 = load i64, i64* %2
%38 = icmp ne i64 %37, 0
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
%41 = load i64, i64* %2
%42 = sub nsw i64 %41, 42
%43 = load i64, i64* %1
%44 = icmp eq i64 %42, %43
%45 = zext i1 %44 to i32
%46 = call i32 @assert(i32 %45)
br label %47
47: ; preds = %32
%48 = load i64, i64* %1
%49 = add nsw i64 %48, 1
store i64 %49, i64* %1
br label %29
50: ; preds = %29
%51 = load %struct.std_hashtable*, %struct.std_hashtable** %3
%52 = call i32 @std_hash_table_destroy(%struct.std_hashtable* %51)
ret void
}

LLVM IR (-O2):
%struct.std_hashtable = type { i32 }
define void @direct_hash_test() {
%1 = tail call %struct.std_hashtable* @std_hash_table_new(i32* null, i32* null)
%2 = icmp ne %struct.std_hashtable* %1, null
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = tail call i32 @std_hash_table_insert(%struct.std_hashtable* %1, i8* inttoptr (i64 1 to i8*), i8* inttoptr (i64 43 to i8*))
%6 = tail call i32 @std_hash_table_insert(%struct.std_hashtable* %1, i8* inttoptr (i64 2 to i8*), i8* inttoptr (i64 44 to i8*))
%7 = tail call i32 @std_hash_table_insert(%struct.std_hashtable* %1, i8* inttoptr (i64 3 to i8*), i8* inttoptr (i64 45 to i8*))
%8 = tail call i32 @std_hash_table_insert(%struct.std_hashtable* %1, i8* inttoptr (i64 4 to i8*), i8* inttoptr (i64 46 to i8*))
%9 = tail call i32 @std_hash_table_insert(%struct.std_hashtable* %1, i8* inttoptr (i64 5 to i8*), i8* inttoptr (i64 47 to i8*))
%10 = tail call i32 @std_hash_table_insert(%struct.std_hashtable* %1, i8* inttoptr (i64 6 to i8*), i8* inttoptr (i64 48 to i8*))
%11 = tail call i32 @std_hash_table_insert(%struct.std_hashtable* %1, i8* inttoptr (i64 7 to i8*), i8* inttoptr (i64 49 to i8*))
%12 = tail call i32 @std_hash_table_insert(%struct.std_hashtable* %1, i8* inttoptr (i64 8 to i8*), i8* inttoptr (i64 50 to i8*))
%13 = tail call i32 @std_hash_table_insert(%struct.std_hashtable* %1, i8* inttoptr (i64 9 to i8*), i8* inttoptr (i64 51 to i8*))
%14 = tail call i32 @std_hash_table_insert(%struct.std_hashtable* %1, i8* inttoptr (i64 10 to i8*), i8* inttoptr (i64 52 to i8*))
%15 = tail call i32 @std_hash_table_insert(%struct.std_hashtable* %1, i8* inttoptr (i64 11 to i8*), i8* inttoptr (i64 53 to i8*))
%16 = tail call i32 @std_hash_table_insert(%struct.std_hashtable* %1, i8* inttoptr (i64 12 to i8*), i8* inttoptr (i64 54 to i8*))
%17 = tail call i32 @std_hash_table_insert(%struct.std_hashtable* %1, i8* inttoptr (i64 13 to i8*), i8* inttoptr (i64 55 to i8*))
%18 = tail call i32 @std_hash_table_insert(%struct.std_hashtable* %1, i8* inttoptr (i64 14 to i8*), i8* inttoptr (i64 56 to i8*))
%19 = tail call i32 @std_hash_table_insert(%struct.std_hashtable* %1, i8* inttoptr (i64 15 to i8*), i8* inttoptr (i64 57 to i8*))
%20 = tail call i32 @std_hash_table_insert(%struct.std_hashtable* %1, i8* inttoptr (i64 16 to i8*), i8* inttoptr (i64 58 to i8*))
%21 = tail call i32 @std_hash_table_insert(%struct.std_hashtable* %1, i8* inttoptr (i64 17 to i8*), i8* inttoptr (i64 59 to i8*))
%22 = tail call i32 @std_hash_table_insert(%struct.std_hashtable* %1, i8* inttoptr (i64 18 to i8*), i8* inttoptr (i64 60 to i8*))
%23 = tail call i32 @std_hash_table_insert(%struct.std_hashtable* %1, i8* inttoptr (i64 19 to i8*), i8* inttoptr (i64 61 to i8*))
%24 = tail call i32 @std_hash_table_insert(%struct.std_hashtable* %1, i8* inttoptr (i64 20 to i8*), i8* inttoptr (i64 62 to i8*))
%25 = tail call i32 @std_hash_table_size(%struct.std_hashtable* %1)
%26 = icmp eq i32 %25, 20
%27 = zext i1 %26 to i32
%28 = tail call i32 @assert(i32 %27)
br label %29
29: ; preds = %0, %29
%30 = phi i64 [ 1, %0 ], [ %40, %29 ]
%31 = inttoptr i64 %30 to i8*
%32 = tail call i64 @std_hash_table_lookup(%struct.std_hashtable* %1, i8* %31)
%33 = icmp ne i64 %32, 0
%34 = zext i1 %33 to i32
%35 = tail call i32 @assert(i32 %34)
%36 = add nsw i64 %32, -42
%37 = icmp eq i64 %36, %30
%38 = zext i1 %37 to i32
%39 = tail call i32 @assert(i32 %38)
%40 = add nuw nsw i64 %30, 1
%41 = icmp eq i64 %40, 21
br i1 %41, label %42, label %29
42: ; preds = %29
%43 = tail call i32 @std_hash_table_destroy(%struct.std_hashtable* %1)
ret void
}