// File: /workspace/github_cpp_makefile_star2_O2/mhe[P]raytracerframework_cpp/lodepng.cpp
// Function: LodeFlate_inflate(ucvector*, unsigned char const*, unsigned long, unsigned long)
unsigned LodeFlate_inflate(ucvector* out, const unsigned char* in, size_t insize, size_t inpos)
{
  size_t bp = 0; /*bit pointer in the "in" data, current byte is bp >> 3, current bit is bp & 0x7 (from lsb to msb of the byte)*/
  unsigned BFINAL = 0;
  size_t pos = 0; /*byte position in the out buffer*/
  
  unsigned error = 0;
  
  while(!BFINAL)
  {
    unsigned BTYPE;
    if((bp >> 3) >= insize) return 52; /*error, bit pointer will jump past memory*/
    BFINAL = readBitFromStream(&bp, &in[inpos]);
    BTYPE = 1 * readBitFromStream(&bp, &in[inpos]); BTYPE += 2 * readBitFromStream(&bp, &in[inpos]);

    if(BTYPE == 3) return 20; /*error: invalid BTYPE*/
    else if(BTYPE == 0) error = inflateNoCompression(out, &in[inpos], &bp, &pos, insize); /*no compression*/
    else error = inflateHuffmanBlock(out, &in[inpos], &bp, &pos, insize, BTYPE); /*compression, BTYPE 01 or 10*/
    if(error) return error;
  }
  
  if(!ucvector_resize(out, pos)) error = 9916; /*Only now we know the true size of out, resize it to that*/
  
  return error;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
movq %rdx, %r15
leaq -0x30(%rbp), %rax
andq $0x0, (%rax)
leaq (%rsi,%rcx), %rax
movq %rax, -0x40(%rbp)
leaq -0x4(%rdx), %rax
movq %rax, -0x100(%rbp)
leaq -0x2(%rdx), %rax
movq %rax, -0xf0(%rbp)
leaq (%rsi,%rcx), %rax
addq $0x4, %rax
movq %rax, -0xf8(%rbp)
xorl %r13d, %r13d
xorl %r9d, %r9d
movq %rdi, -0x60(%rbp)
movq %rdx, -0x70(%rbp)
testl %r9d, %r9d
jne 0x10b9a
movq -0x30(%rbp), %rax
movq %rax, %rcx
shrq $0x3, %rcx
cmpq %r15, %rcx
jae 0x10b96
movq -0x40(%rbp), %r8
movzbl (%r8,%rcx), %ecx
movl %eax, %edx
andl $0x7, %edx
xorl %r9d, %r9d
btl %edx, %ecx
setb %r10b
leaq 0x1(%rax), %rcx
movq %rcx, %rdx
shrq $0x3, %rdx
movzbl (%r8,%rdx), %edx
andl $0x7, %ecx
btl %ecx, %edx
setb %sil
leaq 0x2(%rax), %r14
movq %r14, %rcx
shrq $0x3, %rcx
movb (%r8,%rcx), %dl
movl %r14d, %ecx
andb $0x7, %cl
shrb %cl, %dl
addq $0x3, %rax
movq %rax, -0x30(%rbp)
addb %dl, %dl
andb $0x2, %dl
orb %sil, %dl
testb %dl, %dl
je 0x10479
movzbl %dl, %ecx
cmpl $0x3, %ecx
je 0x10bb2
andl $0x0, -0x44(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x1a0(%rbp)
movaps %xmm0, -0x190(%rbp)
movaps %xmm0, -0x180(%rbp)
movaps %xmm0, -0x170(%rbp)
andq $0x0, -0x160(%rbp)
movaps %xmm0, -0x150(%rbp)
movaps %xmm0, -0x140(%rbp)
movaps %xmm0, -0x130(%rbp)
movaps %xmm0, -0x120(%rbp)
andq $0x0, -0x110(%rbp)
cmpb $0x2, %dl
movb %r10b, -0x31(%rbp)
je 0x10530
xorl %r14d, %r14d
cmpl $0x1, %ecx
jne 0x109a4
leaq -0x1a0(%rbp), %rdi
callq 0x16457
leaq -0x150(%rbp), %rdi
callq 0x16505
jmp 0x109a4
movq %rax, %rbx
incq %r14
incq %rax
testb $0x7, %r14b
jne 0x10479
shrq $0x3, %r14
cmpq -0x100(%rbp), %r14
jae 0x10b96
movq -0x40(%rbp), %rcx
movzwl (%rcx,%r14), %eax
movzwl 0x2(%rcx,%r14), %ecx
addl %eax, %ecx
cmpl $0xffff, %ecx           # imm = 0xFFFF
jne 0x10bb6
movl %eax, %r12d
leaq (%r12,%r13), %rsi
cmpq 0x8(%rdi), %rsi
jb 0x104e1
movl %r10d, %r15d
callq 0x10bdb
movl %r15d, %r10d
movq -0x70(%rbp), %r15
xorl %r9d, %r9d
movq -0x60(%rbp), %rdi
testl %eax, %eax
je 0x10bd3
addq $0x4, %r14
addq %r12, %r14
cmpq %r15, %r14
ja 0x10bba
movq %rbx, %rax
shrq $0x3, %rax
addq -0xf8(%rbp), %rax
andq $-0x8, %rbx
addq $0x20, %rbx
xorl %ecx, %ecx
cmpl %ecx, %r12d
je 0x10524
movb (%rax,%rcx), %dl
movq (%rdi), %rsi
movb %dl, (%rsi,%r13)
incq %r13
addq $0x8, %rbx
incq %rcx
jmp 0x10509
movq %rbx, -0x30(%rbp)
xorl %r14d, %r14d
jmp 0x10b88
movaps %xmm0, -0x1c0(%rbp)
movaps %xmm0, -0x1d0(%rbp)
movaps %xmm0, -0x1e0(%rbp)
andq $0x0, -0x1b0(%rbp)
movaps %xmm0, -0x1f0(%rbp)
shrq $0x3, %rax
pushq $0x31
popq %r14
cmpq -0xf0(%rbp), %rax
jae 0x10994
leaq -0x30(%rbp), %rbx
movq %rbx, %rdi
movq -0x40(%rbp), %r14
movq %r14, %rsi
pushq $0x5
popq %r12
movq %r12, %rdx
callq 0x16414
movq %rax, -0x88(%rbp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x16414
movl %eax, %r12d
movq %rbx, %rdi
movq %r14, %rsi
pushq $0x4
popq %rdx
callq 0x16414
movl %eax, %ebx
xorps %xmm0, %xmm0
movaps %xmm0, -0xa0(%rbp)
andq $0x0, -0x90(%rbp)
leaq -0xa0(%rbp), %rdi
pushq $0x13
popq %rsi
callq 0x16562
testl %eax, %eax
je 0x1063c
movq %r12, -0x58(%rbp)
addl $0x4, %ebx
movq -0xa0(%rbp), %r14
leaq 0x124cb(%rip), %r12     # 0x22ab0
xorl %r15d, %r15d
cmpq $0x13, %r15
je 0x10616
xorl %eax, %eax
cmpq %rbx, %r15
jae 0x10605
leaq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
pushq $0x3
popq %rdx
callq 0x16414
movl (%r12), %ecx
movl %eax, (%r14,%rcx,4)
incq %r15
addq $0x4, %r12
jmp 0x105e8
movq -0x98(%rbp), %rdx
leaq -0x1f0(%rbp), %rdi
movq %r14, %rsi
pushq $0x7
popq %rcx
callq 0x165b5
movl %eax, %r14d
movq -0x70(%rbp), %r15
movq -0x58(%rbp), %r12
jmp 0x10642
movl $0x26b7, %r14d          # imm = 0x26B7
movl %r14d, -0x48(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x16628
testl %r14d, %r14d
jne 0x10994
xorps %xmm0, %xmm0
movaps %xmm0, -0xe0(%rbp)
andq $0x0, -0xd0(%rbp)
movl $0x120, %esi            # imm = 0x120
leaq -0xe0(%rbp), %rdi
callq 0x16846
xorps %xmm0, %xmm0
movaps %xmm0, -0xc0(%rbp)
andq $0x0, -0xb0(%rbp)
leaq -0xc0(%rbp), %rdi
pushq $0x20
popq %rsi
callq 0x16846
movq -0xe0(%rbp), %rax
movq %rax, -0x50(%rbp)
testq %rax, %rax
setne %al
movq -0xc0(%rbp), %rcx
movq %rcx, -0x80(%rbp)
testq %rcx, %rcx
setne %cl
andb %al, %cl
movl $0x26b8, %r14d          # imm = 0x26B8
cmpb $0x1, %cl
jne 0x1097c
movq -0x88(%rbp), %rax
leal 0x101(%rax), %ecx
incl %r12d
addl %ecx, %r12d
movl %ecx, -0x64(%rbp)
movl %ecx, %edi
movl $0xfffffeff, %r9d       # imm = 0xFFFFFEFF
subl %eax, %r9d
xorl %r14d, %r14d
movb $0x1, %al
xorl %ebx, %ebx
movq %r12, -0x58(%rbp)
movq %r9, -0x78(%rbp)
cmpl %r12d, %ebx
jae 0x1091f
movq %rdi, %r12
leaq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
leaq -0x30(%rbp), %rdx
leaq -0x1f0(%rbp), %rcx
movq %r15, %r8
callq 0x1638a
movl -0x48(%rbp), %r14d
testl %r14d, %r14d
jne 0x1097c
cmpl $0xf, %eax
ja 0x10764
movq %r12, %rdi
xorl %r14d, %r14d
movl -0x64(%rbp), %ecx
cmpl %ecx, %ebx
cmovbl %r14d, %ecx
movq -0x80(%rbp), %rdx
cmovbq -0x50(%rbp), %rdx
movl %ebx, %esi
subl %ecx, %esi
movl %eax, (%rdx,%rsi,4)
incl %ebx
movb $0x1, %al
movq -0x58(%rbp), %r12
jmp 0x10702
movq %rbx, -0xe8(%rbp)
movl %ebx, %ebx
cmpl $0x12, %eax
movq -0x80(%rbp), %r14
je 0x1087a
cmpl $0x11, %eax
je 0x10816
cmpl $0x10, %eax
jne 0x10978
movq -0x30(%rbp), %rax
shrq $0x3, %rax
cmpq %r15, %rax
jae 0x10974
leaq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
pushq $0x2
popq %rdx
callq 0x16414
movq %r12, %rdi
addl $0x3, %eax
movq -0xe8(%rbp), %rdx
leal -0x1(%rdx), %ecx
subl -0x88(%rbp), %edx
addl $0xfffffefe, %edx       # imm = 0xFFFFFEFE
cmpl -0x64(%rbp), %ecx
movq -0x50(%rbp), %rsi
leaq (%rsi,%rcx,4), %rcx
leaq (%r14,%rdx,4), %rdx
cmovbq %rcx, %rdx
movl (%rdx), %ecx
leaq (%rsi,%rbx,4), %rdx
movq -0x58(%rbp), %r12
movq -0x78(%rbp), %r9
subl $0x1, %eax
jb 0x108d6
cmpq %rbx, %r12
je 0x108f5
leal (%r9,%rbx), %esi
cmpq %rdi, %rbx
leaq (%r14,%rsi,4), %rsi
cmovbq %rdx, %rsi
movl %ecx, (%rsi)
incq %rbx
addq $0x4, %rdx
jmp 0x107ea
movq -0x30(%rbp), %rax
shrq $0x3, %rax
cmpq %r15, %rax
jae 0x10974
leaq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
pushq $0x3
popq %rdx
callq 0x16414
movq %r12, %rdi
addl $0x3, %eax
movq -0x50(%rbp), %rcx
leaq (%rcx,%rbx,4), %rcx
movq -0x58(%rbp), %r12
movq -0x78(%rbp), %r9
subl $0x1, %eax
jb 0x108d6
cmpq %rbx, %r12
je 0x108e0
leal (%r9,%rbx), %edx
cmpq %rdi, %rbx
leaq (%r14,%rdx,4), %rdx
cmovbq %rcx, %rdx
andl $0x0, (%rdx)
incq %rbx
addq $0x4, %rcx
jmp 0x1084d
movq -0x30(%rbp), %rax
shrq $0x3, %rax
cmpq %r15, %rax
jae 0x10974
leaq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
pushq $0x7
popq %rdx
callq 0x16414
movq %r12, %rdi
addl $0xb, %eax
movq -0x50(%rbp), %rcx
leaq (%rcx,%rbx,4), %rcx
movq -0x58(%rbp), %r12
movq -0x78(%rbp), %r9
subl $0x1, %eax
jb 0x108d6
cmpq %rbx, %r12
je 0x1090a
leal (%r9,%rbx), %edx
cmpq %rdi, %rbx
leaq (%r14,%rdx,4), %rdx
cmovbq %rcx, %rdx
andl $0x0, (%rdx)
incq %rbx
addq $0x4, %rcx
jmp 0x108b1
movb $0x1, %al
xorl %r14d, %r14d
jmp 0x10702
movl $0xe, -0x48(%rbp)
xorl %eax, %eax
pushq $0xe
popq %r14
movl %r12d, %ebx
jmp 0x10702
movl $0xd, -0x48(%rbp)
xorl %eax, %eax
pushq $0xd
popq %r14
movl %r12d, %ebx
jmp 0x10702
movl $0xf, -0x48(%rbp)
xorl %eax, %eax
pushq $0xf
popq %r14
movl %r12d, %ebx
jmp 0x10702
testb $0x1, %al
je 0x1097c
movq -0x50(%rbp), %rax
cmpl $0x0, 0x400(%rax)
pushq $0x40
popq %r14
je 0x1097c
movq -0xd8(%rbp), %rdx
leaq -0x1a0(%rbp), %rdi
movq -0x50(%rbp), %rsi
pushq $0xf
popq %rcx
callq 0x165b5
movl %eax, %r14d
testl %eax, %eax
jne 0x1097c
movq -0xb8(%rbp), %rdx
leaq -0x150(%rbp), %rdi
movq -0x80(%rbp), %rsi
pushq $0xf
popq %rcx
callq 0x165b5
movl %eax, %r14d
jmp 0x1097c
pushq $0x32
jmp 0x1097a
pushq $0x10
popq %r14
leaq -0xe0(%rbp), %rdi
callq 0x16628
leaq -0xc0(%rbp), %rdi
callq 0x16628
movl %r14d, -0x44(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x16361
xorl %eax, %eax
orl %r14d, %eax
jne 0x10b65
leaq -0x44(%rbp), %rdi
movq -0x40(%rbp), %rsi
leaq -0x30(%rbp), %rdx
leaq -0x1a0(%rbp), %rcx
movq %r15, %r8
callq 0x1638a
movl -0x44(%rbp), %r14d
testl %r14d, %r14d
jne 0x10b65
movl %eax, %ebx
xorl %r14d, %r14d
pushq $0x1
popq %rax
cmpl $0x100, %ebx            # imm = 0x100
je 0x109a6
jb 0x10b05
xorl %r14d, %r14d
movl $0x0, %eax
cmpl $0x11d, %ebx            # imm = 0x11D
ja 0x109a6
movq -0x30(%rbp), %rax
shrq $0x3, %rax
cmpq %r15, %rax
jae 0x10b49
addl $0xfffffeff, %ebx       # imm = 0xFFFFFEFF
leaq 0x11f15(%rip), %rax     # 0x22930
movl (%rax,%rbx,4), %edx
leaq 0x11e8b(%rip), %rax     # 0x228b0
movl (%rax,%rbx,4), %r12d
leaq -0x30(%rbp), %rdi
movq -0x40(%rbp), %r14
movq %r14, %rsi
callq 0x16414
movl %eax, %ebx
leaq -0x44(%rbp), %rdi
movq %r14, %rsi
leaq -0x30(%rbp), %rdx
leaq -0x150(%rbp), %rcx
movq %r15, %r8
callq 0x1638a
movl -0x44(%rbp), %r14d
testl %r14d, %r14d
jne 0x10b65
cmpl $0x1d, %eax
ja 0x10b55
movq -0x30(%rbp), %rcx
shrq $0x3, %rcx
cmpq %r15, %rcx
jae 0x10b49
movl %ebx, %r14d
addq %r12, %r14
movl %eax, %r15d
leaq 0x11fa4(%rip), %rax     # 0x22a30
movl (%rax,%r15,4), %edx
leaq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x16414
movl %eax, %ebx
leaq 0x11f0a(%rip), %rax     # 0x229b0
addl (%rax,%r15,4), %ebx
leaq (%r14,%r13), %r15
movq -0x60(%rbp), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, %r15
jb 0x10acc
leaq (%r15,%r15), %rsi
callq 0x10bdb
movq -0x60(%rbp), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, %r15
jae 0x10b5b
movq %r13, %rax
subq %rbx, %rax
movq %r13, %rcx
movq %rax, %rdx
movq -0x70(%rbp), %r15
subq $0x1, %r14
jb 0x10b3e
movq (%rdi), %rsi
movb (%rsi,%rdx), %r8b
movb %r8b, (%rsi,%rcx)
incq %rcx
incq %rdx
cmpq %r13, %rdx
cmovaeq %rax, %rdx
jmp 0x10ae5
movq -0x60(%rbp), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, %r13
jb 0x10b27
leaq 0x2(,%r13,2), %rsi
callq 0x10bdb
movq -0x60(%rbp), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, %r13
jae 0x10b4d
movq (%rdi), %rax
movb %bl, (%rax,%r13)
incq %r13
xorl %r14d, %r14d
jmp 0x109a4
xorl %r14d, %r14d
movq %rcx, %r13
jmp 0x109a4
pushq $0x33
jmp 0x10b57
movl $0x26b9, %r14d          # imm = 0x26B9
jmp 0x10b65
pushq $0x12
popq %r14
jmp 0x10b65
movl $0x26ba, %r14d          # imm = 0x26BA
movq -0x70(%rbp), %r15
leaq -0x1a0(%rbp), %rdi
callq 0x16361
leaq -0x150(%rbp), %rdi
callq 0x16361
movq -0x60(%rbp), %rdi
xorl %r9d, %r9d
movb -0x31(%rbp), %r10b
movb %r10b, %r9b
testl %r14d, %r14d
je 0x1036a
jmp 0x10bbe
pushq $0x34
jmp 0x10bbc
movq %r13, %rsi
callq 0x10bdb
xorl %ecx, %ecx
testl %eax, %eax
movl $0x26bc, %r14d          # imm = 0x26BC
cmovnel %ecx, %r14d
jmp 0x10bbe
pushq $0x14
jmp 0x10bbc
pushq $0x15
jmp 0x10bbc
pushq $0x17
popq %r14
movl %r14d, %eax
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x26bb, %r14d          # imm = 0x26BB
jmp 0x10bbe