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

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

  newchain = pool->next++;
  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);
      /* Two lookahead chains of previous list used up, create new ones. */
      BoundaryPM(lists, leaves, numsymbols, pool, index - 1);
      BoundaryPM(lists, leaves, numsymbols, pool, index - 1);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl 0x10(%rax), %eax
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x1b697
movl -0x3c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jl 0x1b697
jmp 0x1b806
movq -0x20(%rbp), %rcx
movq (%rcx), %rax
movq %rax, %rdx
addq $0x18, %rdx
movq %rdx, (%rcx)
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rcx
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rcx
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
cmpl $0x0, -0x24(%rbp)
jne 0x1b720
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdi
movl -0x3c(%rbp), %esi
addl $0x1, %esi
movq -0x30(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
callq 0x1ba10
jmp 0x1b806
movq -0x8(%rbp), %rax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
movl -0x24(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
addq (%rcx), %rax
movq %rax, -0x48(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x1b7a4
movq -0x48(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq -0x3c(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpq (%rcx), %rax
jbe 0x1b7a4
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdi
movl -0x3c(%rbp), %esi
addl $0x1, %esi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x30(%rbp), %rcx
callq 0x1ba10
jmp 0x1b804
movq -0x48(%rbp), %rdi
movl -0x3c(%rbp), %esi
movq -0x8(%rbp), %rax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdx
movq -0x30(%rbp), %rcx
callq 0x1ba10
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movq -0x20(%rbp), %rcx
movl -0x24(%rbp), %r8d
subl $0x1, %r8d
callq 0x1b650
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movq -0x20(%rbp), %rcx
movl -0x24(%rbp), %r8d
subl $0x1, %r8d
callq 0x1b650
jmp 0x1b806
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)