// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/extended/huffcode.c
// Function: gt_huffman_decoder_next
int gt_huffman_decoder_next(GtHuffmanDecoder *huff_decoder,
                            GtArray *symbols,
                            GtUword symbols_to_read,
                            GtError *err)
{
  int had_err = 0,
      bits_to_read = GT_INTWORDSIZE;
  GtUword read_symbols = 0;

  gt_assert((symbols_to_read > 0) && huff_decoder &&
            (gt_array_elem_size(symbols) == sizeof (GtUword)));

  if (huff_decoder->cur_bitseq == huff_decoder->length - 1)
    gt_safe_assign(bits_to_read, (GT_INTWORDSIZE - huff_decoder->pad_length));

  /* reached end of data in a previous call, didn't get reset */
  if (huff_decoder->cur_bitseq == huff_decoder->length) {
    if (!huff_decoder->mem_func)
      return 0;  /*EOF*/
    else if (huff_decoder->mem_func_stat == 0)
      return 0;
    else {
      had_err = -1;
      gt_error_set(err, "huff decoder reached EOF");
    }
  }

  while (!had_err && read_symbols < symbols_to_read) {

    /* huffman was initialized with empty dist */
    gt_assert(huff_decoder->cur_node != NULL);

    if (!had_err && huff_decoder->cur_bit == (GtUword) bits_to_read) {
      huff_decoder->cur_bitseq++;

      if (huff_decoder->cur_bitseq == huff_decoder->length - 1)
        gt_safe_assign(bits_to_read,
                       (GT_INTWORDSIZE - huff_decoder->pad_length));

      /* no next bitseq ask for more if possible */
      if (huff_decoder->cur_bitseq == huff_decoder->length ) {
        if (!huff_decoder->mem_func) {
          return 0;  /*EOF*/
        }

        huff_decoder->mem_func_stat =
          huff_decoder->mem_func(&huff_decoder->bitsequence,
                                 &huff_decoder->length,
                                 &huff_decoder->cur_bit,
                                 &huff_decoder->pad_length,
                                 huff_decoder->info);
        if (huff_decoder->mem_func_stat == -1) {
          gt_error_set(err, "error calling mem_func");
          had_err = huff_decoder->mem_func_stat;
        }
        else if (huff_decoder->mem_func_stat == 0) {
          return huff_decoder->mem_func_stat; /*EOF*/
        }

        huff_decoder->cur_bitseq = 0;
        bits_to_read = GT_INTWORDSIZE;
        if (huff_decoder->cur_bitseq == huff_decoder->length - 1)
          bits_to_read -= huff_decoder->pad_length;
      }
      huff_decoder->cur_bit = 0;
    }

    /* read the next bit */
    else if (!had_err) {
      /* nothing to do if huffman tree has only one node, just advance the bits
       */
      if (huff_decoder->cur_node->leftchild == NULL)
        huff_decoder->cur_bit++;
      else {
        if (GT_ISBITSET(huff_decoder->bitsequence[huff_decoder->cur_bitseq],
                        huff_decoder->cur_bit++))
          huff_decoder->cur_node = huff_decoder->cur_node->rightchild;
        else
          huff_decoder->cur_node = huff_decoder->cur_node->leftchild;
      }
    }

    /* symbol found, reset huffman */
    if (!had_err && huff_decoder->cur_node->leftchild == NULL) {
      gt_array_add(symbols, huff_decoder->cur_node->symbol.symbol);
      read_symbols++;
      huff_decoder->cur_node = huff_decoder->huffman->root_huffman_tree;
    }
  }
  if (!had_err) {
    /* all read, but not eof */
    return 1;
  }
  return had_err;
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
movq %rdx, 0x48(%rsp)
movq %rcx, 0x40(%rsp)
movl $0x0, 0x3c(%rsp)
movl $0x40, 0x38(%rsp)
movq $0x0, 0x30(%rsp)
cmpq $0x0, 0x48(%rsp)
jbe 0x192a01
cmpq $0x0, 0x58(%rsp)
je 0x192a01
movq 0x50(%rsp), %rdi
callq 0x813a0
cmpq $0x8, %rax
je 0x192a39
movq 0x4a9598(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x383601(%rip), %rsi    # 0x516013
leaq 0x3c421e(%rip), %rdx    # 0x556c37
leaq 0x3c4272(%rip), %rcx    # 0x556c92
leaq 0x3c4013(%rip), %r8     # 0x556a3a
movl $0x1fe, %r9d            # imm = 0x1FE
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x192a3b
movq 0x58(%rsp), %rax
movq 0x28(%rax), %rax
movq 0x58(%rsp), %rcx
movq 0x40(%rcx), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x192b03
jmp 0x192a5c
movq 0x58(%rsp), %rcx
movl $0x40, %eax
subq 0x38(%rcx), %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rax
movl %eax, 0x24(%rsp)
movq 0x28(%rsp), %rax
movslq 0x24(%rsp), %rcx
cmpq %rcx, %rax
jne 0x192ab7
cmpq $0x1, 0x28(%rsp)
setb %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, 0x24(%rsp)
setl %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0x192ab7
movl 0x24(%rsp), %eax
movl %eax, 0x38(%rsp)
xorl %eax, %eax
movl %eax, 0xc(%rsp)
jmp 0x192ac2
movl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x192ac2
movl 0xc(%rsp), %eax
movl %eax, 0x20(%rsp)
cmpl $0x0, 0x20(%rsp)
je 0x192aff
movq 0x4a94c8(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x385543(%rip), %rsi    # 0x518025
leaq 0x3c3f51(%rip), %rdx    # 0x556a3a
movl $0x201, %ecx            # imm = 0x201
movb $0x0, %al
callq 0x199f0
movl $0x1, %edi
callq 0x19890
jmp 0x192b01
jmp 0x192b03
movq 0x58(%rsp), %rax
movq 0x28(%rax), %rax
movq 0x58(%rsp), %rcx
cmpq 0x40(%rcx), %rax
jne 0x192b67
movq 0x58(%rsp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x192b30
movl $0x0, 0x64(%rsp)
jmp 0x192f03
movq 0x58(%rsp), %rax
cmpl $0x0, 0x48(%rax)
jne 0x192b48
movl $0x0, 0x64(%rsp)
jmp 0x192f03
movl $0xffffffff, 0x3c(%rsp) # imm = 0xFFFFFFFF
movq 0x40(%rsp), %rdi
leaq 0x3c414e(%rip), %rsi    # 0x556caa
movb $0x0, %al
callq 0xd88c0
jmp 0x192b65
jmp 0x192b67
jmp 0x192b69
xorl %eax, %eax
cmpl $0x0, 0x3c(%rsp)
movb %al, 0xb(%rsp)
jne 0x192b87
movq 0x30(%rsp), %rax
cmpq 0x48(%rsp), %rax
setb %al
movb %al, 0xb(%rsp)
movb 0xb(%rsp), %al
testb $0x1, %al
jne 0x192b94
jmp 0x192eea
jmp 0x192b96
movq 0x58(%rsp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x192bda
movq 0x4a93f7(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x383460(%rip), %rsi    # 0x516013
leaq 0x3c4109(%rip), %rdx    # 0x556cc3
leaq 0x3c40d1(%rip), %rcx    # 0x556c92
leaq 0x3c3e72(%rip), %r8     # 0x556a3a
movl $0x212, %r9d            # imm = 0x212
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x192bdc
cmpl $0x0, 0x3c(%rsp)
jne 0x192de9
movq 0x58(%rsp), %rax
movq 0x30(%rax), %rax
movslq 0x38(%rsp), %rcx
cmpq %rcx, %rax
jne 0x192de9
movq 0x58(%rsp), %rax
movq 0x28(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x28(%rax)
movq 0x58(%rsp), %rax
movq 0x28(%rax), %rax
movq 0x58(%rsp), %rcx
movq 0x40(%rcx), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x192cd7
jmp 0x192c30
movq 0x58(%rsp), %rcx
movl $0x40, %eax
subq 0x38(%rcx), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movl %eax, 0x14(%rsp)
movq 0x18(%rsp), %rax
movslq 0x14(%rsp), %rcx
cmpq %rcx, %rax
jne 0x192c8b
cmpq $0x1, 0x18(%rsp)
setb %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, 0x14(%rsp)
setl %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0x192c8b
movl 0x14(%rsp), %eax
movl %eax, 0x38(%rsp)
xorl %eax, %eax
movl %eax, 0x4(%rsp)
jmp 0x192c96
movl $0x1, %eax
movl %eax, 0x4(%rsp)
jmp 0x192c96
movl 0x4(%rsp), %eax
movl %eax, 0x10(%rsp)
cmpl $0x0, 0x10(%rsp)
je 0x192cd3
movq 0x4a92f4(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x38536f(%rip), %rsi    # 0x518025
leaq 0x3c3d7d(%rip), %rdx    # 0x556a3a
movl $0x219, %ecx            # imm = 0x219
movb $0x0, %al
callq 0x199f0
movl $0x1, %edi
callq 0x19890
jmp 0x192cd5
jmp 0x192cd7
movq 0x58(%rsp), %rax
movq 0x28(%rax), %rax
movq 0x58(%rsp), %rcx
cmpq 0x40(%rcx), %rax
jne 0x192dd7
movq 0x58(%rsp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x192d08
movl $0x0, 0x64(%rsp)
jmp 0x192f03
movq 0x58(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x58(%rsp), %rdi
movq 0x58(%rsp), %rsi
addq $0x40, %rsi
movq 0x58(%rsp), %rdx
addq $0x30, %rdx
movq 0x58(%rsp), %rcx
addq $0x38, %rcx
movq 0x58(%rsp), %r8
movq 0x20(%r8), %r8
callq *%rax
movl %eax, %ecx
movq 0x58(%rsp), %rax
movl %ecx, 0x48(%rax)
movq 0x58(%rsp), %rax
cmpl $-0x1, 0x48(%rax)
jne 0x192d72
movq 0x40(%rsp), %rdi
leaq 0x3c3df8(%rip), %rsi    # 0x556b55
movb $0x0, %al
callq 0xd88c0
movq 0x58(%rsp), %rax
movl 0x48(%rax), %eax
movl %eax, 0x3c(%rsp)
jmp 0x192d90
movq 0x58(%rsp), %rax
cmpl $0x0, 0x48(%rax)
jne 0x192d8e
movq 0x58(%rsp), %rax
movl 0x48(%rax), %eax
movl %eax, 0x64(%rsp)
jmp 0x192f03
jmp 0x192d90
movq 0x58(%rsp), %rax
movq $0x0, 0x28(%rax)
movl $0x40, 0x38(%rsp)
movq 0x58(%rsp), %rax
movq 0x28(%rax), %rax
movq 0x58(%rsp), %rcx
movq 0x40(%rcx), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x192dd5
movq 0x58(%rsp), %rax
movq 0x38(%rax), %rcx
movslq 0x38(%rsp), %rax
subq %rcx, %rax
movl %eax, 0x38(%rsp)
jmp 0x192dd7
movq 0x58(%rsp), %rax
movq $0x0, 0x30(%rax)
jmp 0x192e8a
cmpl $0x0, 0x3c(%rsp)
jne 0x192e88
movq 0x58(%rsp), %rax
movq 0x18(%rax), %rax
cmpq $0x0, 0x20(%rax)
jne 0x192e17
movq 0x58(%rsp), %rax
movq 0x30(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x30(%rax)
jmp 0x192e86
movq 0x58(%rsp), %rax
movq (%rax), %rax
movq 0x58(%rsp), %rcx
movq 0x28(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq 0x58(%rsp), %rdx
movq 0x30(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x30(%rdx)
shlq %cl, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
andq %rcx, %rax
cmpq $0x0, %rax
je 0x192e6e
movq 0x58(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x18(%rax)
jmp 0x192e84
movq 0x58(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x18(%rax)
jmp 0x192e86
jmp 0x192e88
jmp 0x192e8a
cmpl $0x0, 0x3c(%rsp)
jne 0x192ee5
movq 0x58(%rsp), %rax
movq 0x18(%rax), %rax
cmpq $0x0, 0x20(%rax)
jne 0x192ee5
movq 0x50(%rsp), %rdi
movq 0x58(%rsp), %rax
movq 0x18(%rax), %rsi
addq $0x10, %rsi
addq $0x8, %rsi
movl $0x8, %edx
callq 0x81100
movq 0x30(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x30(%rsp)
movq 0x58(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x18(%rax)
jmp 0x192b69
cmpl $0x0, 0x3c(%rsp)
jne 0x192efb
movl $0x1, 0x64(%rsp)
jmp 0x192f03
movl 0x3c(%rsp), %eax
movl %eax, 0x64(%rsp)
movl 0x64(%rsp), %eax
addq $0x68, %rsp
retq
nopl (%rax)