// File: /workspace/github_c_makefile_star2_O0/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: deflateNoCompression
static unsigned deflateNoCompression(ucvector* out, const unsigned char* data, size_t datasize)
{
  /*non compressed deflate block data: 1 bit BFINAL,2 bits BTYPE,(5 bits): it jumps to start of next byte,
  2 bytes LEN, 2 bytes NLEN, LEN bytes literal DATA*/

  size_t i, j, numdeflateblocks = (datasize + 65534) / 65535;
  unsigned datapos = 0;
  for(i = 0; i != numdeflateblocks; ++i)
  {
    unsigned BFINAL, BTYPE, LEN, NLEN;
    unsigned char firstbyte;

    BFINAL = (i == numdeflateblocks - 1);
    BTYPE = 0;

    firstbyte = (unsigned char)(BFINAL + ((BTYPE & 1) << 1) + ((BTYPE & 2) << 1));
    ucvector_push_back(out, firstbyte);

    LEN = 65535;
    if(datasize - datapos < 65535) LEN = (unsigned)datasize - datapos;
    NLEN = 65535 - LEN;

    ucvector_push_back(out, (unsigned char)(LEN & 255));
    ucvector_push_back(out, (unsigned char)(LEN >> 8));
    ucvector_push_back(out, (unsigned char)(NLEN & 255));
    ucvector_push_back(out, (unsigned char)(NLEN >> 8));

    /*Decompressed data*/
    for(j = 0; j < 65535 && datapos < datasize; ++j)
    {
      ucvector_push_back(out, data[datapos++]);
    }
  }

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rax
addq $0xfffe, %rax           # imm = 0xFFFE
movl $0xffff, %ecx           # imm = 0xFFFF
xorl %edx, %edx
divq %rcx
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x30(%rbp), %rax
je 0xbce7
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x38(%rbp), %eax
movl -0x3c(%rbp), %ecx
andl $0x1, %ecx
shll %ecx
addl %ecx, %eax
movl -0x3c(%rbp), %ecx
andl $0x2, %ecx
shll %ecx
addl %ecx, %eax
movb %al, -0x45(%rbp)
movq -0x8(%rbp), %rdi
movzbl -0x45(%rbp), %esi
callq 0x2660
movl $0xffff, -0x40(%rbp)    # imm = 0xFFFF
movq -0x18(%rbp), %rax
movl -0x34(%rbp), %ecx
subq %rcx, %rax
cmpq $0xffff, %rax           # imm = 0xFFFF
jae 0xbc24
movq -0x18(%rbp), %rax
subl -0x34(%rbp), %eax
movl %eax, -0x40(%rbp)
movl $0xffff, %eax           # imm = 0xFFFF
subl -0x40(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rdi
movl -0x40(%rbp), %eax
andl $0xff, %eax
movzbl %al, %esi
callq 0x2660
movq -0x8(%rbp), %rdi
movl -0x40(%rbp), %eax
shrl $0x8, %eax
movzbl %al, %esi
callq 0x2660
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %eax
andl $0xff, %eax
movzbl %al, %esi
callq 0x2660
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %eax
shrl $0x8, %eax
movzbl %al, %esi
callq 0x2660
movq $0x0, -0x28(%rbp)
xorl %eax, %eax
cmpq $0xffff, -0x28(%rbp)    # imm = 0xFFFF
movb %al, -0x46(%rbp)
jae 0xbc9f
movl -0x34(%rbp), %eax
cmpq -0x18(%rbp), %rax
setb %al
movb %al, -0x46(%rbp)
movb -0x46(%rbp), %al
testb $0x1, %al
jne 0xbca8
jmp 0xbcd4
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x34(%rbp)
movl %ecx, %ecx
movzbl (%rax,%rcx), %esi
callq 0x2660
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0xbc83
jmp 0xbcd6
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0xbbab
xorl %eax, %eax
addq $0x50, %rsp
popq %rbp
retq
nop