// File: /workspace/github_c_makefile_star2_O2/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
andl $0x0, 0x8(%rsp)
movq 0x70(%r15), %rdi
pushq $0x4
popq %rdx
movl $0x120, %esi            # imm = 0x120
callq *0x60(%r15)
testq %rax, %rax
je 0x86d8
movq %rax, %rbx
movq %r14, 0x10(%rsp)
movq 0x58(%rsp), %r9
leaq 0x8(%rsp), %rax
leaq 0x1b5a(%rip), %rcx      # 0xa190
leaq 0x1d13(%rip), %r8       # 0xa350
movq %r12, %rdi
movl %ebp, %esi
xorl %edx, %edx
pushq %rbx
pushq %rax
pushq 0x80(%rsp)
pushq %r13
callq 0x80bb
addq $0x20, %rsp
movl %eax, %r14d
cmpl $-0x4, %eax
je 0x86f6
cmpl $-0x3, %r14d
je 0x86e7
testl %r14d, %r14d
jne 0x86de
cmpl $0x0, (%r13)
je 0x86de
movq 0x60(%rsp), %r9
movl %ebp, %eax
leaq (%r12,%rax,4), %rdi
leaq 0x1e88(%rip), %rcx      # 0xa510
leaq 0x2301(%rip), %r8       # 0xa990
movl 0xc(%rsp), %esi
movl $0x101, %edx            # imm = 0x101
pushq %rbx
leaq 0x10(%rsp), %rax
pushq %rax
pushq 0x80(%rsp)
pushq 0x28(%rsp)
callq 0x80bb
addq $0x20, %rsp
movl %eax, %r14d
leal 0x5(%r14), %eax
cmpl $0x5, %eax
ja 0x872e
leaq 0x1a7a(%rip), %rcx      # 0xa140
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x27df(%rip), %rax      # 0xaeb5
jmp 0x86ee
pushq $-0x4
popq %r14
jmp 0x8701
leaq 0x2793(%rip), %rax      # 0xae78
jmp 0x86ee
leaq 0x276e(%rip), %rax      # 0xae5c
movq %rax, 0x50(%r15)
pushq $-0x3
popq %r14
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 0x2776(%rip), %rax      # 0xae90
jmp 0x86ee
cmpl $0x102, %ebp            # imm = 0x102
jb 0x8737
movq 0x10(%rsp), %rax
cmpl $0x0, (%rax)
jne 0x8737
leaq 0x27a1(%rip), %rax      # 0xaed6
jmp 0x86ee
movq 0x68(%rsp), %rax
movq 0x50(%rsp), %rcx
movl $0x1, (%rcx)
leaq 0x7a42(%rip), %rcx      # 0x10190
movq %rcx, (%rax)
xorl %r14d, %r14d
jmp 0x86f6
nop