// File: /workspace/github_c_makefile_star2_O0/zhiyb[P]png2tlg/./stb_image.h
// Function: stbi__pic_load_core(stbi__context*, int, int, int*, unsigned char*)
static stbi_uc *stbi__pic_load_core(stbi__context *s,int width,int height,int *comp, stbi_uc *result)
{
   int act_comp=0,num_packets=0,y,chained;
   stbi__pic_packet packets[10];

   // this will (should...) cater for even some bizarre stuff like having data
    // for the same channel in multiple packets.
   do {
      stbi__pic_packet *packet;

      if (num_packets==sizeof(packets)/sizeof(packets[0]))
         return stbi__errpuc("bad format","too many packets");

      packet = &packets[num_packets++];

      chained = stbi__get8(s);
      packet->size    = stbi__get8(s);
      packet->type    = stbi__get8(s);
      packet->channel = stbi__get8(s);

      act_comp |= packet->channel;

      if (stbi__at_eof(s))          return stbi__errpuc("bad file","file too short (reading packets)");
      if (packet->size != 8)  return stbi__errpuc("bad format","packet isn't 8bpp");
   } while (chained);

   *comp = (act_comp & 0x10 ? 4 : 3); // has alpha channel?

   for(y=0; y<height; ++y) {
      int packet_idx;

      for(packet_idx=0; packet_idx < num_packets; ++packet_idx) {
         stbi__pic_packet *packet = &packets[packet_idx];
         stbi_uc *dest = result+y*width*4;

         switch (packet->type) {
            default:
               return stbi__errpuc("bad format","packet has bad compression type");

            case 0: {//uncompressed
               int x;

               for(x=0;x<width;++x, dest+=4)
                  if (!stbi__readval(s,packet->channel,dest))
                     return 0;
               break;
            }

            case 1://Pure RLE
               {
                  int left=width, i;

                  while (left>0) {
                     stbi_uc count,value[4];

                     count=stbi__get8(s);
                     if (stbi__at_eof(s))   return stbi__errpuc("bad file","file too short (pure read count)");

                     if (count > left)
                        count = (stbi_uc) left;

                     if (!stbi__readval(s,packet->channel,value))  return 0;

                     for(i=0; i<count; ++i,dest+=4)
                        stbi__copyval(packet->channel,dest,value);
                     left -= count;
                  }
               }
               break;

            case 2: {//Mixed RLE
               int left=width;
               while (left>0) {
                  int count = stbi__get8(s), i;
                  if (stbi__at_eof(s))  return stbi__errpuc("bad file","file too short (mixed read count)");

                  if (count >= 128) { // Repeated
                     stbi_uc value[4];

                     if (count==128)
                        count = stbi__get16be(s);
                     else
                        count -= 127;
                     if (count > left)
                        return stbi__errpuc("bad file","scanline overrun");

                     if (!stbi__readval(s,packet->channel,value))
                        return 0;

                     for(i=0;i<count;++i, dest += 4)
                        stbi__copyval(packet->channel,dest,value);
                  } else { // Raw
                     ++count;
                     if (count>left) return stbi__errpuc("bad file","scanline overrun");

                     for(i=0;i<count;++i, dest+=4)
                        if (!stbi__readval(s,packet->channel,dest))
                           return 0;
                  }
                  left-=count;
               }
               break;
            }
         }
      }
   }

   return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movslq -0x30(%rbp), %rax
cmpq $0xa, %rax
jne 0x1c0e5
leaq 0x4f0c(%rip), %rdi      # 0x20fd8
callq 0x2680
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0x1c601
movl -0x30(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x30(%rbp)
movslq %eax, %rcx
leaq -0x60(%rbp), %rax
imulq $0x3, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rdi
callq 0x12e60
movzbl %al, %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
callq 0x12e60
movb %al, %cl
movq -0x68(%rbp), %rax
movb %cl, (%rax)
movq -0x10(%rbp), %rdi
callq 0x12e60
movb %al, %cl
movq -0x68(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x10(%rbp), %rdi
callq 0x12e60
movb %al, %cl
movq -0x68(%rbp), %rax
movb %cl, 0x2(%rax)
movq -0x68(%rbp), %rax
movzbl 0x2(%rax), %eax
orl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x12530
cmpl $0x0, %eax
je 0x1c182
leaq 0x4e66(%rip), %rdi      # 0x20fcf
callq 0x2680
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0x1c601
movq -0x68(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x8, %eax
je 0x1c1ae
leaq 0x4e43(%rip), %rdi      # 0x20fd8
callq 0x2680
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0x1c601
jmp 0x1c1b0
cmpl $0x0, -0x38(%rbp)
jne 0x1c0bb
movl -0x2c(%rbp), %edx
andl $0x10, %edx
movl $0x3, %ecx
movl $0x4, %eax
cmpl $0x0, %edx
cmovnel %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x1c5f9
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x1c5e9
movslq -0x6c(%rbp), %rax
leaq (%rax,%rax,2), %rax
leaq -0x60(%rbp,%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x28(%rbp), %rax
movl -0x34(%rbp), %ecx
movl -0x14(%rbp), %edx
imull %edx, %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x78(%rbp), %rax
movzbl 0x1(%rax), %eax
movl %eax, -0xa8(%rbp)
testl %eax, %eax
je 0x1c27d
jmp 0x1c23b
movl -0xa8(%rbp), %eax
subl $0x1, %eax
je 0x1c2de
jmp 0x1c24c
movl -0xa8(%rbp), %eax
subl $0x2, %eax
je 0x1c3e6
jmp 0x1c25d
leaq 0x4d74(%rip), %rdi      # 0x20fd8
callq 0x2680
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0x1c601
movl $0x0, -0x84(%rbp)
movl -0x84(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x1c2d9
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rax
movzbl 0x2(%rax), %esi
movq -0x80(%rbp), %rdx
callq 0x1c610
cmpq $0x0, %rax
jne 0x1c2ba
movq $0x0, -0x8(%rbp)
jmp 0x1c601
jmp 0x1c2bc
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
movq -0x80(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x80(%rbp)
jmp 0x1c287
jmp 0x1c5d9
movl -0x14(%rbp), %eax
movl %eax, -0x88(%rbp)
cmpl $0x0, -0x88(%rbp)
jle 0x1c3e1
movq -0x10(%rbp), %rdi
callq 0x12e60
movb %al, -0x8d(%rbp)
movq -0x10(%rbp), %rdi
callq 0x12530
cmpl $0x0, %eax
je 0x1c331
leaq 0x4cb7(%rip), %rdi      # 0x20fcf
callq 0x2680
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0x1c601
movzbl -0x8d(%rbp), %eax
cmpl -0x88(%rbp), %eax
jle 0x1c34c
movl -0x88(%rbp), %eax
movb %al, -0x8d(%rbp)
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rax
movzbl 0x2(%rax), %esi
leaq -0x91(%rbp), %rdx
callq 0x1c610
cmpq $0x0, %rax
jne 0x1c377
movq $0x0, -0x8(%rbp)
jmp 0x1c601
movl $0x0, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
movzbl -0x8d(%rbp), %ecx
cmpl %ecx, %eax
jge 0x1c3c7
movq -0x78(%rbp), %rax
movzbl 0x2(%rax), %edi
movq -0x80(%rbp), %rsi
leaq -0x91(%rbp), %rdx
callq 0x1c6b0
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
movq -0x80(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x80(%rbp)
jmp 0x1c381
movzbl -0x8d(%rbp), %ecx
movl -0x88(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x88(%rbp)
jmp 0x1c2e7
jmp 0x1c5d9
movl -0x14(%rbp), %eax
movl %eax, -0x98(%rbp)
cmpl $0x0, -0x98(%rbp)
jle 0x1c5d7
movq -0x10(%rbp), %rdi
callq 0x12e60
movzbl %al, %eax
movl %eax, -0x9c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x12530
cmpl $0x0, %eax
je 0x1c43c
leaq 0x4bac(%rip), %rdi      # 0x20fcf
callq 0x2680
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0x1c601
cmpl $0x80, -0x9c(%rbp)
jl 0x1c523
cmpl $0x80, -0x9c(%rbp)
jne 0x1c469
movq -0x10(%rbp), %rdi
callq 0x12fa0
movl %eax, -0x9c(%rbp)
jmp 0x1c478
movl -0x9c(%rbp), %eax
subl $0x7f, %eax
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
cmpl -0x98(%rbp), %eax
jle 0x1c4a6
leaq 0x4b42(%rip), %rdi      # 0x20fcf
callq 0x2680
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0x1c601
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rax
movzbl 0x2(%rax), %esi
leaq -0xa4(%rbp), %rdx
callq 0x1c610
cmpq $0x0, %rax
jne 0x1c4d1
movq $0x0, -0x8(%rbp)
jmp 0x1c601
movl $0x0, -0xa0(%rbp)
movl -0xa0(%rbp), %eax
cmpl -0x9c(%rbp), %eax
jge 0x1c51e
movq -0x78(%rbp), %rax
movzbl 0x2(%rax), %edi
movq -0x80(%rbp), %rsi
leaq -0xa4(%rbp), %rdx
callq 0x1c6b0
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
movq -0x80(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x80(%rbp)
jmp 0x1c4db
jmp 0x1c5be
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
cmpl -0x98(%rbp), %eax
jle 0x1c560
leaq 0x4a88(%rip), %rdi      # 0x20fcf
callq 0x2680
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0x1c601
movl $0x0, -0xa0(%rbp)
movl -0xa0(%rbp), %eax
cmpl -0x9c(%rbp), %eax
jge 0x1c5bc
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rax
movzbl 0x2(%rax), %esi
movq -0x80(%rbp), %rdx
callq 0x1c610
cmpq $0x0, %rax
jne 0x1c59d
movq $0x0, -0x8(%rbp)
jmp 0x1c601
jmp 0x1c59f
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
movq -0x80(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x80(%rbp)
jmp 0x1c56a
jmp 0x1c5be
movl -0x9c(%rbp), %ecx
movl -0x98(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x98(%rbp)
jmp 0x1c3ef
jmp 0x1c5d9
jmp 0x1c5db
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x1c1f0
jmp 0x1c5eb
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1c1dd
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xb0, %rsp
popq %rbp
retq
nop