// File: /workspace/github_c_makefile_star2_O0/pje[P]pixelsort/lodepng.c
// Function: lodepng_deflatev
static unsigned lodepng_deflatev(ucvector* out, const unsigned char* in, size_t insize,
                                 const LodePNGCompressSettings* settings)
{
  unsigned error = 0;
  size_t i, blocksize, numdeflateblocks;
  size_t bp = 0; /*the bit pointer*/
  Hash hash;

  if(settings->btype > 2) return 61;
  else if(settings->btype == 0) return deflateNoCompression(out, in, insize);
  else if(settings->btype == 1) blocksize = insize;
  else /*if(settings->btype == 2)*/
  {
    blocksize = insize / 8 + 8;
    if(blocksize < 65535) blocksize = 65535;
  }

  numdeflateblocks = (insize + blocksize - 1) / blocksize;
  if(numdeflateblocks == 0) numdeflateblocks = 1;

  error = hash_init(&hash, settings->windowsize);
  if(error) return error;

  for(i = 0; i < numdeflateblocks && !error; i++)
  {
    unsigned final = (i == numdeflateblocks - 1);
    size_t start = i * blocksize;
    size_t end = start + blocksize;
    if(end > insize) end = insize;

    if(settings->btype == 1) error = deflateFixed(out, &bp, &hash, in, start, end, settings, final);
    else if(settings->btype == 2) error = deflateDynamic(out, &bp, &hash, in, start, end, settings, final);
  }

  hash_cleanup(&hash);

  return error;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x2, (%rax)
jbe 0x1d8f
movl $0x3d, -0x4(%rbp)
jmp 0x1f6e
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x1db1
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0xb310
movl %eax, -0x4(%rbp)
jmp 0x1f6e
movq -0x28(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x1dc4
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x1de8
movq -0x20(%rbp), %rax
shrq $0x3, %rax
addq $0x8, %rax
movq %rax, -0x40(%rbp)
cmpq $0xffff, -0x40(%rbp)    # imm = 0xFFFF
jae 0x1de6
movq $0xffff, -0x40(%rbp)    # imm = 0xFFFF
jmp 0x1de8
jmp 0x1dea
jmp 0x1dec
movq -0x20(%rbp), %rax
addq -0x40(%rbp), %rax
subq $0x1, %rax
xorl %ecx, %ecx
movl %ecx, %edx
divq -0x40(%rbp)
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x1e13
movq $0x1, -0x48(%rbp)
movq -0x28(%rbp), %rax
movl 0x8(%rax), %esi
leaq -0x80(%rbp), %rdi
callq 0xb490
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x1e37
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1f6e
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rcx
xorl %eax, %eax
cmpq -0x48(%rbp), %rcx
movb %al, -0x99(%rbp)
jae 0x1e60
cmpl $0x0, -0x2c(%rbp)
setne %al
xorb $-0x1, %al
movb %al, -0x99(%rbp)
movb -0x99(%rbp), %al
testb $0x1, %al
jne 0x1e6f
jmp 0x1f5f
movq -0x38(%rbp), %rax
movq -0x48(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x84(%rbp)
movq -0x38(%rbp), %rax
imulq -0x40(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
addq -0x40(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
cmpq -0x20(%rbp), %rax
jbe 0x1ec6
movq -0x20(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x1f09
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rcx
movq -0x90(%rbp), %r8
movq -0x98(%rbp), %r9
movq -0x28(%rbp), %r10
movl -0x84(%rbp), %eax
leaq -0x50(%rbp), %rsi
leaq -0x80(%rbp), %rdx
movq %r10, (%rsp)
movl %eax, 0x8(%rsp)
callq 0xb670
movl %eax, -0x2c(%rbp)
jmp 0x1f4c
movq -0x28(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x1f4a
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rcx
movq -0x90(%rbp), %r8
movq -0x98(%rbp), %r9
movq -0x28(%rbp), %r10
movl -0x84(%rbp), %eax
leaq -0x50(%rbp), %rsi
leaq -0x80(%rbp), %rdx
movq %r10, (%rsp)
movl %eax, 0x8(%rsp)
callq 0xb970
movl %eax, -0x2c(%rbp)
jmp 0x1f4c
jmp 0x1f4e
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x1e3f
leaq -0x80(%rbp), %rdi
callq 0xc680
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopw (%rax,%rax)