// File: /workspace/github_c_makefile_star2_O0/madler[P]pigz/zopfli/src/zopfli/deflate.c
// Function: ZopfliDeflatePart
void ZopfliDeflatePart(const ZopfliOptions* options, int btype, int final,
                       const unsigned char* in, size_t instart, size_t inend,
                       unsigned char* bp, unsigned char** out,
                       size_t* outsize) {
  size_t i;
  /* byte coordinates rather than lz77 index */
  size_t* splitpoints_uncompressed = 0;
  size_t npoints = 0;
  size_t* splitpoints = 0;
  double totalcost = 0;
  ZopfliLZ77Store lz77;

  /* If btype=2 is specified, it tries all block types. If a lesser btype is
  given, then however it forces that one. Neither of the lesser types needs
  block splitting as they have no dynamic huffman trees. */
  if (btype == 0) {
    AddNonCompressedBlock(options, final, in, instart, inend, bp, out, outsize);
    return;
  } else if (btype == 1) {
    ZopfliLZ77Store store;
    ZopfliBlockState s;
    ZopfliInitLZ77Store(in, &store);
    ZopfliInitBlockState(options, instart, inend, 1, &s);

    ZopfliLZ77OptimalFixed(&s, in, instart, inend, &store);
    AddLZ77Block(options, btype, final, &store, 0, store.size, 0,
                 bp, out, outsize);

    ZopfliCleanBlockState(&s);
    ZopfliCleanLZ77Store(&store);
    return;
  }


  if (options->blocksplitting) {
    ZopfliBlockSplit(options, in, instart, inend,
                     options->blocksplittingmax,
                     &splitpoints_uncompressed, &npoints);
    splitpoints = (size_t*)malloc(sizeof(*splitpoints) * npoints);
  }

  ZopfliInitLZ77Store(in, &lz77);

  for (i = 0; i <= npoints; i++) {
    size_t start = i == 0 ? instart : splitpoints_uncompressed[i - 1];
    size_t end = i == npoints ? inend : splitpoints_uncompressed[i];
    ZopfliBlockState s;
    ZopfliLZ77Store store;
    ZopfliInitLZ77Store(in, &store);
    ZopfliInitBlockState(options, start, end, 1, &s);
    ZopfliLZ77Optimal(&s, in, start, end, options->numiterations, &store);
    totalcost += ZopfliCalculateBlockSizeAutoType(&store, 0, store.size);

    ZopfliAppendLZ77Store(&store, &lz77);
    if (i < npoints) splitpoints[i] = lz77.size;

    ZopfliCleanBlockState(&s);
    ZopfliCleanLZ77Store(&store);
  }

  /* Second block splitting attempt */
  if (options->blocksplitting && npoints > 1) {
    size_t* splitpoints2 = 0;
    size_t npoints2 = 0;
    double totalcost2 = 0;

    ZopfliBlockSplitLZ77(options, &lz77,
                         options->blocksplittingmax, &splitpoints2, &npoints2);

    for (i = 0; i <= npoints2; i++) {
      size_t start = i == 0 ? 0 : splitpoints2[i - 1];
      size_t end = i == npoints2 ? lz77.size : splitpoints2[i];
      totalcost2 += ZopfliCalculateBlockSizeAutoType(&lz77, start, end);
    }

    if (totalcost2 < totalcost) {
      free(splitpoints);
      splitpoints = splitpoints2;
      npoints = npoints2;
    } else {
      free(splitpoints2);
    }
  }

  for (i = 0; i <= npoints; i++) {
    size_t start = i == 0 ? 0 : splitpoints[i - 1];
    size_t end = i == npoints ? lz77.size : splitpoints[i];
    AddLZ77BlockAutoType(options, i == npoints && final,
                         &lz77, start, end, 0,
                         bp, out, outsize);
  }

  ZopfliCleanLZ77Store(&lz77);
  free(splitpoints);
  free(splitpoints_uncompressed);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x210, %rsp            # imm = 0x210
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x50(%rbp)
cmpl $0x0, -0xc(%rbp)
jne 0x12e15
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %esi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movq 0x10(%rbp), %r9
movq 0x18(%rbp), %r10
movq 0x20(%rbp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x13330
jmp 0x1331d
cmpl $0x1, -0xc(%rbp)
jne 0x12ecb
movq -0x18(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x16b40
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movl $0x1, %ecx
leaq -0x100(%rbp), %r8
callq 0x17b20
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
leaq -0x100(%rbp), %rdi
leaq -0xe0(%rbp), %r8
callq 0x1a300
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0xd0(%rbp), %r9
movq 0x10(%rbp), %r11
movq 0x18(%rbp), %r10
movq 0x20(%rbp), %rax
leaq -0xe0(%rbp), %rcx
xorl %r8d, %r8d
movq $0x0, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x13720
leaq -0x100(%rbp), %rdi
callq 0x17bb0
leaq -0xe0(%rbp), %rdi
callq 0x16bc0
jmp 0x1331d
jmp 0x12ecd
movq -0x8(%rbp), %rax
cmpl $0x0, 0xc(%rax)
je 0x12f11
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x8(%rbp), %rax
movslq 0x14(%rax), %r8
leaq -0x38(%rbp), %r9
leaq -0x40(%rbp), %rax
movq %rax, (%rsp)
callq 0x163d0
movq -0x40(%rbp), %rdi
shlq $0x3, %rdi
callq 0x33d0
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x16b40
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x40(%rbp), %rax
ja 0x13082
cmpq $0x0, -0x30(%rbp)
jne 0x12f4b
movq -0x20(%rbp), %rax
movq %rax, -0x1b8(%rbp)
jmp 0x12f62
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x1b8(%rbp)
movq -0x1b8(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x40(%rbp), %rax
jne 0x12f87
movq -0x28(%rbp), %rax
movq %rax, -0x1c0(%rbp)
jmp 0x12f9a
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x1c0(%rbp)
movq -0x1c0(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x16b40
movq -0x8(%rbp), %rdi
movq -0x108(%rbp), %rsi
movq -0x110(%rbp), %rdx
movl $0x1, %ecx
leaq -0x130(%rbp), %r8
callq 0x17b20
movq -0x18(%rbp), %rsi
movq -0x108(%rbp), %rdx
movq -0x110(%rbp), %rcx
movq -0x8(%rbp), %rax
movl 0x8(%rax), %r8d
leaq -0x130(%rbp), %rdi
leaq -0x178(%rbp), %r9
callq 0x198a0
movq -0x168(%rbp), %rdx
leaq -0x178(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x12ca0
addsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
leaq -0x178(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x176b0
movq -0x30(%rbp), %rax
cmpq -0x40(%rbp), %rax
jae 0x13059
movq -0x88(%rbp), %rdx
movq -0x48(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
leaq -0x130(%rbp), %rdi
callq 0x17bb0
leaq -0x178(%rbp), %rdi
callq 0x16bc0
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x12f29
movq -0x8(%rbp), %rax
cmpl $0x0, 0xc(%rax)
je 0x131f3
cmpq $0x1, -0x40(%rbp)
jbe 0x131f3
movq $0x0, -0x180(%rbp)
movq $0x0, -0x188(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x190(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movslq 0x14(%rax), %rdx
leaq -0x98(%rbp), %rsi
leaq -0x180(%rbp), %rcx
leaq -0x188(%rbp), %r8
callq 0x159a0
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x188(%rbp), %rax
ja 0x131b1
cmpq $0x0, -0x30(%rbp)
jne 0x1310d
xorl %eax, %eax
movq %rax, -0x1c8(%rbp)
jmp 0x13127
movq -0x180(%rbp), %rax
movq -0x30(%rbp), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x1c8(%rbp)
movq -0x1c8(%rbp), %rax
movq %rax, -0x198(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x188(%rbp), %rax
jne 0x13152
movq -0x88(%rbp), %rax
movq %rax, -0x1d0(%rbp)
jmp 0x13168
movq -0x180(%rbp), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x1d0(%rbp)
movq -0x1d0(%rbp), %rax
movq %rax, -0x1a0(%rbp)
movq -0x198(%rbp), %rsi
movq -0x1a0(%rbp), %rdx
leaq -0x98(%rbp), %rdi
callq 0x12ca0
addsd -0x190(%rbp), %xmm0
movsd %xmm0, -0x190(%rbp)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x130ea
movsd -0x190(%rbp), %xmm1
movsd -0x50(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x131e5
movq -0x48(%rbp), %rdi
callq 0x3050
movq -0x180(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x188(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x131f1
movq -0x180(%rbp), %rdi
callq 0x3050
jmp 0x131f3
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x40(%rbp), %rax
ja 0x132ff
cmpq $0x0, -0x30(%rbp)
jne 0x1321b
xorl %eax, %eax
movq %rax, -0x1d8(%rbp)
jmp 0x13232
movq -0x48(%rbp), %rax
movq -0x30(%rbp), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x1d8(%rbp)
movq -0x1d8(%rbp), %rax
movq %rax, -0x1a8(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x40(%rbp), %rax
jne 0x1325a
movq -0x88(%rbp), %rax
movq %rax, -0x1e0(%rbp)
jmp 0x1326d
movq -0x48(%rbp), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x1e0(%rbp)
movq -0x1e0(%rbp), %rax
movq %rax, -0x1b0(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1f0(%rbp)
movq -0x30(%rbp), %rcx
xorl %eax, %eax
cmpq -0x40(%rbp), %rcx
movb %al, -0x1e1(%rbp)
jne 0x132a5
cmpl $0x0, -0x10(%rbp)
setne %al
movb %al, -0x1e1(%rbp)
movq -0x1f0(%rbp), %rdi
movb -0x1e1(%rbp), %al
andb $0x1, %al
movzbl %al, %esi
movq -0x1a8(%rbp), %rcx
movq -0x1b0(%rbp), %r8
movq 0x10(%rbp), %r11
movq 0x18(%rbp), %r10
movq 0x20(%rbp), %rax
leaq -0x98(%rbp), %rdx
xorl %r9d, %r9d
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x13ac0
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x131fb
leaq -0x98(%rbp), %rdi
callq 0x16bc0
movq -0x48(%rbp), %rdi
callq 0x3050
movq -0x38(%rbp), %rdi
callq 0x3050
addq $0x210, %rsp            # imm = 0x210
popq %rbp
retq
nopw %cs:(%rax,%rax)