// File: /workspace/github_c_makefile_star2_O0/imaya[P]zopfli-for-emscripten/hash.c
// Function: ZopfliInitHash
void ZopfliInitHash(size_t window_size, ZopfliHash* h) {
  size_t i;

  h->val = 0;
  h->head = (int*)malloc(sizeof(*h->head) * 65536);
  h->prev = (unsigned short*)malloc(sizeof(*h->prev) * window_size);
  h->hashval = (int*)malloc(sizeof(*h->hashval) * window_size);
  for (i = 0; i < 65536; i++) {
    h->head[i] = -1;  /* -1 indicates no head so far. */
  }
  for (i = 0; i < window_size; i++) {
    h->prev[i] = i;  /* If prev[j] == j, then prev[j] is uninitialized. */
    h->hashval[i] = -1;
  }

#ifdef ZOPFLI_HASH_SAME
  h->same = (unsigned short*)malloc(sizeof(*h->same) * window_size);
  for (i = 0; i < window_size; i++) {
    h->same[i] = 0;
  }
#endif

#ifdef ZOPFLI_HASH_SAME_HASH
  h->val2 = 0;
  h->head2 = (int*)malloc(sizeof(*h->head2) * 65536);
  h->prev2 = (unsigned short*)malloc(sizeof(*h->prev2) * window_size);
  h->hashval2 = (int*)malloc(sizeof(*h->hashval2) * window_size);
  for (i = 0; i < 65536; i++) {
    h->head2[i] = -1;
  }
  for (i = 0; i < window_size; i++) {
    h->prev2[i] = i;
    h->hashval2[i] = -1;
  }
#endif
}

// Assembly:
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
movq 0x8(%rsp), %rax
movl $0x0, 0x18(%rax)
movl $0x40000, %edi          # imm = 0x40000
callq 0x1120
movq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, (%rax)
movq 0x10(%rsp), %rdi
shlq %rdi
callq 0x1120
movq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x10(%rsp), %rdi
shlq $0x2, %rdi
callq 0x1120
movq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x10(%rax)
movq $0x0, (%rsp)
cmpq $0x10000, (%rsp)        # imm = 0x10000
jae 0x6aa5
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq (%rsp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movq (%rsp), %rax
addq $0x1, %rax
movq %rax, (%rsp)
jmp 0x6a7a
movq $0x0, (%rsp)
movq (%rsp), %rax
cmpq 0x10(%rsp), %rax
jae 0x6af2
movq (%rsp), %rax
movw %ax, %dx
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rax
movq (%rsp), %rcx
movw %dx, (%rax,%rcx,2)
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movq (%rsp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movq (%rsp), %rax
addq $0x1, %rax
movq %rax, (%rsp)
jmp 0x6aad
movq 0x10(%rsp), %rdi
shlq %rdi
callq 0x1120
movq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x40(%rax)
movq $0x0, (%rsp)
movq (%rsp), %rax
cmpq 0x10(%rsp), %rax
jae 0x6b3f
movq 0x8(%rsp), %rax
movq 0x40(%rax), %rax
movq (%rsp), %rcx
movw $0x0, (%rax,%rcx,2)
movq (%rsp), %rax
addq $0x1, %rax
movq %rax, (%rsp)
jmp 0x6b13
movq 0x8(%rsp), %rax
movl $0x0, 0x38(%rax)
movl $0x40000, %edi          # imm = 0x40000
callq 0x1120
movq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x10(%rsp), %rdi
shlq %rdi
callq 0x1120
movq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x28(%rax)
movq 0x10(%rsp), %rdi
shlq $0x2, %rdi
callq 0x1120
movq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x30(%rax)
movq $0x0, (%rsp)
cmpq $0x10000, (%rsp)        # imm = 0x10000
jae 0x6bc8
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movq (%rsp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movq (%rsp), %rax
addq $0x1, %rax
movq %rax, (%rsp)
jmp 0x6b9c
movq $0x0, (%rsp)
movq (%rsp), %rax
cmpq 0x10(%rsp), %rax
jae 0x6c15
movq (%rsp), %rax
movw %ax, %dx
movq 0x8(%rsp), %rax
movq 0x28(%rax), %rax
movq (%rsp), %rcx
movw %dx, (%rax,%rcx,2)
movq 0x8(%rsp), %rax
movq 0x30(%rax), %rax
movq (%rsp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movq (%rsp), %rax
addq $0x1, %rax
movq %rax, (%rsp)
jmp 0x6bd0
addq $0x18, %rsp
retq
nopw (%rax,%rax)