// File: /workspace/github_c_makefile_star2_O1/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, %r15
movq %r8, %r14
movq %rcx, %r13
movl %esi, %r12d
movl %edi, %ebp
movq 0x78(%rsp), %rax
movl $0x0, 0xc(%rsp)
movq 0x70(%rax), %rdi
movl $0x120, %esi            # imm = 0x120
movl $0x4, %edx
callq *0x60(%rax)
testq %rax, %rax
je 0x89ad
movq %rax, %rbx
movq %r15, 0x10(%rsp)
movq 0x58(%rsp), %r9
leaq 0xc(%rsp), %rax
leaq 0x18ad(%rip), %rcx      # 0xa190
leaq 0x1a66(%rip), %r8       # 0xa350
movq %r13, %rdi
movl %ebp, %esi
xorl %edx, %edx
pushq %rbx
pushq %rax
pushq 0x80(%rsp)
pushq %r14
callq 0x83e7
addq $0x20, %rsp
movl %eax, %r15d
cmpl $-0x4, %eax
je 0x89b5
leaq 0x2544(%rip), %rax      # 0xae5c
cmpl $-0x3, %r15d
je 0x89d4
testl %r15d, %r15d
jne 0x89cd
cmpl $0x0, (%r14)
je 0x89bc
movq 0x60(%rsp), %r9
movl %ebp, %eax
leaq (,%rax,4), %rdi
addq %r13, %rdi
leaq 0x1bc2(%rip), %rcx      # 0xa510
leaq 0x203b(%rip), %r8       # 0xa990
movl %r12d, %esi
movl $0x101, %edx            # imm = 0x101
pushq %rbx
leaq 0x14(%rsp), %rax
pushq %rax
pushq 0x80(%rsp)
pushq 0x28(%rsp)
callq 0x83e7
addq $0x20, %rsp
movl %eax, %r15d
leal 0x5(%r15), %ecx
cmpl $0x5, %ecx
movq 0x78(%rsp), %r8
ja 0x8a24
leaq 0x24fc(%rip), %rax      # 0xae90
leaq 0x17a5(%rip), %rdx      # 0xa140
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
leaq 0x250a(%rip), %rax      # 0xaeb5
jmp 0x89d9
movl $0xfffffffc, %r15d      # imm = 0xFFFFFFFC
jmp 0x89ee
movq 0x78(%rsp), %r8
jmp 0x89e3
cmpl $-0x4, %r15d
movq 0x78(%rsp), %r8
je 0x89e3
cmpl $-0x3, %r15d
je 0x89d4
leaq 0x24a4(%rip), %rax      # 0xae78
movq 0x78(%rsp), %r8
movq %rax, 0x50(%r8)
movl $0xfffffffd, %r15d      # imm = 0xFFFFFFFD
movq 0x70(%r8), %rdi
movq %rbx, %rsi
callq *0x68(%r8)
movl %r15d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x102, %ebp            # imm = 0x102
jb 0x8a2d
movq 0x10(%rsp), %rcx
cmpl $0x0, (%rcx)
jne 0x8a2d
cmpl $-0x3, %r15d
je 0x89d9
cmpl $-0x4, %r15d
je 0x89e3
cmpl $-0x5, %r15d
je 0x89a4
leaq 0x24ab(%rip), %rax      # 0xaed6
jmp 0x89d9
movq 0x68(%rsp), %rax
movq 0x50(%rsp), %rcx
movl $0x1, (%rcx)
leaq 0x774c(%rip), %rcx      # 0x10190
movq %rcx, (%rax)
xorl %r15d, %r15d
jmp 0x89e3