LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: lodepng_decode_memory
unsigned lodepng_decode_memory(unsigned char** out, unsigned* w, unsigned* h, const unsigned char* in,
                               size_t insize, LodePNGColorType colortype, unsigned bitdepth)
{
  unsigned error;
  LodePNGState state;
  lodepng_state_init(&state);
  state.info_raw.colortype = colortype;
  state.info_raw.bitdepth = bitdepth;
  error = lodepng_decode(out, w, h, &state, in, insize);
  lodepng_state_cleanup(&state);
  return error;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movl %r9d, %ebx
movq %r8, (%rsp)
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbp
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x6986
movl %ebx, 0x88(%r14)
movl 0x1e0(%rsp), %eax
movl %eax, 0x8c(%r14)
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r14, %rcx
movq %r15, %r8
movq (%rsp), %r9
callq 0x55d6
movl %eax, %ebx
movq %r14, %rdi
callq 0x69ed
movl %ebx, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: lodepng_state_init
void lodepng_state_init(LodePNGState* state)
{
#ifdef LODEPNG_COMPILE_DECODER
  lodepng_decoder_settings_init(&state->decoder);
#endif /*LODEPNG_COMPILE_DECODER*/
#ifdef LODEPNG_COMPILE_ENCODER
  lodepng_encoder_settings_init(&state->encoder);
#endif /*LODEPNG_COMPILE_ENCODER*/
  lodepng_color_mode_init(&state->info_raw);
  lodepng_info_init(&state->info_png);
  state->error = 1;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x24(%rdi)
andl $0x0, 0x2c(%rdi)
andl $0x0, (%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rdi)
movups %xmm0, 0x14(%rdi)
addq $0x30, %rdi
callq 0x6aea
xorps %xmm0, %xmm0
movups %xmm0, 0xa0(%rbx)
movabsq $0x800000006, %rax      # imm = 0x800000006
movq %rax, 0x88(%rbx)
movups %xmm0, 0x90(%rbx)
leaq 0xb0(%rbx), %rdi
callq 0x3aa6
movl $0x1, 0x198(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: lodepng_decode_file
unsigned lodepng_decode_file(unsigned char** out, unsigned* w, unsigned* h, const char* filename,
                             LodePNGColorType colortype, unsigned bitdepth)
{
  unsigned char* buffer = 0;
  size_t buffersize;
  unsigned error;
  error = lodepng_load_file(&buffer, &buffersize, filename);
  if(!error) error = lodepng_decode_memory(out, w, h, buffer, buffersize, colortype, bitdepth);
  lodepng_free(buffer);
  return error;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r9d, %ebp
movl %r8d, 0x14(%rsp)
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r13
leaq 0x20(%rsp), %r12
andq $0x0, (%r12)
leaq 0x18(%rsp), %rsi
movq %r12, %rdi
movq %rcx, %rdx
callq 0x1261
movl %eax, %ebx
movq (%r12), %r12
testl %eax, %eax
jne 0x6a96
movq 0x18(%rsp), %r8
movl %ebp, (%rsp)
movq %r13, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %r12, %rcx
movl 0x14(%rsp), %r9d
callq 0x690a
movl %eax, %ebx
movq %r12, %rdi
callq 0x1030
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: lodepng_encoder_settings_init
void lodepng_encoder_settings_init(LodePNGEncoderSettings* settings)
{
  lodepng_compress_settings_init(&settings->zlibsettings);
  settings->filter_palette_zero = 1;
  settings->filter_strategy = LFS_MINSUM;
  settings->auto_convert = 1;
  settings->force_palette = 0;
  settings->predefined_filters = 0;
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
  settings->add_id = 0;
  settings->text_compression = 1;
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
}

// Assembly:
movaps 0x452f(%rip), %xmm0     # 0xb020
movups %xmm0, (%rdi)
movabsq $0x100000080, %rax      # imm = 0x100000080
movq %rax, 0x10(%rdi)
andq $0x0, 0x28(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rdi)
pushq $0x1
popq %rax
movl %eax, 0x38(%rdi)
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, 0x30(%rdi)
movups %xmm0, 0x40(%rdi)
movl %eax, 0x50(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: lodepng_state_copy
void lodepng_state_copy(LodePNGState* dest, const LodePNGState* source)
{
  lodepng_state_cleanup(dest);
  *dest = *source;
  lodepng_color_mode_init(&dest->info_raw);
  lodepng_info_init(&dest->info_png);
  dest->error = lodepng_color_mode_copy(&dest->info_raw, &source->info_raw); if(dest->error) return;
  dest->error = lodepng_info_copy(&dest->info_png, &source->info_png); if(dest->error) return;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
callq 0x69ed
movl $0x1a0, %edx            # imm = 0x1A0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x10e0
movl $0x88, %r12d
leaq (%rbx,%r12), %r13
xorps %xmm0, %xmm0
movups %xmm0, 0xa0(%rbx)
movabsq $0x800000006, %rax      # imm = 0x800000006
movq %rax, 0x88(%rbx)
movups %xmm0, 0x90(%rbx)
leaq 0xb0(%rbx), %r15
movq %r15, %rdi
callq 0x3aa6
addq %r14, %r12
movq %r13, %rdi
movq %r12, %rsi
callq 0x3506
movl %eax, 0x198(%rbx)
testl %eax, %eax
jne 0x6bb9
addq $0xb0, %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x3b65
movl %eax, 0x198(%rbx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: addUnknownChunks
static unsigned addUnknownChunks(ucvector* out, unsigned char* data, size_t datasize)
{
  unsigned char* inchunk = data;
  while((size_t)(inchunk - data) < datasize)
  {
    CERROR_TRY_RETURN(lodepng_chunk_append(&out->data, &out->size, inchunk));
    out->allocsize = out->size; /*fix the allocsize again*/
    inchunk = lodepng_chunk_next(inchunk);
  }
  return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x8(%rdi), %r12
movq %rsi, %r13
movq %r13, %rax
subq %r14, %rax
cmpq %rbx, %rax
jae 0x7d04
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x33a0
testl %eax, %eax
jne 0x7d06
movq 0x8(%r15), %rax
movq %rax, 0x10(%r15)
movq %r13, %rdi
callq 0x337e
movq %rax, %r13
jmp 0x7cd2
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: addChunk_PLTE
static unsigned addChunk_PLTE(ucvector* out, const LodePNGColorMode* info)
{
  unsigned error = 0;
  size_t i;
  ucvector PLTE;
  ucvector_init(&PLTE);
  for(i = 0; i != info->palettesize * 4; ++i)
  {
    /*add all channels except alpha channel*/
    if(i % 4 != 3) ucvector_push_back(&PLTE, info->palette[i]);
  }
  error = addChunk(out, "PLTE", PLTE.data, PLTE.size);
  ucvector_cleanup(&PLTE);

  return error;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
xorps %xmm0, %xmm0
movq %rsp, %r15
movaps %xmm0, (%r15)
andq $0x0, 0x10(%r15)
xorl %r12d, %r12d
movq 0x10(%r14), %rax
shlq $0x2, %rax
cmpq %rax, %r12
je 0x7d5f
movl %r12d, %eax
notl %eax
testb $0x3, %al
je 0x7d5a
movq 0x8(%r14), %rax
movzbl (%rax,%r12), %esi
movq %r15, %rdi
callq 0x31c1
incq %r12
jmp 0x7d33
movq %rsp, %r14
movq (%r14), %rdx
movq 0x8(%r14), %rcx
leaq 0x4bf9(%rip), %rsi      # 0xc969
movq %rbx, %rdi
callq 0x9dc8
movq %r14, %rdi
callq 0x8f7c
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: addChunk_tRNS
static unsigned addChunk_tRNS(ucvector* out, const LodePNGColorMode* info)
{
  unsigned error = 0;
  size_t i;
  ucvector tRNS;
  ucvector_init(&tRNS);
  if(info->colortype == LCT_PALETTE)
  {
    size_t amount = info->palettesize;
    /*the tail of palette values that all have 255 as alpha, does not have to be encoded*/
    for(i = info->palettesize; i != 0; --i)
    {
      if(info->palette[4 * (i - 1) + 3] == 255) --amount;
      else break;
    }
    /*add only alpha channel*/
    for(i = 0; i != amount; ++i) ucvector_push_back(&tRNS, info->palette[4 * i + 3]);
  }
  else if(info->colortype == LCT_GREY)
  {
    if(info->key_defined)
    {
      ucvector_push_back(&tRNS, (unsigned char)(info->key_r >> 8));
      ucvector_push_back(&tRNS, (unsigned char)(info->key_r & 255));
    }
  }
  else if(info->colortype == LCT_RGB)
  {
    if(info->key_defined)
    {
      ucvector_push_back(&tRNS, (unsigned char)(info->key_r >> 8));
      ucvector_push_back(&tRNS, (unsigned char)(info->key_r & 255));
      ucvector_push_back(&tRNS, (unsigned char)(info->key_g >> 8));
      ucvector_push_back(&tRNS, (unsigned char)(info->key_g & 255));
      ucvector_push_back(&tRNS, (unsigned char)(info->key_b >> 8));
      ucvector_push_back(&tRNS, (unsigned char)(info->key_b & 255));
    }
  }

  error = addChunk(out, "tRNS", tRNS.data, tRNS.size);
  ucvector_cleanup(&tRNS);

  return error;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rsi, %r14
movq %rdi, %rbx
andq $0x0, 0x10(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movl (%rsi), %eax
testl %eax, %eax
je 0x7e44
cmpl $0x2, %eax
je 0x7e02
cmpl $0x3, %eax
jne 0x7e6d
movq 0x10(%r14), %rax
movq %rax, %r12
subq $0x1, %rax
jb 0x7ddc
movq 0x8(%r14), %rcx
cmpb $-0x1, 0x3(%rcx,%rax,4)
je 0x7dc8
xorl %r13d, %r13d
movq %rsp, %r15
cmpq %r13, %r12
je 0x7e6d
movq 0x8(%r14), %rax
movzbl 0x3(%rax,%r13,4), %esi
movq %r15, %rdi
callq 0x31c1
incq %r13
jmp 0x7de2
cmpl $0x0, 0x18(%r14)
je 0x7e6d
movzbl 0x1d(%r14), %esi
movq %rsp, %r15
movq %r15, %rdi
callq 0x31c1
movzbl 0x1c(%r14), %esi
movq %r15, %rdi
callq 0x31c1
movzbl 0x21(%r14), %esi
movq %r15, %rdi
callq 0x31c1
movzbl 0x20(%r14), %esi
movq %r15, %rdi
callq 0x31c1
pushq $0x24
jmp 0x7e4d
cmpl $0x0, 0x18(%r14)
je 0x7e6d
pushq $0x1c
popq %r12
movzbl 0x1(%r14,%r12), %esi
movq %rsp, %r15
movq %r15, %rdi
callq 0x31c1
movzbl (%r14,%r12), %esi
movq %r15, %rdi
callq 0x31c1
movq %rsp, %r14
movq (%r14), %rdx
movq 0x8(%r14), %rcx
leaq 0x4af0(%rip), %rsi      # 0xc96e
movq %rbx, %rdi
callq 0x9dc8
movq %r14, %rdi
callq 0x8f7c
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: addChunk_tEXt
static unsigned addChunk_tEXt(ucvector* out, const char* keyword, const char* textstring)
{
  unsigned error = 0;
  size_t i;
  ucvector text;
  ucvector_init(&text);
  for(i = 0; keyword[i] != 0; ++i) ucvector_push_back(&text, (unsigned char)keyword[i]);
  if(i < 1 || i > 79) return 89; /*error: invalid keyword size*/
  ucvector_push_back(&text, 0); /*0 termination char*/
  for(i = 0; textstring[i] != 0; ++i) ucvector_push_back(&text, (unsigned char)textstring[i]);
  error = addChunk(out, "tEXt", text.data, text.size);
  ucvector_cleanup(&text);

  return error;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
xorps %xmm0, %xmm0
movq %rsp, %r12
movaps %xmm0, (%r12)
andq $0x0, 0x10(%r12)
pushq $-0x50
popq %r13
movb 0x50(%r15,%r13), %al
testb %al, %al
je 0x7ee0
movzbl %al, %esi
movq %r12, %rdi
callq 0x31c1
incq %r13
jmp 0x7ec7
cmpq $-0x4f, %r13
jb 0x7f2b
movq %rsp, %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x31c1
movb (%r14), %al
testb %al, %al
je 0x7f0a
movzbl %al, %esi
movq %r15, %rdi
callq 0x31c1
incq %r14
jmp 0x7ef3
movq %rsp, %r14
movq (%r14), %rdx
movq 0x8(%r14), %rcx
leaq 0x4a5d(%rip), %rsi      # 0xc978
movq %rbx, %rdi
callq 0x9dc8
movq %r14, %rdi
callq 0x8f7c
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: lodepng_encode_memory
unsigned lodepng_encode_memory(unsigned char** out, size_t* outsize, const unsigned char* image,
                               unsigned w, unsigned h, LodePNGColorType colortype, unsigned bitdepth)
{
  unsigned error;
  LodePNGState state;
  lodepng_state_init(&state);
  state.info_raw.colortype = colortype;
  state.info_raw.bitdepth = bitdepth;
  state.info_png.color.colortype = colortype;
  state.info_png.color.bitdepth = bitdepth;
  lodepng_encode(out, outsize, image, w, h, &state);
  error = state.error;
  lodepng_state_cleanup(&state);
  return error;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movl %r9d, %ebx
movl %r8d, 0x4(%rsp)
movl %ecx, %r14d
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
leaq 0x8(%rsp), %rbp
movq %rbp, %rdi
callq 0x6986
movl %ebx, 0x88(%rbp)
movl 0x1e0(%rsp), %eax
movl %eax, 0x8c(%rbp)
movl %ebx, 0xc0(%rbp)
movl %eax, 0xc4(%rbp)
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movl %r14d, %ecx
movl 0x4(%rsp), %r8d
movq %rbp, %r9
callq 0x6bc3
movl 0x198(%rbp), %ebx
movq %rbp, %rdi
callq 0x69ed
movl %ebx, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: lodepng_encode_file
unsigned lodepng_encode_file(const char* filename, const unsigned char* image, unsigned w, unsigned h,
                             LodePNGColorType colortype, unsigned bitdepth)
{
  unsigned char* buffer;
  size_t buffersize;
  unsigned error = lodepng_encode_memory(&buffer, &buffersize, image, w, h, colortype, bitdepth);
  if(!error) error = lodepng_save_file(buffer, buffersize, filename);
  lodepng_free(buffer);
  return error;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movl %r8d, %eax
movl %ecx, %r8d
movl %edx, %ecx
movq %rsi, %rdx
movq %rdi, %rbx
movl %r9d, (%rsp)
leaq 0x18(%rsp), %r14
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
movl %eax, %r9d
callq 0x7f39
movl %eax, %ebp
movq (%r14), %r14
testl %eax, %eax
jne 0x8035
movq 0x10(%rsp), %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x134b
movl %eax, %ebp
movq %r14, %rdi
callq 0x1030
movl %ebp, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: ucvector_reserve
static unsigned ucvector_reserve(ucvector* p, size_t allocsize)
{
  if(allocsize > p->allocsize)
  {
    size_t newsize = (allocsize > p->allocsize * 2) ? allocsize : (allocsize * 3 / 2);
    void* data = lodepng_realloc(p->data, newsize);
    if(data)
    {
      p->allocsize = newsize;
      p->data = (unsigned char*)data;
    }
    else return 0; /*error: not enough memory*/
  }
  return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq 0x10(%rdi), %rax
pushq $0x1
popq %rbx
cmpq %rsi, %rax
jae 0x80e6
movq %rdi, %r14
addq %rax, %rax
leaq (%rsi,%rsi,2), %r15
shrq %r15
cmpq %rsi, %rax
cmovbq %rsi, %r15
movq (%rdi), %rdi
movq %r15, %rsi
callq 0x1120
testq %rax, %rax
je 0x80e4
movq %r15, 0x10(%r14)
movq %rax, (%r14)
jmp 0x80e6
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: huffmanDecodeSymbol
static unsigned huffmanDecodeSymbol(const unsigned char* in, size_t* bp,
                                    const HuffmanTree* codetree, size_t inbitlength)
{
  unsigned treepos = 0, ct;
  for(;;)
  {
    if(*bp >= inbitlength) return (unsigned)(-1); /*error: end of input memory reached without endcode*/
    /*
    decode the symbol from the tree. The "readBitFromStream" code is inlined in
    the expression below because this is the biggest bottleneck while decoding
    */
    ct = codetree->tree2d[(treepos << 1) + READBIT(*bp, in)];
    ++(*bp);
    if(ct < codetree->numcodes) return ct; /*the symbol is decoded, return it*/
    else treepos = ct - codetree->numcodes; /*symbol not yet decoded, instead move tree position*/

    if(treepos >= codetree->numcodes) return (unsigned)(-1); /*error: it appeared outside the codetree*/
  }
}

// Assembly:
pushq %r14
pushq %rbx
movq (%rsi), %r9
xorl %r10d, %r10d
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
cmpq %rcx, %r9
jae 0x8141
movq (%rdx), %rax
movq %r9, %r11
shrq $0x3, %r11
movzbl (%rdi,%r11), %r11d
movl %r9d, %ebx
andl $0x7, %ebx
xorl %r14d, %r14d
btl %ebx, %r11d
setb %r14b
leal (%r14,%r10,2), %r10d
movl (%rax,%r10,4), %eax
incq %r9
movq %r9, (%rsi)
movl 0x1c(%rdx), %r11d
movl %eax, %r10d
subl %r11d, %r10d
jb 0x8144
cmpl %r11d, %r10d
jb 0x80fd
movl %r8d, %eax
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: readBitsFromStream
static unsigned readBitsFromStream(size_t* bitpointer, const unsigned char* bitstream, size_t nbits)
{
  unsigned result = 0, i;
  for(i = 0; i != nbits; ++i)
  {
    result += ((unsigned)READBIT(*bitpointer, bitstream)) << i;
    ++(*bitpointer);
  }
  return result;
}

// Assembly:
xorl %eax, %eax
xorl %ecx, %ecx
movl %ecx, %r8d
cmpq %rdx, %r8
je 0x8185
movq (%rdi), %r8
movq %r8, %r9
shrq $0x3, %r9
movzbl (%rsi,%r9), %r9d
movl %r8d, %r10d
andl $0x7, %r10d
xorl %r11d, %r11d
btl %r10d, %r9d
setb %r11b
shll %cl, %r11d
addl %r11d, %eax
incq %r8
movq %r8, (%rdi)
incl %ecx
jmp 0x814c
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: generateFixedLitLenTree
static unsigned generateFixedLitLenTree(HuffmanTree* tree)
{
  unsigned i, error = 0;
  unsigned* bitlen = (unsigned*)lodepng_malloc(NUM_DEFLATE_CODE_SYMBOLS * sizeof(unsigned));
  if(!bitlen) return 83; /*alloc fail*/

  /*288 possible codes: 0-255=literals, 256=endcode, 257-285=lengthcodes, 286-287=unused*/
  for(i =   0; i <= 143; ++i) bitlen[i] = 8;
  for(i = 144; i <= 255; ++i) bitlen[i] = 9;
  for(i = 256; i <= 279; ++i) bitlen[i] = 7;
  for(i = 280; i <= 287; ++i) bitlen[i] = 8;

  error = HuffmanTree_makeFromLengths(tree, bitlen, NUM_DEFLATE_CODE_SYMBOLS, 15);

  lodepng_free(bitlen);
  return error;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movl $0x480, %edi            # imm = 0x480
callq 0x10f0
testq %rax, %rax
je 0x8245
movq %rax, %rbx
xorl %eax, %eax
cmpq $0x90, %rax
je 0x81d8
movl $0x8, (%rbx,%rax,4)
incq %rax
jmp 0x81c4
movl $0x90, %eax
cmpq $0x100, %rax            # imm = 0x100
je 0x81f1
movl $0x9, (%rbx,%rax,4)
incq %rax
jmp 0x81dd
movl $0x100, %eax            # imm = 0x100
cmpq $0x118, %rax            # imm = 0x118
je 0x820a
movl $0x7, (%rbx,%rax,4)
incq %rax
jmp 0x81f6
movl $0x118, %eax            # imm = 0x118
cmpq $0x120, %rax            # imm = 0x120
je 0x8223
movl $0x8, (%rbx,%rax,4)
incq %rax
jmp 0x820f
pushq $0xf
popq %rcx
movl $0x120, %edx            # imm = 0x120
movq %r14, %rdi
movq %rbx, %rsi
callq 0x82a2
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x1030
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: generateFixedDistanceTree
static unsigned generateFixedDistanceTree(HuffmanTree* tree)
{
  unsigned i, error = 0;
  unsigned* bitlen = (unsigned*)lodepng_malloc(NUM_DISTANCE_SYMBOLS * sizeof(unsigned));
  if(!bitlen) return 83; /*alloc fail*/

  /*there are 32 distance codes, but 30-31 are unused*/
  for(i = 0; i != NUM_DISTANCE_SYMBOLS; ++i) bitlen[i] = 5;
  error = HuffmanTree_makeFromLengths(tree, bitlen, NUM_DISTANCE_SYMBOLS, 15);

  lodepng_free(bitlen);
  return error;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movl $0x80, %edi
callq 0x10f0
testq %rax, %rax
je 0x829a
movq %rax, %rbx
xorl %eax, %eax
cmpq $0x20, %rax
je 0x827a
movl $0x5, (%rbx,%rax,4)
incq %rax
jmp 0x8268
pushq $0x20
popq %rdx
pushq $0xf
popq %rcx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x82a2
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x1030
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: HuffmanTree_makeFromLengths
static unsigned HuffmanTree_makeFromLengths(HuffmanTree* tree, const unsigned* bitlen,
                                            size_t numcodes, unsigned maxbitlen)
{
  unsigned i;
  tree->lengths = (unsigned*)lodepng_malloc(numcodes * sizeof(unsigned));
  if(!tree->lengths) return 83; /*alloc fail*/
  for(i = 0; i != numcodes; ++i) tree->lengths[i] = bitlen[i];
  tree->numcodes = (unsigned)numcodes; /*number of symbols*/
  tree->maxbitlen = maxbitlen;
  return HuffmanTree_makeFromLengths2(tree);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebx
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r14
leaq (,%rdx,4), %rdi
callq 0x10f0
movq %rax, 0x10(%r14)
testq %rax, %rax
je 0x82f7
xorl %ecx, %ecx
movl %ecx, %ecx
cmpq %r15, %rcx
je 0x82df
movl (%r12,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
incl %ecx
jmp 0x82cd
movl %r15d, 0x1c(%r14)
movl %ebx, 0x18(%r14)
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x8306
pushq $0x53
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: writeLZ77data
static void writeLZ77data(size_t* bp, ucvector* out, const uivector* lz77_encoded,
                          const HuffmanTree* tree_ll, const HuffmanTree* tree_d)
{
  size_t i = 0;
  for(i = 0; i != lz77_encoded->size; ++i)
  {
    unsigned val = lz77_encoded->data[i];
    addHuffmanSymbol(bp, out, HuffmanTree_getCode(tree_ll, val), HuffmanTree_getLength(tree_ll, val));
    if(val > 256) /*for a length code, 3 more things have to be added*/
    {
      unsigned length_index = val - FIRST_LENGTH_CODE_INDEX;
      unsigned n_length_extra_bits = LENGTHEXTRA[length_index];
      unsigned length_extra_bits = lz77_encoded->data[++i];

      unsigned distance_code = lz77_encoded->data[++i];

      unsigned distance_index = distance_code;
      unsigned n_distance_extra_bits = DISTANCEEXTRA[distance_index];
      unsigned distance_extra_bits = lz77_encoded->data[++i];

      addBitsToStream(bp, out, length_extra_bits, n_length_extra_bits);
      addHuffmanSymbol(bp, out, HuffmanTree_getCode(tree_d, distance_code),
                       HuffmanTree_getLength(tree_d, distance_code));
      addBitsToStream(bp, out, distance_extra_bits, n_distance_extra_bits);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, 0x8(%rsp)
movq %rcx, %rbp
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
xorl %r14d, %r14d
cmpq 0x8(%r15), %r14
je 0x8b30
movq (%r15), %rax
movl (%rax,%r14,4), %ebx
movq 0x8(%rbp), %rax
movq 0x10(%rbp), %rcx
movl (%rax,%rbx,4), %edx
movl (%rcx,%rbx,4), %ecx
movq %r13, %rdi
movq %r12, %rsi
callq 0x8b3f
cmpq $0x101, %rbx            # imm = 0x101
jb 0x8b28
addl $0xfffffeff, %ebx       # imm = 0xFFFFFEFF
leaq 0x2b87(%rip), %rax      # 0xb640
movl (%rax,%rbx,4), %ecx
movq (%r15), %rax
movl 0x4(%rax,%r14,4), %edx
movq %rbp, %rbx
movl 0x8(%rax,%r14,4), %ebp
leaq 0x2c6d(%rip), %rsi      # 0xb740
movl (%rsi,%rbp,4), %esi
movq %rsi, 0x10(%rsp)
movl 0xc(%rax,%r14,4), %eax
movl %eax, 0x4(%rsp)
addq $0x3, %r14
movq %r13, %rdi
movq %r12, %rsi
callq 0x8ccb
movq 0x8(%rsp), %rcx
movq 0x8(%rcx), %rax
movq 0x10(%rcx), %rcx
movl (%rax,%rbp,4), %edx
movl (%rcx,%rbp,4), %ecx
movq %rbx, %rbp
movq %r13, %rdi
movq %r12, %rsi
callq 0x8b3f
movq %r13, %rdi
movq %r12, %rsi
movl 0x4(%rsp), %edx
movq 0x10(%rsp), %rcx
callq 0x8ccb
incq %r14
jmp 0x8a79
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: getHash
static unsigned getHash(const unsigned char* data, size_t size, size_t pos)
{
  unsigned result = 0;
  if(pos + 2 < size)
  {
    /*A simple shift and xor hash is used. Since the data of PNGs is dominated
    by zeroes due to the filters, a better hash does not have a significant
    effect on speed in traversing the chain, and causes more time spend on
    calculating the hash.*/
    result ^= (unsigned)(data[pos + 0] << 0u);
    result ^= (unsigned)(data[pos + 1] << 4u);
    result ^= (unsigned)(data[pos + 2] << 8u);
  } else {
    size_t amount, i;
    if(pos >= size) return 0;
    amount = size - pos;
    for(i = 0; i != amount; ++i) result ^= (unsigned)(data[pos + i] << (i * 8u));
  }
  return result & HASH_BIT_MASK;
}

// Assembly:
leaq 0x2(%rdx), %rax
cmpq %rsi, %rax
jae 0x8bbf
movzbl (%rdi,%rdx), %eax
movzbl 0x1(%rdi,%rdx), %ecx
shll $0x4, %ecx
xorl %eax, %ecx
movzbl 0x2(%rdi,%rdx), %eax
shll $0x8, %eax
xorl %ecx, %eax
movzwl %ax, %eax
jmp 0x8be2
xorl %eax, %eax
cmpq %rsi, %rdx
jae 0x8be2
xorl %ecx, %ecx
xorl %eax, %eax
cmpq %rdx, %rsi
je 0x8bba
movzbl (%rdi,%rdx), %r8d
shll %cl, %r8d
xorl %r8d, %eax
incq %rdx
addl $0x8, %ecx
jmp 0x8bca
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: countZeros
static unsigned countZeros(const unsigned char* data, size_t size, size_t pos)
{
  const unsigned char* start = data + pos;
  const unsigned char* end = start + MAX_SUPPORTED_DEFLATE_LENGTH;
  if(end > data + size) end = data + size;
  data = start;
  while(data != end && *data == 0) ++data;
  /*subtracting two addresses returned as 32-bit number (max value is MAX_SUPPORTED_DEFLATE_LENGTH)*/
  return (unsigned)(data - start);
}

// Assembly:
movq %rsi, %rax
leaq (%rdi,%rdx), %rcx
addq %rdi, %rdx
addq $0x102, %rdx            # imm = 0x102
addq %rdi, %rax
cmpq %rax, %rdx
cmovbeq %rdx, %rax
movq %rcx, %rdx
cmpq %rax, %rdx
je 0x8c13
cmpb $0x0, (%rdx)
jne 0x8c10
incq %rdx
jmp 0x8c01
movq %rdx, %rax
subl %ecx, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: updateHashChain
static void updateHashChain(Hash* hash, size_t wpos, unsigned hashval, unsigned short numzeros)
{
  hash->val[wpos] = (int)hashval;
  if(hash->head[hashval] != -1) hash->chain[wpos] = hash->head[hashval];
  hash->head[hashval] = wpos;

  hash->zeros[wpos] = numzeros;
  if(hash->headz[numzeros] != -1) hash->chainz[wpos] = hash->headz[numzeros];
  hash->headz[numzeros] = wpos;
}

// Assembly:
movq 0x10(%rdi), %rax
movl %edx, (%rax,%rsi,4)
movq (%rdi), %rax
movl %edx, %edx
movl (%rax,%rdx,4), %r8d
cmpl $-0x1, %r8d
je 0x8c35
movq 0x8(%rdi), %r9
movw %r8w, (%r9,%rsi,2)
movl %esi, (%rax,%rdx,4)
movq 0x28(%rdi), %rax
movw %cx, (%rax,%rsi,2)
movq 0x18(%rdi), %rax
movzwl %cx, %ecx
movl (%rax,%rcx,4), %edx
cmpl $-0x1, %edx
je 0x8c57
movq 0x20(%rdi), %rdi
movw %dx, (%rdi,%rsi,2)
movl %esi, (%rax,%rcx,4)
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: searchCodeIndex
static size_t searchCodeIndex(const unsigned* array, size_t array_size, size_t value)
{
  /*binary search (only small gain over linear). TODO: use CPU log2 instruction for getting symbols instead*/
  size_t left = 1;
  size_t right = array_size - 1;

  while(left <= right) {
    size_t mid = (left + right) >> 1;
    if (array[mid] >= value) right = mid - 1;
    else left = mid + 1;
  }
  if(left >= array_size || array[left] > value) left--;
  return left;
}

// Assembly:
leaq -0x1(%rsi), %rcx
pushq $0x1
popq %rax
cmpq %rcx, %rax
ja 0x8cba
leaq (%rax,%rcx), %r8
shrq %r8
movl (%rdi,%r8,4), %r9d
cmpq %rdx, %r9
jb 0x8cb2
decq %r8
movq %r8, %rcx
jmp 0x8c95
incq %r8
movq %r8, %rax
jmp 0x8c95
cmpq %rsi, %rax
jae 0x8cc7
movl (%rdi,%rax,4), %ecx
cmpq %rdx, %rcx
jbe 0x8cca
decq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: HuffmanTree_makeFromFrequencies
static unsigned HuffmanTree_makeFromFrequencies(HuffmanTree* tree, const unsigned* frequencies,
                                                size_t mincodes, size_t numcodes, unsigned maxbitlen)
{
  unsigned error = 0;
  while(!frequencies[numcodes - 1] && numcodes > mincodes) --numcodes; /*trim zeroes*/
  tree->maxbitlen = maxbitlen;
  tree->numcodes = (unsigned)numcodes; /*number of symbols*/
  tree->lengths = (unsigned*)lodepng_realloc(tree->lengths, numcodes * sizeof(unsigned));
  if(!tree->lengths) return 83; /*alloc fail*/
  /*initialize all lengths to 0*/
  memset(tree->lengths, 0, numcodes * sizeof(unsigned));

  error = lodepng_huffman_code_lengths(tree->lengths, frequencies, numcodes, maxbitlen);
  if(!error) error = HuffmanTree_makeFromLengths2(tree);
  return error;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r8d, %ebp
movq %rcx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x4(,%rcx,4), %rsi
pushq $0x1
popq %rax
xorl %ecx, %ecx
leaq (%r14,%rcx), %rdi
leaq -0x4(%rsi), %r12
decq %rax
cmpq %rdx, %rdi
jbe 0x8d67
decq %rcx
cmpl $0x0, -0x8(%r15,%rsi)
movq %r12, %rsi
je 0x8d49
movl %ebp, 0x18(%rbx)
addq %rax, %r14
movl %r14d, 0x1c(%rbx)
movq 0x10(%rbx), %rdi
movq %r12, %rsi
callq 0x1120
movq %rax, 0x10(%rbx)
testq %rax, %rax
je 0x8dc0
movq %rax, %r13
movq %rax, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x10b0
movq %r13, %rdi
movq %r15, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x1393
testl %eax, %eax
jne 0x8dc3
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8306
pushq $0x53
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: string_resize
static unsigned string_resize(char** out, size_t size)
{
  char* data = (char*)lodepng_realloc(*out, size + 1);
  if(data)
  {
    data[size] = 0; /*null termination char*/
    *out = data;
  }
  return data != 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %rdi
incq %rsi
callq 0x1120
testq %rax, %rax
je 0x8e06
movb $0x0, (%rax,%r14)
movq %rax, (%rbx)
xorl %ecx, %ecx
testq %rax, %rax
setne %cl
movl %ecx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: readBitsFromReversedStream
static unsigned readBitsFromReversedStream(size_t* bitpointer, const unsigned char* bitstream, size_t nbits)
{
  unsigned result = 0;
  size_t i;
  for(i = 0 ; i < nbits; ++i)
  {
    result <<= 1;
    result |= (unsigned)readBitFromReversedStream(bitpointer, bitstream);
  }
  return result;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r12
xorl %r15d, %r15d
subq $0x1, %rbx
jb 0x8e46
movq %r12, %rdi
movq %r14, %rsi
callq 0x8e55
movzbl %al, %eax
leal (%rax,%r15,2), %r15d
jmp 0x8e2c
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: addColorBits
static void addColorBits(unsigned char* out, size_t index, unsigned bits, unsigned in)
{
  unsigned m = bits == 1 ? 7 : bits == 2 ? 3 : 1; /*8 / bits - 1*/
  /*p = the partial index in the byte, e.g. with 4 palettebits it is 0 for first half or 1 for second half*/
  unsigned p = index & m;
  in &= (1u << bits) - 1u; /*filter out any other bits of the input value*/
  in = in << (bits * (m - p));
  if(p == 0) out[index * bits / 8] = in;
  else out[index * bits / 8] |= in;
}

// Assembly:
movl %ecx, %eax
xorl %ecx, %ecx
cmpl $0x2, %edx
sete %cl
cmpl $0x1, %edx
leal 0x1(%rcx,%rcx), %ecx
pushq $0x7
popq %r8
cmovnel %ecx, %r8d
movl %esi, %r10d
andl %r8d, %r10d
pushq $-0x1
popq %r9
movl %edx, %ecx
shll %cl, %r9d
notl %r9d
andl %eax, %r9d
subl %r10d, %r8d
imull %edx, %r8d
movl %r8d, %ecx
shll %cl, %r9d
movl %edx, %eax
imulq %rsi, %rax
shrq $0x3, %rax
testl %r10d, %r10d
je 0x8ec9
orb %r9b, (%rdi,%rax)
retq
movb %r9b, (%rdi,%rax)
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: color_tree_get
static int color_tree_get(ColorTree* tree, unsigned char r, unsigned char g, unsigned char b, unsigned char a)
{
  int bit = 0;
  for(bit = 0; bit < 8; ++bit)
  {
    int i = 8 * ((r >> bit) & 1) + 4 * ((g >> bit) & 1) + 2 * ((b >> bit) & 1) + 1 * ((a >> bit) & 1);
    if(!tree->children[i]) return -1;
    else tree = tree->children[i];
  }
  return tree ? tree->index : -1;
}

// Assembly:
pushq %r14
pushq %rbx
movl %ecx, %r9d
xorl %ecx, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl $0x8, %ecx
je 0x8f20
movl %esi, %r10d
shrl %cl, %r10d
movl %edx, %r11d
shrl %cl, %r11d
movl %r9d, %ebx
shrl %cl, %ebx
andl $0x1, %r10d
andl $0x1, %r11d
andl $0x1, %ebx
xorl %r14d, %r14d
btl %ecx, %r8d
setb %r14b
leal (%r14,%r11,4), %r11d
leal (%r11,%r10,8), %r10d
leal (%r10,%rbx,2), %r10d
movq (%rdi,%r10,8), %rdi
incl %ecx
testq %rdi, %rdi
jne 0x8edb
jmp 0x8f2b
testq %rdi, %rdi
je 0x8f2b
movl 0x80(%rdi), %eax
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: removePaddingBits
static void removePaddingBits(unsigned char* out, const unsigned char* in,
                              size_t olinebits, size_t ilinebits, unsigned h)
{
  /*
  After filtering there are still padding bits if scanlines have non multiple of 8 bit amounts. They need
  to be removed (except at last scanline of (Adam7-reduced) image) before working with pure image buffers
  for the Adam7 code, the color convert code and the output to the user.
  in and out are allowed to be the same buffer, in may also be higher but still overlapping; in must
  have >= ilinebits*h bits, out must have >= olinebits*h bits, olinebits must be <= ilinebits
  also used to move bits after earlier such operations happened, e.g. in a sequence of reduced images from Adam7
  only useful if (ilinebits - olinebits) is a value in the range 1..7
  */
  unsigned y;
  size_t diff = ilinebits - olinebits;
  size_t ibp = 0, obp = 0; /*input and output bit pointers*/
  for(y = 0; y < h; ++y)
  {
    size_t x;
    for(x = 0; x < olinebits; ++x)
    {
      unsigned char bit = readBitFromReversedStream(&ibp, in);
      setBitOfReversedStream(&obp, out, bit);
    }
    ibp += diff;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, 0x8(%rsp)
movq %rcx, 0x18(%rsp)
movq %rdx, 0x10(%rsp)
leaq 0x20(%rsp), %r12
andq $0x0, (%r12)
movq %rsi, %r13
movq %rdi, %rbp
xorl %ebx, %ebx
xorl %eax, %eax
cmpl 0x8(%rsp), %eax
je 0x928d
movl %eax, 0xc(%rsp)
movq 0x10(%rsp), %rax
movq %rbx, %r14
movq %rax, %r15
subq $0x1, %r15
jb 0x927d
movq %r14, %rax
shrq $0x3, %rax
movl %r14d, %ecx
notb %cl
movzbl (%r13,%rax), %eax
movzbl %cl, %ecx
andl $0x7, %ecx
xorl %edx, %edx
btl %ecx, %eax
setb %dl
incq %r14
movq %r12, %rdi
movq %rbp, %rsi
callq 0x9405
movq %r15, %rax
jmp 0x9244
addq 0x18(%rsp), %rbx
subq %rax, %rbx
movl 0xc(%rsp), %eax
incl %eax
jmp 0x922f
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: Adam7_getpassvalues
static void Adam7_getpassvalues(unsigned passw[7], unsigned passh[7], size_t filter_passstart[8],
                                size_t padded_passstart[8], size_t passstart[8], unsigned w, unsigned h, unsigned bpp)
{
  /*the passstart values have 8 values: the 8th one indicates the byte after the end of the 7th (= last) pass*/
  unsigned i;

  /*calculate width and height in pixels of each pass*/
  for(i = 0; i != 7; ++i)
  {
    passw[i] = (w + ADAM7_DX[i] - ADAM7_IX[i] - 1) / ADAM7_DX[i];
    passh[i] = (h + ADAM7_DY[i] - ADAM7_IY[i] - 1) / ADAM7_DY[i];
    if(passw[i] == 0) passh[i] = 0;
    if(passh[i] == 0) passw[i] = 0;
  }

  filter_passstart[0] = padded_passstart[0] = passstart[0] = 0;
  for(i = 0; i != 7; ++i)
  {
    /*if passw[i] is 0, it's 0 bytes, not 1 (no filtertype-byte)*/
    filter_passstart[i + 1] = filter_passstart[i]
                            + ((passw[i] && passh[i]) ? passh[i] * (1 + (passw[i] * bpp + 7) / 8) : 0);
    /*bits padded if needed to fill full byte at end of each scanline*/
    padded_passstart[i + 1] = padded_passstart[i] + passh[i] * ((passw[i] * bpp + 7) / 8);
    /*only padded at end of reduced image*/
    passstart[i + 1] = passstart[i] + (passh[i] * passw[i] * bpp + 7) / 8;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %r10
movl 0x38(%rsp), %ebx
xorl %r14d, %r14d
leaq 0x2559(%rip), %r15      # 0xb810
leaq 0x2572(%rip), %r12      # 0xb830
leaq 0x258b(%rip), %r13      # 0xb850
leaq 0x25a4(%rip), %rbp      # 0xb870
cmpq $0x1c, %r14
je 0x931f
movl (%r14,%r15), %r11d
movl (%r14,%r12), %eax
notl %eax
addl %r11d, %eax
addl %r9d, %eax
xorl %edx, %edx
divl %r11d
movl %eax, (%rdi,%r14)
movl (%r14,%r13), %r11d
movl (%r14,%rbp), %eax
notl %eax
addl %r11d, %eax
addl %ebx, %eax
xorl %edx, %edx
divl %r11d
movl %eax, (%rsi,%r14)
movl (%rdi,%r14), %edx
testl %edx, %edx
cmovel %edx, %eax
movl %eax, (%rsi,%r14)
testl %eax, %eax
jne 0x9319
andl $0x0, (%rdi,%r14)
addq $0x4, %r14
jmp 0x92cc
andq $0x0, (%r8)
andq $0x0, (%rcx)
andq $0x0, (%r10)
xorl %eax, %eax
movl 0x40(%rsp), %ebp
cmpq $0x1c, %rax
je 0x9399
movl (%rdi,%rax), %edx
movl (%rsi,%rax), %r9d
testl %edx, %edx
je 0x935d
testl %r9d, %r9d
je 0x935a
movl %edx, %ebx
imull %ebp, %ebx
addl $0x7, %ebx
shrl $0x3, %ebx
incl %ebx
imull %r9d, %ebx
jmp 0x935f
xorl %r9d, %r9d
xorl %ebx, %ebx
addq (%r10,%rax,2), %rbx
movq %rbx, 0x8(%r10,%rax,2)
imull %ebp, %edx
leal 0x7(%rdx), %r11d
shrl $0x3, %r11d
imull %r9d, %r11d
addq (%rcx,%rax,2), %r11
movq %r11, 0x8(%rcx,%rax,2)
imull %r9d, %edx
addl $0x7, %edx
shrl $0x3, %edx
addq (%r8,%rax,2), %rdx
movq %rdx, 0x8(%r8,%rax,2)
addq $0x4, %rax
jmp 0x9331
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: paethPredictor
static unsigned char paethPredictor(short a, short b, short c)
{
  short pa = abs(b - c);
  short pb = abs(a - c);
  short pc = abs(a + b - c - c);

  if(pc < pa && pc < pb) return (unsigned char)c;
  else if(pb < pa) return (unsigned char)b;
  else return (unsigned char)a;
}

// Assembly:
movl %edx, %eax
movl $0xffff, %ecx           # imm = 0xFFFF
movl %esi, %r8d
andl %ecx, %r8d
movl %edx, %r9d
andl %ecx, %r9d
subl %r9d, %r8d
movl %r8d, %edx
negl %edx
cmovsl %r8d, %edx
andl %ecx, %edx
movl %edi, %r8d
andl %ecx, %r8d
subl %r9d, %r8d
movl %r8d, %r9d
negl %r9d
cmovsl %r8d, %r9d
andl %ecx, %r9d
leal (%rsi,%rdi), %r8d
subl %eax, %r8d
subl %eax, %r8d
movl %r8d, %r10d
negl %r10d
cmovsl %r8d, %r10d
andl %ecx, %r10d
cmpl %edx, %r9d
cmovbl %esi, %edi
cmpl %r9d, %r10d
cmovael %edi, %eax
cmpl %edx, %r10d
cmovael %edi, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: setBitOfReversedStream
static void setBitOfReversedStream(size_t* bitpointer, unsigned char* bitstream, unsigned char bit)
{
  /*the current bit in bitstream may be 0 or 1 for this to work*/
  if(bit == 0) bitstream[(*bitpointer) >> 3] &=  (unsigned char)(~(1 << (7 - ((*bitpointer) & 0x7))));
  else         bitstream[(*bitpointer) >> 3] |=  (1 << (7 - ((*bitpointer) & 0x7)));
  ++(*bitpointer);
}

// Assembly:
movq (%rdi), %rax
movl %eax, %ecx
notb %cl
andb $0x7, %cl
movb $0x1, %r8b
shlb %cl, %r8b
testl %edx, %edx
je 0x9423
shrq $0x3, %rax
orb %r8b, (%rsi,%rax)
jmp 0x942e
notb %r8b
shrq $0x3, %rax
andb %r8b, (%rsi,%rax)
incq (%rdi)
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: addPaddingBits
static void addPaddingBits(unsigned char* out, const unsigned char* in,
                           size_t olinebits, size_t ilinebits, unsigned h)
{
  /*The opposite of the removePaddingBits function
  olinebits must be >= ilinebits*/
  unsigned y;
  size_t diff = olinebits - ilinebits;
  size_t obp = 0, ibp = 0; /*bit pointers*/
  for(y = 0; y != h; ++y)
  {
    size_t x;
    for(x = 0; x < ilinebits; ++x)
    {
      unsigned char bit = readBitFromReversedStream(&ibp, in);
      setBitOfReversedStream(&obp, out, bit);
    }
    /*obp += diff; --> no, fill in some value in the padding bits too, to avoid
    "Use of uninitialised value of size ###" warning from valgrind*/
    for(x = 0; x != diff; ++x) setBitOfReversedStream(&obp, out, 0);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, 0x4(%rsp)
movq %rsi, %r12
leaq 0x8(%rsp), %r13
andq $0x0, (%r13)
movq %rdi, %rbp
movq %rcx, 0x18(%rsp)
subq %rcx, %rdx
movq %rdx, 0x10(%rsp)
xorl %r15d, %r15d
xorl %ebx, %ebx
cmpl 0x4(%rsp), %ebx
je 0x94ec
movq 0x18(%rsp), %r14
leaq (%r15,%r14), %rax
movq %rax, 0x20(%rsp)
subq $0x1, %r14
jb 0x94b0
movq %r15, %rax
shrq $0x3, %rax
movl %r15d, %ecx
notb %cl
movzbl (%r12,%rax), %eax
movzbl %cl, %ecx
andl $0x7, %ecx
xorl %edx, %edx
btl %ecx, %eax
setb %dl
incq %r15
movq %r13, %rdi
movq %rbp, %rsi
callq 0x9405
jmp 0x947b
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rdx
subq $0x1, %rdx
jb 0x94db
movl %eax, %ecx
notb %cl
movb $-0x2, %sil
rolb %cl, %sil
movq %rax, %rcx
shrq $0x3, %rcx
andb %sil, (%rbp,%rcx)
incq %rax
jmp 0x94ba
movq %rax, 0x8(%rsp)
incl %ebx
movq 0x20(%rsp), %r15
jmp 0x9467
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/txp-convert.c
// Function: swizzle
int swizzle(int index) {
	int b = (index >> 3) & 3;
	if( b == 1 ) b = 2;
	else if( b == 2 ) b = 1;
	int swiz = b * 8;
	int b32 = (index >> 5 ) * 32;
	int final = b32 + swiz + (index & 7 );
	return final;
}

// Assembly:
movl %edi, %eax
shrl $0x3, %eax
andl $0x3, %eax
leal (,%rax,8), %ecx
cmpl $0x2, %eax
pushq $0x8
popq %rdx
cmovnel %ecx, %edx
cmpl $0x1, %eax
pushq $0x10
popq %rax
cmovnel %edx, %eax
andl $-0x19, %edi
orl %edi, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/txp-convert.c
// Function: unfiddle
unsigned char *unfiddle(unsigned char *source, unsigned int width, unsigned int height, unsigned int bpp) {
	unsigned char *retpixel = malloc(width*height);
	unsigned int x, y, yc0, yc1, xc0, xc1, memptr = 0;
	for(y = 0; y < height; y++) {
		yc0 = y*16;
		if(bpp == 4) {
			yc1 = y/8*(width*4-128);
			for(x = 0; x < width/2; x++) {
				xc0 = x/16*16;
				xc1 = x/16*128;
				retpixel[memptr] = source[x-xc0+xc1+yc0+yc1] & 0xF;
				memptr++;
				retpixel[memptr] = source[x-xc0+xc1+yc0+yc1] >> 4;
				memptr++;
			}
		}
		else {
			yc1 = y/8*(width*8-128);
			for(x = 0; x < width; x++) {
				xc0 = x/16*16;
				xc1 = x/16*128;
				retpixel[memptr] = source[x-xc0+xc1+yc0+yc1];
				memptr++;
			}
		}
	}
	return retpixel;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebx
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %r15
movl %edx, %edi
imull %esi, %edi
callq 0x10f0
leal -0x80(,%r14,8), %ecx
movl %ecx, 0x4(%rsp)
leal -0x80(,%r14,4), %edx
movl %r14d, %esi
shrl %esi
xorl %edi, %edi
xorl %r8d, %r8d
cmpl %ebp, %edi
je 0xa67d
movl %edi, %r10d
shll $0x4, %r10d
movl %edi, %r9d
shrl $0x3, %r9d
cmpl $0x4, %ebx
jne 0xa631
imull %edx, %r9d
addl %r10d, %r9d
xorl %r10d, %r10d
xorl %r11d, %r11d
cmpl %r11d, %esi
je 0xa670
movl %r10d, %r12d
andl $-0x80, %r12d
movl %r11d, %r13d
andl $0xf, %r13d
addl %r9d, %r13d
addl %r12d, %r13d
movb (%r15,%r13), %r12b
movl %r12d, %r13d
andb $0xf, %r13b
movl %r8d, %ecx
movb %r13b, (%rax,%rcx)
leal 0x1(%r8), %ecx
shrb $0x4, %r12b
movb %r12b, (%rax,%rcx)
addl $0x2, %r8d
incl %r11d
addl $0x8, %r10d
jmp 0xa5ed
imull 0x4(%rsp), %r9d
addl %r10d, %r9d
xorl %r10d, %r10d
xorl %r11d, %r11d
leal (%r8,%r11), %r12d
cmpl %r11d, %r14d
je 0xa673
movl %r10d, %ecx
andl $-0x80, %ecx
movl %r11d, %r13d
andl $0xf, %r13d
addl %r9d, %r13d
addl %ecx, %r13d
movb (%r15,%r13), %cl
movl %r12d, %r12d
movb %cl, (%rax,%r12)
incl %r11d
addl $0x8, %r10d
jmp 0xa640
movl %r8d, %r12d
incl %edi
movl %r12d, %r8d
jmp 0xa5c5
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/txp-convert.c
// Function: buildPalette
paletteEntry *buildPalette(unsigned char *source, unsigned int bpp) {
	paletteEntry *retpal = NULL;
	unsigned int palsize;
	palsize = (bpp==4) ? 16:256;
	retpal = malloc(sizeof(paletteEntry)*palsize);
	unsigned int i, e = 0;
	for(i = 0; i < palsize; i++) {
		retpal[i].red = source[e];
		e++;
		retpal[i].green = source[e];
		e++;
		retpal[i].blue = source[e];
		e++;
		retpal[i].alpha = source[e];
		e++;
	}
	return retpal;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $0x4, %esi
pushq $0x10
popq %rax
movl $0x100, %r14d           # imm = 0x100
cmovel %eax, %r14d
leal (,%r14,4), %edi
callq 0x10f0
xorl %ecx, %ecx
cmpq %rcx, %r14
je 0xa6c2
movl (%rbx,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
incq %rcx
jmp 0xa6b2
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-mgs/txp-convert.c
// Function: getFramePixels
void getFramePixels(FILE *f, txpHeader header, textureHeader *textures, frameHeader *frames) {
	unsigned int i/*, j*/, palsize;
	uint32_t compressedsize;
	unsigned char *palette = NULL;
	for(i = 0; i < header.numframes; i++) {
		frames[i].texpixels = textures[frames[i].sourcetexture].texpixels;
		if(frames[i].palette == textures[frames[i].sourcetexture].palette) frames[i].palpixels = textures[frames[i].sourcetexture].palpixels;
		else {
			fseek(f, frames[i].palette, SEEK_SET);
			switch(textures[frames[i].sourcetexture].bpp) {
				case 4: {
					palsize = 16*4;
					break;
				}
				case 5: {
					palsize = 256*4;
					break;
				}
				case 6: {
					fseek(f, 20, SEEK_CUR);
					fread(&compressedsize, 4, 1, f);
					palsize = compressedsize;
					fseek(f, textures[i].palette, SEEK_SET);
					break;
				}
			}
			
			palette = malloc(palsize);
			fread(palette, palsize, 1, f);
			frames[i].palpixels = buildPalette(palette, textures[frames[i].sourcetexture].bpp);
			free(palette);
		}
	}
	return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r13
movl 0x5c(%rsp), %edx
addq $0x14, %rbx
leaq 0x14(%rsi), %rbp
xorl %r15d, %r15d
movq %rdi, 0x10(%rsp)
movq %rdx, 0x8(%rsp)
cmpq %rdx, %r15
jae 0xaa2a
movl (%rbx), %eax
movl 0x4(%rbx), %esi
imulq $0x28, %rax, %rax
movq 0x18(%r14,%rax), %rcx
movq %rcx, 0xc(%rbx)
cmpl 0x14(%r14,%rax), %esi
jne 0xa968
addq %r14, %rax
movq 0x20(%rax), %rax
movq %rax, 0x14(%rbx)
jmp 0xaa1a
movq %r13, %rdi
xorl %edx, %edx
callq 0x1110
movl (%rbx), %eax
imulq $0x28, %rax, %rax
movl (%r14,%rax), %eax
cmpl $0x6, %eax
je 0xa99a
cmpl $0x5, %eax
je 0xa993
cmpl $0x4, %eax
movl (%rsp), %eax
jne 0xa9d0
pushq $0x40
popq %rax
jmp 0xa9d0
movl $0x400, %eax            # imm = 0x400
jmp 0xa9d0
movq %r13, %rdi
pushq $0x14
popq %rsi
pushq $0x1
popq %rdx
callq 0x1110
leaq 0x4(%rsp), %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %r13, %rcx
callq 0x1060
movl 0x4(%rsp), %r12d
movl (%rbp), %esi
movq %r13, %rdi
xorl %edx, %edx
callq 0x1110
movl %r12d, %eax
movl %eax, (%rsp)
movl %eax, %r13d
movq %r13, %rdi
callq 0x10f0
movq %rax, %r12
movq %rax, %rdi
movq %r13, %rsi
pushq $0x1
popq %rdx
movq 0x10(%rsp), %r13
movq %r13, %rcx
callq 0x1060
movl (%rbx), %eax
imulq $0x28, %rax, %rax
movl (%r14,%rax), %esi
movq %r12, %rdi
callq 0xa68c
movq %rax, 0x14(%rbx)
movq %r12, %rdi
callq 0x1030
movq 0x8(%rsp), %rdx
incq %r15
addq $0x30, %rbx
addq $0x28, %rbp
jmp 0xa936
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq