// File: /workspace/github_c_makefile_star2_O0/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: hash_init
static unsigned hash_init(Hash* hash, unsigned windowsize)
{
  unsigned i;
  hash->head = (int*)lodepng_malloc(sizeof(int) * HASH_NUM_VALUES);
  hash->val = (int*)lodepng_malloc(sizeof(int) * windowsize);
  hash->chain = (unsigned short*)lodepng_malloc(sizeof(unsigned short) * windowsize);

  hash->zeros = (unsigned short*)lodepng_malloc(sizeof(unsigned short) * windowsize);
  hash->headz = (int*)lodepng_malloc(sizeof(int) * (MAX_SUPPORTED_DEFLATE_LENGTH + 1));
  hash->chainz = (unsigned short*)lodepng_malloc(sizeof(unsigned short) * windowsize);

  if(!hash->head || !hash->chain || !hash->val  || !hash->headz|| !hash->chainz || !hash->zeros)
  {
    return 83; /*alloc fail*/
  }

  /*initialize hash table*/
  for(i = 0; i != HASH_NUM_VALUES; ++i) hash->head[i] = -1;
  for(i = 0; i != windowsize; ++i) hash->val[i] = -1;
  for(i = 0; i != windowsize; ++i) hash->chain[i] = i; /*same value as index indicates uninitialized*/

  for(i = 0; i <= MAX_SUPPORTED_DEFLATE_LENGTH; ++i) hash->headz[i] = -1;
  for(i = 0; i != windowsize; ++i) hash->chainz[i] = i; /*same value as index indicates uninitialized*/

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl $0x40000, %edi          # imm = 0x40000
callq 0x13b0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movl -0x14(%rbp), %eax
movl %eax, %edi
shlq $0x2, %rdi
callq 0x13b0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movl -0x14(%rbp), %eax
movl %eax, %edi
shlq %rdi
callq 0x13b0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movl -0x14(%rbp), %eax
movl %eax, %edi
shlq %rdi
callq 0x13b0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movl $0x40c, %edi            # imm = 0x40C
callq 0x13b0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0x14(%rbp), %eax
movl %eax, %edi
shlq %rdi
callq 0x13b0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0xbdca
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xbdca
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0xbdca
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0xbdca
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0xbdca
movq -0x10(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0xbdd6
movl $0x53, -0x4(%rbp)
jmp 0xbec2
movl $0x0, -0x18(%rbp)
cmpl $0x10000, -0x18(%rbp)   # imm = 0x10000
je 0xbe02
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x18(%rbp), %ecx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xbddd
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
je 0xbe2e
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x18(%rbp), %ecx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xbe09
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
je 0xbe5d
movl -0x18(%rbp), %eax
movw %ax, %dx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x18(%rbp), %ecx
movw %dx, (%rax,%rcx,2)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xbe35
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpq $0x102, %rax            # imm = 0x102
ja 0xbe8c
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x18(%rbp), %ecx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xbe64
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
je 0xbebb
movl -0x18(%rbp), %eax
movw %ax, %dx
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x18(%rbp), %ecx
movw %dx, (%rax,%rcx,2)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xbe93
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)