// File: /workspace/github_c_makefile_star2_O0/imaya[P]zopfli-for-emscripten/katajainen.c
// Function: BoundaryPM
static void BoundaryPM(Node* (*lists)[2], int maxbits,
    Node* leaves, int numsymbols, NodePool* pool, int index, char final) {
  Node* newchain;
  Node* oldchain;
  int lastcount = lists[index][1]->count;  /* Count of last chain of list. */

  if (index == 0 && lastcount >= numsymbols) return;

  newchain = GetFreeNode(lists, maxbits, pool);
  oldchain = lists[index][1];

  /* These are set up before the recursive calls below, so that there is a list
  pointing to the new node, to let the garbage collection know it's in use. */
  lists[index][0] = oldchain;
  lists[index][1] = newchain;

  if (index == 0) {
    /* New leaf node in list 0. */
    InitNode(leaves[lastcount].weight, lastcount + 1, 0, newchain);
  } else {
    size_t sum = lists[index - 1][0]->weight + lists[index - 1][1]->weight;
    if (lastcount < numsymbols && sum > leaves[lastcount].weight) {
      /* New leaf inserted in list, so count is incremented. */
      InitNode(leaves[lastcount].weight, lastcount + 1, oldchain->tail,
          newchain);
    } else {
      InitNode(sum, lastcount, lists[index - 1][1], newchain);
      if (!final) {
        /* Two lookahead chains of previous list used up, create new ones. */
        BoundaryPM(lists, maxbits, leaves, numsymbols, pool, index - 1, 0);
        BoundaryPM(lists, maxbits, leaves, numsymbols, pool, index - 1, 0);
      }
    }
  }
}

// Assembly:
subq $0x58, %rsp
movb 0x60(%rsp), %al
movq %rdi, 0x50(%rsp)
movl %esi, 0x4c(%rsp)
movq %rdx, 0x40(%rsp)
movl %ecx, 0x3c(%rsp)
movq %r8, 0x30(%rsp)
movl %r9d, 0x2c(%rsp)
movq 0x50(%rsp), %rax
movslq 0x2c(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl 0x10(%rax), %eax
movl %eax, 0x14(%rsp)
cmpl $0x0, 0x2c(%rsp)
jne 0x7426
movl 0x14(%rsp), %eax
cmpl 0x3c(%rsp), %eax
jl 0x7426
jmp 0x75ea
movq 0x50(%rsp), %rdi
movl 0x4c(%rsp), %esi
movq 0x30(%rsp), %rdx
callq 0x7670
movq %rax, 0x20(%rsp)
movq 0x50(%rsp), %rax
movslq 0x2c(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rcx
movq 0x50(%rsp), %rax
movslq 0x2c(%rsp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq 0x20(%rsp), %rcx
movq 0x50(%rsp), %rax
movslq 0x2c(%rsp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
cmpl $0x0, 0x2c(%rsp)
jne 0x74c0
movq 0x40(%rsp), %rax
movslq 0x14(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdi
movl 0x14(%rsp), %esi
addl $0x1, %esi
movq 0x20(%rsp), %rcx
xorl %eax, %eax
movl %eax, %edx
callq 0x77d0
jmp 0x75ea
movq 0x50(%rsp), %rax
movl 0x2c(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq (%rax), %rax
movq 0x50(%rsp), %rcx
movl 0x2c(%rsp), %edx
subl $0x1, %edx
movslq %edx, %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
addq (%rcx), %rax
movq %rax, 0x8(%rsp)
movl 0x14(%rsp), %eax
cmpl 0x3c(%rsp), %eax
jge 0x7556
movq 0x8(%rsp), %rax
movq 0x40(%rsp), %rcx
movslq 0x14(%rsp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpq (%rcx), %rax
jbe 0x7556
movq 0x40(%rsp), %rax
movslq 0x14(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdi
movl 0x14(%rsp), %esi
addl $0x1, %esi
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rdx
movq 0x20(%rsp), %rcx
callq 0x77d0
jmp 0x75e8
movq 0x8(%rsp), %rdi
movl 0x14(%rsp), %esi
movq 0x50(%rsp), %rax
movl 0x2c(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdx
movq 0x20(%rsp), %rcx
callq 0x77d0
cmpb $0x0, 0x60(%rsp)
jne 0x75e6
movq 0x50(%rsp), %rdi
movl 0x4c(%rsp), %esi
movq 0x40(%rsp), %rdx
movl 0x3c(%rsp), %ecx
movq 0x30(%rsp), %r8
movl 0x2c(%rsp), %r9d
subl $0x1, %r9d
xorl %eax, %eax
movl $0x0, (%rsp)
callq 0x73d0
movq 0x50(%rsp), %rdi
movl 0x4c(%rsp), %esi
movq 0x40(%rsp), %rdx
movl 0x3c(%rsp), %ecx
movq 0x30(%rsp), %r8
movl 0x2c(%rsp), %r9d
subl $0x1, %r9d
xorl %eax, %eax
movl $0x0, (%rsp)
callq 0x73d0
jmp 0x75e8
jmp 0x75ea
addq $0x58, %rsp
retq
nop