// File: lvandeve[P]lodepng/lodepng.cpp
// Function: inflateNoCompression(ucvector*, LodePNGBitReader*, LodePNGDecompressSettings const*)
static unsigned inflateNoCompression(ucvector* out, LodePNGBitReader* reader,
                                     const LodePNGDecompressSettings* settings) {
  size_t bytepos;
  size_t size = reader->size;
  unsigned LEN, NLEN, error = 0;

  /*go to first boundary of byte*/
  bytepos = (reader->bp + 7u) >> 3u;

  /*read LEN (2 bytes) and NLEN (2 bytes)*/
  if(bytepos + 4 >= size) return 52; /*error, bit pointer will jump past memory*/
  LEN = (unsigned)reader->data[bytepos] + ((unsigned)reader->data[bytepos + 1] << 8u); bytepos += 2;
  NLEN = (unsigned)reader->data[bytepos] + ((unsigned)reader->data[bytepos + 1] << 8u); bytepos += 2;

  /*check if 16-bit NLEN is really the one's complement of LEN*/
  if(!settings->ignore_nlen && LEN + NLEN != 65535) {
    return 21; /*error: NLEN is not one's complement of LEN*/
  }

  if(!ucvector_resize(out, out->size + LEN)) return 83; /*alloc fail*/

  /*read the literal data: LEN bytes are now stored in the out buffer*/
  if(bytepos + LEN > size) return 23; /*error: reading outside of in buffer*/

  /*out->data can be NULL (when LEN is zero), and arithmetics on NULL ptr is undefined*/
  if (LEN) {
    lodepng_memcpy(out->data + out->size - LEN, reader->data + bytepos, LEN);
    bytepos += LEN;
  }

  reader->bp = bytepos << 3u;

  return error;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x3c(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
addq $0x7, %rax
shrq $0x3, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
addq $0x4, %rax
cmpq -0x30(%rbp), %rax
jb 0x12625
movl $0x34, -0x4(%rbp)
jmp 0x12744
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
movq -0x28(%rbp), %rdx
movzbl 0x1(%rcx,%rdx), %ecx
shll $0x8, %ecx
addl %ecx, %eax
movl %eax, -0x34(%rbp)
movq -0x28(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
movq -0x28(%rbp), %rdx
movzbl 0x1(%rcx,%rdx), %ecx
shll $0x8, %ecx
addl %ecx, %eax
movl %eax, -0x38(%rbp)
movq -0x28(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jne 0x126ae
movl -0x34(%rbp), %eax
addl -0x38(%rbp), %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x126ae
movl $0x15, -0x4(%rbp)
jmp 0x12744
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movl -0x34(%rbp), %eax
addq %rax, %rsi
callq 0x12cb0
cmpl $0x0, %eax
jne 0x126d3
movl $0x53, -0x4(%rbp)
jmp 0x12744
movq -0x28(%rbp), %rax
movl -0x34(%rbp), %ecx
addq %rcx, %rax
cmpq -0x30(%rbp), %rax
jbe 0x126ec
movl $0x17, -0x4(%rbp)
jmp 0x12744
cmpl $0x0, -0x34(%rbp)
je 0x1272e
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
addq 0x8(%rax), %rdi
movl -0x34(%rbp), %eax
movl %eax, %ecx
xorl %eax, %eax
subq %rcx, %rax
addq %rax, %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
addq -0x28(%rbp), %rsi
movl -0x34(%rbp), %eax
movl %eax, %edx
callq 0x5820
movl -0x34(%rbp), %eax
addq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rcx
shlq $0x3, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)