#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 */
typedef int /*<<< orphan*/ uint8_t;
typedef int uint32_t;
typedef int uint16_t;

/* Variables and functions */
int compute_hash(int);
int load_u32(int /*<<< orphan*/ *);
void isal_deflate_hash_base(uint16_t *hash_table, uint32_t hash_mask,
                            uint32_t current_index, uint8_t *dict,
                            uint32_t dict_len) {
  uint8_t *next_in = dict;
  uint8_t *end_in = dict + dict_len - 4;
  uint32_t literal;
  uint32_t hash;
  uint16_t index = current_index - dict_len;
  while (next_in <= end_in) {
    literal = load_u32(next_in);
    hash = compute_hash(literal) & hash_mask;
    hash_table[hash] = index;
    index++;
    next_in++;
  }
}


x86 assembly (clang, -O0):
<isal_deflate_hash_base>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
add    $0xfffffffffffffff0,%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
ja     11b2 <isal_deflate_hash_base+0x92>
mov    -0x28(%rbp),%rdi
call   1030 <load_u32@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edi
call   1040 <compute_hash@plt>
and    -0xc(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x3c(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x28(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x28(%rbp)
jmp    1162 <isal_deflate_hash_base+0x42>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isal_deflate_hash_base>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
movslq %r8d,%rax
lea    (%rcx,%rax,4),%r12
add    $0xfffffffffffffff0,%r12
cmp    %rcx,%r12
jb     1174 <isal_deflate_hash_base+0x54>
mov    %rcx,%rbx
mov    %edx,%ebp
mov    %esi,%r14d
mov    %rdi,%r15
sub    %r8d,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <load_u32@plt>
mov    %eax,%edi
call   1040 <compute_hash@plt>
and    %r14d,%eax
cltq
mov    %ebp,(%r15,%rax,4)
add    $0x1,%ebp
add    $0x4,%rbx
cmp    %r12,%rbx
jbe    1150 <isal_deflate_hash_base+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @isal_deflate_hash_base(i32* %0, i32 %1, i32 %2, i32* %3, i32 %4) {
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32* %3, i32** %9
store i32 %4, i32* %10
%16 = load i32*, i32** %9
store i32* %16, i32** %11
%17 = load i32*, i32** %9
%18 = load i32, i32* %10
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = getelementptr inbounds i32, i32* %20, i64 -4
store i32* %21, i32** %12
%22 = load i32, i32* %8
%23 = load i32, i32* %10
%24 = sub nsw i32 %22, %23
store i32 %24, i32* %15
br label %25
25: ; preds = %29, %5
%26 = load i32*, i32** %11
%27 = load i32*, i32** %12
%28 = icmp ule i32* %26, %27
br i1 %28, label %29, label %45
29: ; preds = %25
%30 = load i32*, i32** %11
%31 = call i32 @load_u32(i32* %30)
store i32 %31, i32* %13
%32 = load i32, i32* %13
%33 = call i32 @compute_hash(i32 %32)
%34 = load i32, i32* %7
%35 = and i32 %33, %34
store i32 %35, i32* %14
%36 = load i32, i32* %15
%37 = load i32*, i32** %6
%38 = load i32, i32* %14
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %37, i64 %39
store i32 %36, i32* %40
%41 = load i32, i32* %15
%42 = add nsw i32 %41, 1
store i32 %42, i32* %15
%43 = load i32*, i32** %11
%44 = getelementptr inbounds i32, i32* %43, i32 1
store i32* %44, i32** %11
br label %25
45: ; preds = %25
ret void
}

LLVM IR (-O2):
define void @isal_deflate_hash_base(i32* nocapture writeonly %0, i32 %1, i32 %2, i32* %3, i32 %4) {
%6 = sext i32 %4 to i64
%7 = getelementptr inbounds i32, i32* %3, i64 %6
%8 = getelementptr inbounds i32, i32* %7, i64 -4
%9 = icmp ult i32* %8, %3
br i1 %9, label %23, label %10
10: ; preds = %5
%11 = sub nsw i32 %2, %4
br label %12
12: ; preds = %10, %12
%13 = phi i32 [ %20, %12 ], [ %11, %10 ]
%14 = phi i32* [ %21, %12 ], [ %3, %10 ]
%15 = tail call i32 @load_u32(i32* %14)
%16 = tail call i32 @compute_hash(i32 %15)
%17 = and i32 %16, %1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %0, i64 %18
store i32 %13, i32* %19
%20 = add nsw i32 %13, 1
%21 = getelementptr inbounds i32, i32* %14, i64 1
%22 = icmp ugt i32* %21, %8
br i1 %22, label %23, label %12
23: ; preds = %12, %5
ret void
}