// File: /workspace/github_c_makefile_star2_O3/snej[P]zdelta/inftrees.c
// Function: inflate_trees_dynamic
int inflate_trees_dynamic(nl, nd, nzd, c, bl, bd, bzd, tl, td, tzd, hp, z)
uInt nl;                /* number of literal/length codes */
uInt nd;                /* number of distance codes */
uInt nzd;               /* number of zdelta  codes */
uIntf *c;               /* that many (total) code lengths */
uIntf *bl;              /* literal desired/actual bit depth */
uIntf *bd;              /* distance desired/actual bit depth */
uIntf *bzd;             /* zdelta codes desired/actual bit depth */
inflate_huft * FAR *tl; /* literal/length tree result */
inflate_huft * FAR *td; /* distance tree result */
inflate_huft * FAR *tzd;/* zdelta flags tree result */
inflate_huft *hp;       /* space for trees */
zd_streamp z;            /* for messages */
{
  int r;
  uInt hn = 0;          /* hufts used in space */
  uIntf *v;             /* work area for huft_build */

  /* allocate work area */
  if ((v = (uIntf*)ZALLOC(z, MAX_CODES, sizeof(uInt))) == ZD_NULL)
    return ZD_MEM_ERROR;

  /* build literal/length tree */
  r = huft_build(c, nl, 0, cplens, cplext, tl, bl, hp, &hn, v);
  if (r != ZD_OK || *bl == 0)
  {
    if (r == ZD_DATA_ERROR)
      z->msg = (char*)"oversubscribed length trees";
    else if (r != ZD_MEM_ERROR)
    {
      z->msg = (char*)"incomplete length trees";
      r = ZD_DATA_ERROR;
    }
    ZFREE(z, v);
    return r;
  }

  /* build distance tree */
  r = huft_build(c + nl, nd, 257, cpdist, cpdext, td, bd, hp, &hn, v);
  if (r != ZD_OK || (*bd == 0 && nl > 257))
  {
    if (r == ZD_DATA_ERROR)
      z->msg = (char*)"oversubscribed literal/distance tree";
    else if (r == ZD_BUF_ERROR) {
#ifdef PKZIP_BUG_WORKAROUND
      r = ZD_OK;
    }
#else
      z->msg = (char*)"incomplete literal/distance tree";
      r = ZD_DATA_ERROR;
    }
    else if (r != ZD_MEM_ERROR)
    {
      z->msg = (char*)"empty literal/distance tree with lengths";
      r = ZD_DATA_ERROR;
    }
    ZFREE(z, v);
    return r;
#endif
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %r14
movq %r8, %r13
movq %rcx, %r12
movl %esi, 0xc(%rsp)
movl %edi, %ebp
movq 0x78(%rsp), %r15
movl $0x0, 0x8(%rsp)
movq 0x70(%r15), %rdi
movl $0x120, %esi            # imm = 0x120
movl $0x4, %edx
callq *0x60(%r15)
testq %rax, %rax
je 0x8be2
movq %rax, %rbx
movq %r14, 0x10(%rsp)
movq 0x58(%rsp), %r9
leaq 0x8(%rsp), %rax
leaq 0x16f0(%rip), %rcx      # 0xa230
leaq 0x18a9(%rip), %r8       # 0xa3f0
movq %r12, %rdi
movl %ebp, %esi
xorl %edx, %edx
pushq %rbx
pushq %rax
pushq 0x80(%rsp)
pushq %r13
callq 0x862f
addq $0x20, %rsp
movl %eax, %r14d
cmpl $-0x4, %eax
je 0x8c04
cmpl $-0x3, %r14d
je 0x8bf3
testl %r14d, %r14d
jne 0x8bea
cmpl $0x0, (%r13)
je 0x8bea
movq 0x60(%rsp), %r9
movl %ebp, %eax
leaq (%r12,%rax,4), %rdi
leaq 0x1a1e(%rip), %rcx      # 0xa5b0
leaq 0x1e97(%rip), %r8       # 0xaa30
movl 0xc(%rsp), %esi
movl $0x101, %edx            # imm = 0x101
pushq %rbx
leaq 0x10(%rsp), %rax
pushq %rax
pushq 0x80(%rsp)
pushq 0x28(%rsp)
callq 0x862f
addq $0x20, %rsp
movl %eax, %r14d
leal 0x5(%r14), %eax
cmpl $0x5, %eax
ja 0x8c3c
leaq 0x1610(%rip), %rcx      # 0xa1e0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x2375(%rip), %rax      # 0xaf55
jmp 0x8bfa
movl $0xfffffffc, %r14d      # imm = 0xFFFFFFFC
jmp 0x8c0f
leaq 0x2327(%rip), %rax      # 0xaf18
jmp 0x8bfa
leaq 0x2302(%rip), %rax      # 0xaefc
movq %rax, 0x50(%r15)
movl $0xfffffffd, %r14d      # imm = 0xFFFFFFFD
movq 0x70(%r15), %rdi
movq %rbx, %rsi
callq *0x68(%r15)
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2308(%rip), %rax      # 0xaf30
jmp 0x8bfa
cmpl $0x102, %ebp            # imm = 0x102
jb 0x8c45
movq 0x10(%rsp), %rax
cmpl $0x0, (%rax)
jne 0x8c45
leaq 0x2333(%rip), %rax      # 0xaf76
jmp 0x8bfa
movq 0x68(%rsp), %rax
movq 0x50(%rsp), %rcx
movl $0x1, (%rcx)
leaq 0x7534(%rip), %rcx      # 0x10190
movq %rcx, (%rax)
xorl %r14d, %r14d
jmp 0x8c04