LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/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 %r14
pushq %rbx
subq $0x1a0, %rsp            # imm = 0x1A0
movl 0x1c0(%rsp), %eax
movaps 0x40cc(%rip), %xmm0     # 0xe030
movq %rsp, %rbx
movups %xmm0, 0x24(%rbx)
xorl %r10d, %r10d
movl %r10d, (%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rbx)
movups %xmm0, 0x14(%rbx)
movaps 0x40bd(%rip), %xmm1     # 0xe040
movups %xmm1, 0x34(%rbx)
movl $0x1, %r11d
movl %r11d, 0x44(%rbx)
movups %xmm0, 0x48(%rbx)
movq %r10, 0x58(%rbx)
movl %r11d, 0x68(%rbx)
movabsq $0x100000001, %r14      # imm = 0x100000001
movq %r14, 0x60(%rbx)
movups %xmm0, 0x70(%rbx)
movl %r11d, 0x80(%rbx)
movups %xmm0, 0xa0(%rbx)
movabsq $0x800000006, %r14      # imm = 0x800000006
movq %r14, 0x88(%rbx)
movups %xmm0, 0x90(%rbx)
movups %xmm0, 0xd8(%rbx)
movq %r14, 0xc0(%rbx)
movups %xmm0, 0xc8(%rbx)
movl %r10d, 0xb8(%rbx)
movq %r10, 0xb0(%rbx)
movl %r10d, 0x154(%rbx)
movl %r10d, 0x138(%rbx)
movups %xmm0, 0x128(%rbx)
movups %xmm0, 0x118(%rbx)
movups %xmm0, 0x108(%rbx)
movups %xmm0, 0xf8(%rbx)
movups %xmm0, 0xe8(%rbx)
movups %xmm0, 0x188(%rbx)
movups %xmm0, 0x178(%rbx)
movups %xmm0, 0x168(%rbx)
movl %r11d, 0x198(%rbx)
movl %r9d, 0x88(%rbx)
movl %eax, 0x8c(%rbx)
movl %r9d, 0xc0(%rbx)
movl %eax, 0xc4(%rbx)
movq %rbx, %r9
callq 0x7c13
movl 0x198(%rbx), %ebp
movq %rbx, %rdi
callq 0x79bf
movl %ebp, %eax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 %rbx
subq $0x18, %rsp
movl %r8d, %eax
movl %ecx, %r8d
movl %edx, %ecx
movq %rsi, %rdx
movq %rdi, %rbx
movl %r9d, (%rsp)
leaq 0x8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movl %eax, %r9d
callq 0x9f4b
movl %eax, %ebp
testl %eax, %eax
jne 0xa0f1
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %rbx, %rdx
callq 0x1357
movl %eax, %ebp
movq 0x8(%rsp), %rdi
callq 0x1030
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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
movl $0x1, %ebx
cmpq %rsi, %rax
jae 0xa186
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 0xa184
movq %r15, 0x10(%r14)
movq %rax, (%r14)
jmp 0xa186
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/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 0xa228
movq %rax, %rbx
xorl %eax, %eax
movl $0x8, (%rbx,%rax,4)
incq %rax
cmpq $0x90, %rax
jne 0xa1ad
movl $0x90, %eax
movl $0x9, (%rbx,%rax,4)
incq %rax
cmpq $0x100, %rax            # imm = 0x100
jne 0xa1c4
movl $0x100, %eax            # imm = 0x100
movl $0x7, (%rbx,%rax,4)
incq %rax
cmpq $0x118, %rax            # imm = 0x118
jne 0xa1db
movl $0x118, %eax            # imm = 0x118
movl $0x8, (%rbx,%rax,4)
incq %rax
cmpq $0x120, %rax            # imm = 0x120
jne 0xa1f2
movl $0x120, %edx            # imm = 0x120
movq %r14, %rdi
movq %rbx, %rsi
movl $0xf, %ecx
callq 0xa287
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_O1/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 0xa27f
movq %rax, %rbx
xorl %eax, %eax
movl $0x5, (%rbx,%rax,4)
incq %rax
cmpq $0x20, %rax
jne 0xa24b
movl $0x20, %edx
movq %r14, %rdi
movq %rbx, %rsi
movl $0xf, %ecx
callq 0xa287
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_O1/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 0xa2e0
testq %r15, %r15
je 0xa2c8
xorl %ecx, %ecx
movl (%r12,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
incq %rcx
movl %ecx, %edx
cmpq %r15, %rdx
jne 0xa2b7
movl %r15d, 0x1c(%r14)
movl %ebx, 0x18(%r14)
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xa2f1
movl $0x53, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/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)
cmpq $0x0, 0x8(%rdx)
je 0xae53
movq %rcx, %rbp
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
xorl %r14d, %r14d
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 0xae62
cmpq $0x101, %rbx            # imm = 0x101
jb 0xae46
addl $0xfffffeff, %ebx       # imm = 0xFFFFFEFF
leaq 0x3869(%rip), %rax      # 0xe640
movl (%rax,%rbx,4), %ecx
movq (%r15), %rax
movl 0x4(%rax,%r14,4), %edx
movq %rbp, %rbx
movl 0x8(%rax,%r14,4), %ebp
leaq 0x394f(%rip), %rsi      # 0xe740
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 0xaf2f
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 0xae62
movq %r13, %rdi
movq %r12, %rsi
movl 0x4(%rsp), %edx
movq 0x10(%rsp), %rcx
callq 0xaf2f
incq %r14
cmpq 0x8(%r15), %r14
jne 0xada1
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0xaefa
movzbl (%rdi,%rdx), %eax
movzbl 0x1(%rdi,%rdx), %ecx
shll $0x4, %ecx
xorl %eax, %ecx
movzbl 0x2(%rdi,%rdx), %r8d
shll $0x8, %r8d
xorl %ecx, %r8d
jmp 0xaf2a
xorl %eax, %eax
movl $0x0, %r8d
cmpq %rsi, %rdx
jae 0xaf25
xorl %ecx, %ecx
movq %rdx, %r9
xorl %r8d, %r8d
movzbl (%rdi,%r9), %r10d
shll %cl, %r10d
xorl %r10d, %r8d
incq %r9
addl $0x8, %ecx
cmpq %r9, %rsi
jne 0xaf0f
cmpq %rsi, %rdx
jae 0xaf2e
movzwl %r8w, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/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
movl $0x1, %eax
xorl %ecx, %ecx
leaq (%r14,%rcx), %rdi
leaq -0x4(%rsi), %r12
decq %rax
cmpq %rdx, %rdi
jbe 0xaff0
decq %rcx
cmpl $0x0, -0x8(%r15,%rsi)
movq %r12, %rsi
je 0xafd2
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 0xb049
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 0x13a3
testl %eax, %eax
jne 0xb04e
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa2f1
movl $0x53, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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
movl $0x7, %r8d
cmovnel %ecx, %r8d
movl %esi, %r10d
andl %r8d, %r10d
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
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 0xb0b0
orb %r9b, (%rdi,%rax)
retq
movb %r9b, (%rdi,%rax)
retq
// File: /workspace/github_c_makefile_star2_O1/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 %rbx
movl %ecx, %eax
xorl %ecx, %ecx
movl %esi, %r9d
shrl %cl, %r9d
movl %edx, %r10d
shrl %cl, %r10d
andl $0x1, %r9d
andl $0x1, %r10d
movl %eax, %r11d
shrl %cl, %r11d
andl $0x1, %r11d
xorl %ebx, %ebx
btl %ecx, %r8d
setb %bl
leal (%rbx,%r10,4), %r10d
leal (%r10,%r9,8), %r9d
leal (%r9,%r11,2), %r9d
movq (%rdi,%r9,8), %rdi
testq %rdi, %rdi
je 0xb105
incl %ecx
cmpl $0x8, %ecx
jne 0xb0ba
movl 0x80(%rdi), %eax
jmp 0xb10a
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: readChunk_PLTE
static unsigned readChunk_PLTE(LodePNGColorMode* color, const unsigned char* data, size_t chunkLength)
{
  unsigned pos = 0, i;
  if(color->palette) lodepng_free(color->palette);
  color->palettesize = chunkLength / 3;
  color->palette = (unsigned char*)lodepng_malloc(4 * color->palettesize);
  if(!color->palette && color->palettesize)
  {
    color->palettesize = 0;
    return 83; /*alloc fail*/
  }
  if(color->palettesize > 256) return 38; /*error: palette too big*/

  for(i = 0; i != color->palettesize; ++i)
  {
    color->palette[4 * i + 0] = data[pos++]; /*R*/
    color->palette[4 * i + 1] = data[pos++]; /*G*/
    color->palette[4 * i + 2] = data[pos++]; /*B*/
    color->palette[4 * i + 3] = 255; /*alpha*/
  }

  return 0; /* OK */
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
testq %rdi, %rdi
je 0xb128
callq 0x1030
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
movq %r15, %rax
mulq %rcx
shrq %rdx
movq %rdx, 0x10(%rbx)
leaq (,%rdx,4), %rdi
callq 0x10f0
movq %rax, 0x8(%rbx)
testq %rax, %rax
setne %al
cmpq $0x3, %r15
setb %cl
orb %al, %cl
je 0xb1de
movl $0x26, %eax
cmpq $0x302, %r15            # imm = 0x302
ja 0xb1eb
xorl %eax, %eax
cmpq $0x0, 0x10(%rbx)
je 0xb1eb
movl $0x3, %ecx
movl $0x1, %edx
movl $0x1, %esi
leal -0x1(%rdx), %edi
movb (%r14,%rdi), %dil
movq 0x8(%rbx), %r8
leal -0x3(%rcx), %r9d
movb %dil, (%r8,%r9)
leal 0x1(%rdx), %edi
movl %edx, %r8d
movb (%r14,%r8), %r8b
movq 0x8(%rbx), %r9
leal -0x2(%rcx), %r10d
movb %r8b, (%r9,%r10)
movb (%r14,%rdi), %dil
movq 0x8(%rbx), %r8
leal -0x1(%rcx), %r9d
movb %dil, (%r8,%r9)
movq 0x8(%rbx), %rdi
movl %ecx, %r8d
movb $-0x1, (%rdi,%r8)
movl %esi, %edi
incl %esi
addl $0x4, %ecx
addl $0x3, %edx
cmpq %rdi, 0x10(%rbx)
jne 0xb187
jmp 0xb1eb
movq $0x0, 0x10(%rbx)
movl $0x53, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: readChunk_tRNS
static unsigned readChunk_tRNS(LodePNGColorMode* color, const unsigned char* data, size_t chunkLength)
{
  unsigned i;
  if(color->colortype == LCT_PALETTE)
  {
    /*error: more alpha values given than there are palette entries*/
    if(chunkLength > color->palettesize) return 38;

    for(i = 0; i != chunkLength; ++i) color->palette[4 * i + 3] = data[i];
  }
  else if(color->colortype == LCT_GREY)
  {
    /*error: this chunk must be 2 bytes for greyscale image*/
    if(chunkLength != 2) return 30;

    color->key_defined = 1;
    color->key_r = color->key_g = color->key_b = 256u * data[0] + data[1];
  }
  else if(color->colortype == LCT_RGB)
  {
    /*error: this chunk must be 6 bytes for RGB image*/
    if(chunkLength != 6) return 41;

    color->key_defined = 1;
    color->key_r = 256u * data[0] + data[1];
    color->key_g = 256u * data[2] + data[3];
    color->key_b = 256u * data[4] + data[5];
  }
  else return 42; /*error: tRNS chunk not allowed for other color models*/

  return 0; /* OK */
}

// Assembly:
movl (%rdi), %ecx
testl %ecx, %ecx
je 0xb285
cmpl $0x2, %ecx
je 0xb246
movl $0x2a, %eax
cmpl $0x3, %ecx
jne 0xb245
movl $0x26, %eax
cmpq %rdx, 0x10(%rdi)
jb 0xb245
testq %rdx, %rdx
je 0xb2af
movl $0x3, %ecx
xorl %eax, %eax
xorl %r8d, %r8d
movb (%rsi,%r8), %r9b
movq 0x8(%rdi), %r10
movl %ecx, %r11d
movb %r9b, (%r10,%r11)
incq %r8
movl %r8d, %r9d
addl $0x4, %ecx
cmpq %rdx, %r9
jne 0xb228
retq
movl $0x29, %eax
cmpq $0x6, %rdx
jne 0xb245
movl $0x1, 0x18(%rdi)
movzwl (%rsi), %eax
rolw $0x8, %ax
movzwl %ax, %eax
movl %eax, 0x1c(%rdi)
movzwl 0x2(%rsi), %eax
rolw $0x8, %ax
movzwl %ax, %eax
movl %eax, 0x20(%rdi)
movzwl 0x4(%rsi), %eax
rolw $0x8, %ax
movzwl %ax, %eax
movl $0x24, %ecx
jmp 0xb2ac
movl $0x1e, %eax
cmpq $0x2, %rdx
jne 0xb245
movl $0x1, 0x18(%rdi)
movzwl (%rsi), %eax
rolw $0x8, %ax
movzwl %ax, %eax
movl %eax, 0x24(%rdi)
movl %eax, 0x20(%rdi)
movl $0x1c, %ecx
movl %eax, (%rdi,%rcx)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: readChunk_bKGD
static unsigned readChunk_bKGD(LodePNGInfo* info, const unsigned char* data, size_t chunkLength)
{
  if(info->color.colortype == LCT_PALETTE)
  {
    /*error: this chunk must be 1 byte for indexed color image*/
    if(chunkLength != 1) return 43;

    info->background_defined = 1;
    info->background_r = info->background_g = info->background_b = data[0];
  }
  else if(info->color.colortype == LCT_GREY || info->color.colortype == LCT_GREY_ALPHA)
  {
    /*error: this chunk must be 2 bytes for greyscale image*/
    if(chunkLength != 2) return 44;

    info->background_defined = 1;
    info->background_r = info->background_g = info->background_b = 256u * data[0] + data[1];
  }
  else if(info->color.colortype == LCT_RGB || info->color.colortype == LCT_RGBA)
  {
    /*error: this chunk must be 6 bytes for greyscale image*/
    if(chunkLength != 6) return 45;

    info->background_defined = 1;
    info->background_r = 256u * data[0] + data[1];
    info->background_g = 256u * data[2] + data[3];
    info->background_b = 256u * data[4] + data[5];
  }

  return 0; /* OK */
}

// Assembly:
movl 0x10(%rdi), %ecx
xorl %eax, %eax
cmpq $0x6, %rcx
ja 0xb353
leaq 0x2e4c(%rip), %r8       # 0xe114
movslq (%r8,%rcx,4), %rcx
addq %r8, %rcx
jmpq *%rcx
movl $0x2c, %eax
cmpq $0x2, %rdx
jne 0xb353
movl $0x1, 0x38(%rdi)
movzwl (%rsi), %eax
rolw $0x8, %ax
movzwl %ax, %eax
jmp 0xb343
movl $0x2d, %eax
cmpq $0x6, %rdx
jne 0xb353
movl $0x1, 0x38(%rdi)
movzwl (%rsi), %eax
rolw $0x8, %ax
movzwl %ax, %eax
movl %eax, 0x3c(%rdi)
movzwl 0x2(%rsi), %eax
rolw $0x8, %ax
movzwl %ax, %eax
movl %eax, 0x40(%rdi)
movzwl 0x4(%rsi), %eax
rolw $0x8, %ax
movzwl %ax, %eax
movl $0x44, %ecx
jmp 0xb34e
movl $0x2b, %eax
cmpq $0x1, %rdx
jne 0xb353
movl $0x1, 0x38(%rdi)
movzbl (%rsi), %eax
movl %eax, 0x44(%rdi)
movl %eax, 0x40(%rdi)
movl $0x3c, %ecx
movl %eax, (%rdi,%rcx)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: readChunk_tEXt
static unsigned readChunk_tEXt(LodePNGInfo* info, const unsigned char* data, size_t chunkLength)
{
  unsigned error = 0;
  char *key = 0, *str = 0;
  unsigned i;

  while(!error) /*not really a while loop, only used to break on error*/
  {
    unsigned length, string2_begin;

    length = 0;
    while(length < chunkLength && data[length] != 0) ++length;
    /*even though it's not allowed by the standard, no error is thrown if
    there's no null termination char, if the text is empty*/
    if(length < 1 || length > 79) CERROR_BREAK(error, 89); /*keyword too short or long*/

    key = (char*)lodepng_malloc(length + 1);
    if(!key) CERROR_BREAK(error, 83); /*alloc fail*/

    key[length] = 0;
    for(i = 0; i != length; ++i) key[i] = (char)data[i];

    string2_begin = length + 1; /*skip keyword null terminator*/

    length = chunkLength < string2_begin ? 0 : chunkLength - string2_begin;
    str = (char*)lodepng_malloc(length + 1);
    if(!str) CERROR_BREAK(error, 83); /*alloc fail*/

    str[length] = 0;
    for(i = 0; i != length; ++i) str[i] = (char)data[string2_begin + i];

    error = lodepng_add_text(info, key, str);

    break;
  }

  lodepng_free(key);
  lodepng_free(str);

  return error;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r12
movq %rsi, %r14
testq %rdx, %rdx
je 0xb381
xorl %ebp, %ebp
xorl %ebx, %ebx
cmpb $0x0, (%r14,%rbp)
je 0xb385
incl %ebx
movq %rbx, %rbp
cmpq %r12, %rbx
jb 0xb36e
jmp 0xb385
xorl %ebx, %ebx
xorl %ebp, %ebp
leal -0x50(%rbx), %eax
cmpl $-0x4f, %eax
jae 0xb39c
movl $0x59, %ebp
xorl %r15d, %r15d
xorl %ebx, %ebx
jmp 0xb423
movq %rdi, (%rsp)
leal 0x1(%rbx), %r13d
movq %r13, %rdi
callq 0x10f0
testq %rax, %rax
je 0xb419
movq %rax, %r15
movb $0x0, (%rax,%rbp)
testl %ebx, %ebx
je 0xb3c9
movl %ebx, %edx
movq %r15, %rdi
movq %r14, %rsi
callq 0x10e0
xorl %eax, %eax
movq %r12, %rbp
subq %r13, %rbp
cmovbq %rax, %rbp
leal 0x1(%rbp), %edi
callq 0x10f0
testq %rax, %rax
je 0xb41c
movq %rax, %rbx
movl %ebp, %eax
movb $0x0, (%rbx,%rax)
cmpq %r12, %r13
jae 0xb406
movl %ebp, %eax
xorl %ecx, %ecx
leal (%rcx,%r13), %edx
movb (%r14,%rdx), %dl
movb %dl, (%rbx,%rcx)
incq %rcx
cmpl %ecx, %eax
jne 0xb3f4
movq (%rsp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x471c
movl %eax, %ebp
jmp 0xb423
xorl %r15d, %r15d
xorl %ebx, %ebx
movl $0x53, %ebp
movq %r15, %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x1030
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: readChunk_tIME
static unsigned readChunk_tIME(LodePNGInfo* info, const unsigned char* data, size_t chunkLength)
{
  if(chunkLength != 7) return 73; /*invalid tIME chunk size*/

  info->time_defined = 1;
  info->time.year = 256u * data[0] + data[1];
  info->time.month = data[2];
  info->time.day = data[3];
  info->time.hour = data[4];
  info->time.minute = data[5];
  info->time.second = data[6];

  return 0; /* OK */
}

// Assembly:
movl $0x49, %eax
cmpq $0x7, %rdx
jne 0xb927
movl $0x1, 0x88(%rdi)
movzwl (%rsi), %eax
rolw $0x8, %ax
movzwl %ax, %eax
movl %eax, 0x8c(%rdi)
movzbl 0x2(%rsi), %eax
movl %eax, 0x90(%rdi)
movzbl 0x3(%rsi), %eax
movl %eax, 0x94(%rdi)
movzbl 0x4(%rsi), %eax
movl %eax, 0x98(%rdi)
movzbl 0x5(%rsi), %eax
movl %eax, 0x9c(%rdi)
movzbl 0x6(%rsi), %eax
movl %eax, 0xa0(%rdi)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: readChunk_pHYs
static unsigned readChunk_pHYs(LodePNGInfo* info, const unsigned char* data, size_t chunkLength)
{
  if(chunkLength != 9) return 74; /*invalid pHYs chunk size*/

  info->phys_defined = 1;
  info->phys_x = 16777216u * data[0] + 65536u * data[1] + 256u * data[2] + data[3];
  info->phys_y = 16777216u * data[4] + 65536u * data[5] + 256u * data[6] + data[7];
  info->phys_unit = data[8];

  return 0; /* OK */
}

// Assembly:
movl $0x4a, %eax
cmpq $0x9, %rdx
jne 0xb95e
movl $0x1, 0xa4(%rdi)
movl (%rsi), %eax
bswapl %eax
movl %eax, 0xa8(%rdi)
movl 0x4(%rsi), %eax
bswapl %eax
movl %eax, 0xac(%rdi)
movzbl 0x8(%rsi), %eax
movl %eax, 0xb0(%rdi)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: lodepng_get_raw_size_idat
static size_t lodepng_get_raw_size_idat(unsigned w, unsigned h, const LodePNGColorMode* color)
{
  /*will not overflow for any color type if roughly w * h < 268435455*/
  size_t bpp = lodepng_get_bpp(color);
  size_t line = ((w / 8) * bpp) + ((w & 7) * bpp + 7) / 8;
  return h * line;
}

// Assembly:
movl (%rdx), %r8d
movl 0x4(%rdx), %ecx
xorl %eax, %eax
cmpq $0x6, %r8
ja 0xb978
leaq 0x30b0(%rip), %rax      # 0xea24
movl (%rax,%r8,4), %eax
imull %ecx, %eax
movl %edi, %ecx
shrl $0x3, %ecx
imulq %rax, %rcx
andl $0x7, %edi
imulq %rax, %rdi
addq $0x7, %rdi
shrq $0x3, %rdi
addq %rcx, %rdi
movl %esi, %eax
imulq %rdi, %rax
retq
// File: /workspace/github_c_makefile_star2_O1/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:
testl %r8d, %r8d
je 0xbdec
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rcx, %rax
subq %rdx, %rax
xorl %r9d, %r9d
xorl %r10d, %r10d
xorl %r11d, %r11d
testq %rdx, %rdx
je 0xbdd9
movq %rdx, %rbx
movq %r11, %r14
movq %r14, %rcx
shrq $0x3, %rcx
movl %r14d, %ebp
notb %bpl
movzbl (%rsi,%rcx), %r15d
movzbl %bpl, %r12d
andl $0x7, %r12d
movl %r10d, %ecx
notb %cl
andb $0x7, %cl
movb $0x1, %bpl
shlb %cl, %bpl
btl %r12d, %r15d
jae 0xbdbd
movq %r10, %rcx
shrq $0x3, %rcx
orb %bpl, (%rdi,%rcx)
jmp 0xbdcb
notb %bpl
movq %r10, %rcx
shrq $0x3, %rcx
andb %bpl, (%rdi,%rcx)
incq %r10
incq %r14
decq %rbx
jne 0xbd82
addq %rdx, %r11
addq %rax, %r11
incl %r9d
cmpl %r8d, %r9d
jne 0xbd77
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x2a08(%rip), %r15      # 0xe810
leaq 0x2a21(%rip), %r12      # 0xe830
leaq 0x2a3a(%rip), %r13      # 0xe850
leaq 0x2a53(%rip), %rbp      # 0xe870
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 0xbe67
movl $0x0, (%rdi,%r14)
addq $0x4, %r14
cmpq $0x1c, %r14
jne 0xbe1d
xorl %eax, %eax
movq %rax, (%r8)
movq %rax, (%rcx)
movq %rax, (%r10)
movl 0x40(%rsp), %ebx
movl (%rdi,%rax), %edx
testl %edx, %edx
je 0xbea8
movl (%rsi,%rax), %r9d
testl %r9d, %r9d
je 0xbea8
movl %edx, %r11d
imull %ebx, %r11d
addl $0x7, %r11d
shrl $0x3, %r11d
incl %r11d
imull %r11d, %r9d
jmp 0xbeab
xorl %r9d, %r9d
addq (%r10,%rax,2), %r9
movq %r9, 0x8(%r10,%rax,2)
movl (%rsi,%rax), %r9d
imull %ebx, %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
cmpq $0x1c, %rax
jne 0xbe80
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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:
testl %r8d, %r8d
je 0xbfb8
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %rax
movq %rdx, %r9
subq %rcx, %r9
xorl %r10d, %r10d
xorl %r11d, %r11d
xorl %ebx, %ebx
testq %rax, %rax
je 0xbf7d
movq %rax, %r14
movq %r11, %r15
movq %r15, %rcx
shrq $0x3, %rcx
movl %r15d, %ebp
notb %bpl
movzbl (%rsi,%rcx), %r12d
movzbl %bpl, %r13d
andl $0x7, %r13d
movl %ebx, %ecx
notb %cl
andb $0x7, %cl
movb $0x1, %bpl
shlb %cl, %bpl
btl %r13d, %r12d
jae 0xbf61
movq %rbx, %rcx
shrq $0x3, %rcx
orb %bpl, (%rdi,%rcx)
jmp 0xbf6f
notb %bpl
movq %rbx, %rcx
shrq $0x3, %rcx
andb %bpl, (%rdi,%rcx)
incq %rbx
incq %r15
decq %r14
jne 0xbf27
addq %rax, %r11
movq %r9, %r14
cmpq %rax, %rdx
je 0xbfa2
movl %ebx, %ecx
notb %cl
movb $-0x2, %bpl
rolb %cl, %bpl
movq %rbx, %rcx
shrq $0x3, %rcx
andb %bpl, (%rdi,%rcx)
incq %rbx
decq %r14
jne 0xbf85
incl %r10d
cmpl %r8d, %r10d
jne 0xbf1c
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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
movl $0x8, %edx
cmovnel %ecx, %edx
cmpl $0x1, %eax
movl $0x10, %eax
cmovnel %edx, %eax
andl $-0x19, %edi
orl %edi, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/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
testl %ebp, %ebp
je 0xd2c6
leal -0x80(,%r14,8), %ecx
leal -0x80(,%r14,4), %edx
movl %edx, 0x4(%rsp)
movl %r14d, %esi
shrl %esi
xorl %edi, %edi
xorl %r8d, %r8d
movl %r8d, %r10d
shll $0x4, %r10d
cmpl $0x4, %ebx
jne 0xd272
cmpl $0x2, %r14d
jb 0xd2ba
movl %r8d, %r9d
shrl $0x3, %r9d
imull 0x4(%rsp), %r9d
addl %r10d, %r9d
xorl %r10d, %r10d
xorl %r11d, %r11d
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 %edi, %edx
movb %r13b, (%rax,%rdx)
leal 0x1(%rdi), %edx
shrb $0x4, %r12b
movb %r12b, (%rax,%rdx)
addl $0x2, %edi
incl %r11d
addl $0x8, %r10d
cmpl %r11d, %esi
jne 0xd231
jmp 0xd2ba
testl %r14d, %r14d
je 0xd2ba
movl %r8d, %r9d
shrl $0x3, %r9d
imull %ecx, %r9d
addl %r10d, %r9d
xorl %r11d, %r11d
xorl %r10d, %r10d
leal (%rdi,%r10), %edx
movl %r11d, %r12d
andl $-0x80, %r12d
movl %r10d, %r13d
andl $0xf, %r13d
addl %r9d, %r13d
addl %r12d, %r13d
movb (%r15,%r13), %r12b
movb %r12b, (%rax,%rdx)
incl %r10d
addl $0x8, %r11d
cmpl %r10d, %r14d
jne 0xd28b
addl %r10d, %edi
incl %r8d
cmpl %ebp, %r8d
jne 0xd205
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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
movl $0x10, %eax
movl $0x100, %r14d           # imm = 0x100
cmovel %eax, %r14d
leal (,%r14,4), %edi
callq 0x10f0
xorl %ecx, %ecx
movb (%rbx,%rcx,4), %dl
movb %dl, (%rax,%rcx,4)
movb 0x1(%rbx,%rcx,4), %dl
movb %dl, 0x1(%rax,%rcx,4)
movb 0x2(%rbx,%rcx,4), %dl
movb %dl, 0x2(%rax,%rcx,4)
movb 0x3(%rbx,%rcx,4), %dl
movb %dl, 0x3(%rax,%rcx,4)
incq %rcx
cmpq %rcx, %r14
jne 0xd2fd
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/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
movl 0x5c(%rsp), %eax
testq %rax, %rax
je 0xd69b
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r13
addq $0x14, %rbx
shlq $0x3, %rax
leaq (%rax,%rax,4), %r15
xorl %r12d, %r12d
movq %rdi, 0x10(%rsp)
movl (%rbx), %eax
movl 0x4(%rbx), %esi
leaq (%rax,%rax,4), %rax
movq 0x18(%r14,%rax,8), %rcx
movq %rcx, 0xc(%rbx)
cmpl 0x14(%r14,%rax,8), %esi
jne 0xd5cf
leaq (%r14,%rax,8), %rax
movq 0x20(%rax), %rax
movq %rax, 0x14(%rbx)
jmp 0xd68a
movq %r13, %rdi
xorl %edx, %edx
callq 0x1110
movl (%rbx), %eax
leaq (%rax,%rax,4), %rax
movl (%r14,%rax,8), %eax
cmpl $0x6, %eax
je 0xd604
cmpl $0x5, %eax
je 0xd5fd
cmpl $0x4, %eax
movl 0x8(%rsp), %eax
jne 0xd642
movl $0x40, %eax
jmp 0xd642
movl $0x400, %eax            # imm = 0x400
jmp 0xd642
movl $0x14, %esi
movq %r13, %rdi
movl $0x1, %edx
callq 0x1110
movl $0x4, %esi
movl $0x1, %edx
leaq 0xc(%rsp), %rdi
movq %r13, %rcx
callq 0x1060
movl 0xc(%rsp), %ebp
movl 0x14(%r14,%r12), %esi
movq %r13, %rdi
xorl %edx, %edx
callq 0x1110
movl %ebp, %eax
movl %eax, 0x8(%rsp)
movl %eax, %r13d
movq %r13, %rdi
callq 0x10f0
movq %rax, %rbp
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
movq 0x10(%rsp), %r13
movq %r13, %rcx
callq 0x1060
movl (%rbx), %eax
leaq (%rax,%rax,4), %rax
movl (%r14,%rax,8), %esi
movq %rbp, %rdi
callq 0xd2d5
movq %rax, 0x14(%rbx)
movq %rbp, %rdi
callq 0x1030
addq $0x30, %rbx
addq $0x28, %r12
cmpq %r12, %r15
jne 0xd5a5
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/Joy-Division[P]tools-mgs/txp-convert.c
// Function: buildSingleFrameRgba
unsigned char *buildSingleFrameRgba(textureHeader *textures, frameHeader frame) {
	unsigned int x, y, mempointer = 0, framesize = frame.width * frame.height;
	unsigned char *retframe = malloc(framesize * 4), pixel;
	for(y = frame.sourcey; y < frame.sourcey+frame.height; y++) {
		for(x = frame.sourcex; x < frame.sourcex+frame.width; x++) {
			pixel = frame.texpixels[x+y*textures[frame.sourcetexture].width];
			retframe[mempointer] = frame.palpixels[pixel].red;
			mempointer++;
			retframe[mempointer] = frame.palpixels[pixel].green;
			mempointer++;
			retframe[mempointer] = frame.palpixels[pixel].blue;
			mempointer++;
			retframe[mempointer] = frame.palpixels[pixel].alpha;
			mempointer++;
		}
	}
	return retframe;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x44(%rsp), %r14d
movl 0x48(%rsp), %ebp
movl %r14d, %edi
imull %ebp, %edi
shll $0x2, %edi
callq 0x10f0
movl 0x50(%rsp), %ecx
addl %ecx, %ebp
cmpl %ebp, %ecx
jae 0xd768
leaq 0x40(%rsp), %r8
movl 0xc(%r8), %edx
movl 0x14(%r8), %edi
addl %edx, %r14d
movq 0x20(%r8), %rsi
leaq (%rdi,%rdi,4), %rdi
leaq (%rbx,%rdi,8), %rdi
addq $0x8, %rdi
movq 0x28(%r8), %r8
movq %r14, %r9
subq %rdx, %r9
xorl %r10d, %r10d
cmpl %r14d, %edx
jae 0xd762
movl (%rdi), %r11d
imull %ecx, %r11d
addl %edx, %r11d
movq %r9, %rbx
movl %r11d, %r15d
movzbl (%rsi,%r15), %r15d
movb (%r8,%r15,4), %r12b
movl %r10d, %r13d
movb %r12b, (%rax,%r13)
leal 0x1(%r10), %r12d
movb 0x1(%r8,%r15,4), %r13b
movb %r13b, (%rax,%r12)
leal 0x2(%r10), %r12d
movb 0x2(%r8,%r15,4), %r13b
movb %r13b, (%rax,%r12)
leal 0x3(%r10), %r12d
movb 0x3(%r8,%r15,4), %r15b
movb %r15b, (%rax,%r12)
addl $0x4, %r10d
incl %r11d
decq %rbx
jne 0xd71c
incl %ecx
cmpl %ebp, %ecx
jne 0xd70a
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/YanjieZe[P]CacheLab/tracegen.c
// Function: validate
int validate(int fn,int M, int N, int A[N][M], int B[M][N]) {
    int C[M][N];
    memset(C,0,sizeof(C));
    correctTrans(M,N,A,C);
    for(int i=0;i<M;i++) {
        for(int j=0;j<N;j++) {
            if(B[i][j]!=C[i][j]) {
                printf("Validation failed on function %d! Expected %d but got %d at B[%d][%d]\n",fn,C[i][j],B[i][j],i,j);
                return 0;
            }
        }
    }
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %r14
movq %rcx, -0x40(%rbp)
movl %edx, %r15d
movl %esi, %r13d
movl %edi, -0x2c(%rbp)
movl %edx, %ebx
movl %esi, %edx
movq %rdx, -0x38(%rbp)
imulq %rbx, %rdx
leaq 0xf(,%rdx,4), %rax
andq $-0x10, %rax
movq %rsp, %r12
subq %rax, %r12
movq %r12, %rsp
shlq $0x2, %rdx
movq %r12, %rdi
xorl %esi, %esi
callq 0x1070
movl %r13d, %edi
movl %r15d, %esi
movq -0x40(%rbp), %rdx
movq %r12, %rcx
callq 0x563c
testl %r13d, %r13d
setle %r13b
jle 0x12ba
leaq (,%rbx,4), %rax
xorl %r8d, %r8d
movq -0x38(%rbp), %rsi
testl %r15d, %r15d
jle 0x1292
xorl %r9d, %r9d
movl (%r14,%r9,4), %ecx
movl (%r12,%r9,4), %edx
cmpl %edx, %ecx
jne 0x12a9
incq %r9
cmpq %r9, %rbx
jne 0x127e
incq %r8
cmpq %rsi, %r8
setae %r13b
addq %rax, %r12
addq %rax, %r14
cmpq %rsi, %r8
jne 0x1276
jmp 0x12ba
leaq 0x4d54(%rip), %rdi      # 0x6004
movl -0x2c(%rbp), %esi
xorl %eax, %eax
callq 0x1050
movzbl %r13b, %eax
andl $0x1, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/YanjieZe[P]CacheLab/cachelab.c
// Function: printSummary
void printSummary(int hits, int misses, int evictions)
{
    printf("hits:%d misses:%d evictions:%d\n", hits, misses, evictions);
    FILE* output_fp = fopen(".csim_results", "w");
    assert(output_fp);
    fprintf(output_fp, "%d %d %d\n", hits, misses, evictions);
    fclose(output_fp);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %ebx
movl %esi, %r14d
movl %edi, %r15d
leaq 0xc0c(%rip), %rdi       # 0x60ba
movl %r15d, %esi
movl %r14d, %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x1050
leaq 0xc16(%rip), %rdi       # 0x60da
leaq 0xb8f(%rip), %rsi       # 0x605a
callq 0x10b0
testq %rax, %rax
je 0x5502
movq %rax, %r12
leaq 0xc3f(%rip), %rsi       # 0x611e
movq %rax, %rdi
movl %r15d, %edx
movl %r14d, %ecx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x1090
movq %r12, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x1040
leaq 0xbdf(%rip), %rdi       # 0x60e8
leaq 0xbe2(%rip), %rsi       # 0x60f2
leaq 0xbe6(%rip), %rcx       # 0x60fd
movl $0x15, %edx
callq 0x1060
// File: /workspace/github_c_makefile_star2_O1/YanjieZe[P]CacheLab/cachelab.c
// Function: initMatrix
void initMatrix(int M, int N, int A[N][M], int B[M][N])
{
    int i, j;
    srand(time(NULL));
    for (i = 0; i < N; i++){
        for (j = 0; j < M; j++){
            // A[i][j] = i+j;  /* The matrix created this way is symmetric */
            A[i][j]=rand();
            B[j][i]=rand();
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, -0x38(%rbp)
movq %rdx, %r14
movl %esi, %r12d
movl %edi, -0x2c(%rbp)
xorl %edi, %edi
callq 0x10a0
movl %eax, %edi
callq 0x1080
testl %r12d, %r12d
jle 0x55b5
movl %r12d, %eax
movl -0x2c(%rbp), %r13d
movq %rax, -0x48(%rbp)
leaq (,%rax,4), %r15
leaq (,%r13,4), %rax
movq %rax, -0x40(%rbp)
xorl %eax, %eax
movq %rax, -0x50(%rbp)
cmpl $0x0, -0x2c(%rbp)
jle 0x559f
movq -0x38(%rbp), %rbx
xorl %r12d, %r12d
callq 0x10f0
movl %eax, (%r14,%r12,4)
callq 0x10f0
movl %eax, (%rbx)
incq %r12
addq %r15, %rbx
cmpq %r12, %r13
jne 0x5584
movq -0x50(%rbp), %rax
incq %rax
addq $0x4, -0x38(%rbp)
addq -0x40(%rbp), %r14
cmpq -0x48(%rbp), %rax
jne 0x5573
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/YanjieZe[P]CacheLab/cachelab.c
// Function: randMatrix
void randMatrix(int M, int N, int A[N][M]) {
    int i, j;
    srand(time(NULL));
    for (i = 0; i < N; i++){
        for (j = 0; j < M; j++){
            // A[i][j] = i+j;  /* The matrix created this way is symmetric */
            A[i][j]=rand();
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movl %esi, %r15d
movl %edi, -0x2c(%rbp)
xorl %edi, %edi
callq 0x10a0
movl %eax, %edi
callq 0x1080
testl %r15d, %r15d
jle 0x562d
movl -0x2c(%rbp), %r12d
movl %r15d, %eax
movq %rax, -0x38(%rbp)
leaq (,%r12,4), %r13
xorl %r14d, %r14d
cmpl $0x0, -0x2c(%rbp)
jle 0x5621
xorl %r15d, %r15d
callq 0x10f0
movl %eax, (%rbx,%r15,4)
incq %r15
cmpq %r15, %r12
jne 0x5610
incq %r14
addq %r13, %rbx
cmpq -0x38(%rbp), %r14
jne 0x5607
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/YanjieZe[P]CacheLab/cachelab.c
// Function: correctTrans
void correctTrans(int M, int N, int A[N][M], int B[M][N])
{
    int i, j, tmp;
    for (i = 0; i < N; i++){
        for (j = 0; j < M; j++){
            tmp = A[i][j];
            B[j][i] = tmp;
        }
    }    
}

// Assembly:
testl %esi, %esi
jle 0x568c
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %esi, %eax
movl %edi, %esi
leaq (,%rax,4), %r8
leaq (,%rsi,4), %r9
xorl %r10d, %r10d
testl %edi, %edi
jle 0x5679
movq %rcx, %r11
xorl %ebx, %ebx
movl (%rdx,%rbx,4), %r14d
movl %r14d, (%r11)
incq %rbx
addq %r8, %r11
cmpq %rbx, %rsi
jne 0x5667
incq %r10
addq $0x4, %rcx
addq %r9, %rdx
cmpq %rax, %r10
jne 0x565e
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/YanjieZe[P]CacheLab/cachelab.c
// Function: registerTransFunction
void registerTransFunction(void (*trans)(int M, int N, int[N][M], int[M][N]), 
                           char* desc)
{
    func_list[func_counter].func_ptr = trans;
    func_list[func_counter].description = desc;
    func_list[func_counter].correct = 0;
    func_list[func_counter].num_hits = 0;
    func_list[func_counter].num_misses = 0;
    func_list[func_counter].num_evictions =0;
    func_counter++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movslq 0x82ce8(%rip), %rax     # 0x88380
leal 0x1(%rax), %ecx
shlq $0x5, %rax
leaq 0x82cea(%rip), %rdx     # 0x88390
movq %rdi, (%rax,%rdx)
movq %rsi, 0x8(%rax,%rdx)
movb $0x0, 0x10(%rax,%rdx)
movq $0x0, 0x14(%rax,%rdx)
movl $0x0, 0x1c(%rax,%rdx)
movl %ecx, 0x82cb5(%rip)     # 0x88380
popq %rbp
retq