// File: /workspace/github_c_makefile_star2_O1/zhiyb[P]png2tlg/./stb_image.h
// Function: stbi__convert_format(unsigned char*, int, int, unsigned int, unsigned int)
static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int req_comp, unsigned int x, unsigned int y)
{
   int i,j;
   unsigned char *good;

   if (req_comp == img_n) return data;
   STBI_ASSERT(req_comp >= 1 && req_comp <= 4);

   good = (unsigned char *) stbi__malloc_mad3(req_comp, x, y, 0);
   if (good == NULL) {
      STBI_FREE(data);
      return stbi__errpuc("outofmem", "Out of memory");
   }

   for (j=0; j < (int) y; ++j) {
      unsigned char *src  = data + j * x * img_n   ;
      unsigned char *dest = good + j * x * req_comp;

      #define STBI__COMBO(a,b)  ((a)*8+(b))
      #define STBI__CASE(a,b)   case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b)
      // convert source image with img_n components to one with req_comp components;
      // avoid switch per pixel, so use switch per scanline and massive macros
      switch (STBI__COMBO(img_n, req_comp)) {
         STBI__CASE(1,2) { dest[0]=src[0]; dest[1]=255;                                     } break;
         STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0];                                  } break;
         STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=255;                     } break;
         STBI__CASE(2,1) { dest[0]=src[0];                                                  } break;
         STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0];                                  } break;
         STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1];                  } break;
         STBI__CASE(3,4) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];dest[3]=255;        } break;
         STBI__CASE(3,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]);                   } break;
         STBI__CASE(3,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = 255;    } break;
         STBI__CASE(4,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]);                   } break;
         STBI__CASE(4,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = src[3]; } break;
         STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];                    } break;
         default: STBI_ASSERT(0);
      }
      #undef STBI__CASE
   }

   STBI_FREE(data);
   return good;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
movq %rsi, 0x8(%rsp)
cmpl %esi, %edx
je 0x119ef
movl %edx, %r15d
leal -0x1(%r15), %eax
cmpl $0x4, %eax
jae 0x11a01
movl %r8d, %ebp
movl %ecx, %r14d
movl %r15d, %edi
movl %ecx, %esi
movl %r8d, %edx
xorl %ecx, %ecx
callq 0xf848
testq %rax, %rax
je 0x119d7
movq %rax, %r12
testl %ebp, %ebp
jle 0x119ca
movq 0x8(%rsp), %rax
leal (%r15,%rax,8), %ecx
cmpl $0x23, %ecx
ja 0x11a20
movabsq $0xe161a1c00, %rax      # imm = 0xE161A1C00
btq %rcx, %rax
jae 0x11a20
cmpl $0x2, %ebp
movl $0x1, %eax
cmovgel %ebp, %eax
movq %rax, 0x30(%rsp)
leal -0x1(%r14), %eax
movl %eax, 0x4(%rsp)
movl %r14d, %eax
imull %r15d, %eax
movl %eax, 0x14(%rsp)
movl %r14d, %eax
imull 0x8(%rsp), %eax
movl %eax, 0x10(%rsp)
leaq 0x3(%r12), %rax
movq %rax, 0x28(%rsp)
leaq 0x2(%r12), %rax
movq %rax, 0x18(%rsp)
xorl %r10d, %r10d
addl $-0xa, %ecx
xorl %ebp, %ebp
xorl %r9d, %r9d
movq %rcx, 0x20(%rsp)
leaq 0x5b6e(%rip), %r13      # 0x1722c
movl %r9d, %edx
imull %r14d, %edx
movl %edx, %r11d
imull 0x8(%rsp), %r11d
addq %rbx, %r11
imull %r15d, %edx
addq %r12, %rdx
cmpl $0x18, %ecx
ja 0x11983
movl %ebp, %esi
leaq (%r12,%rsi), %rcx
movl %r10d, %r8d
addq %rbx, %r8
movq 0x28(%rsp), %rax
leaq (%rax,%rsi), %rdi
movq 0x20(%rsp), %rax
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
cmpl $0x0, 0x4(%rsp)
js 0x119ae
xorl %edx, %edx
movl %r14d, %eax
movb (%r8,%rdx), %sil
movb %sil, (%rcx,%rdx,2)
movb $-0x1, 0x1(%rcx,%rdx,2)
decl %eax
incq %rdx
testl %eax, %eax
jg 0x11715
jmp 0x119ae
cmpl $0x0, 0x4(%rsp)
js 0x119ae
xorl %edx, %edx
movl %r14d, %esi
movzbl (%r8,%rdx,2), %edi
movzbl 0x1(%r8,%rdx,2), %r11d
movzbl 0x2(%r8,%rdx,2), %eax
imull $0x4d, %edi, %edi
imull $0x96, %r11d, %r11d
addl %edi, %r11d
leal (%rax,%rax,8), %edi
leal (%rdi,%rdi,2), %edi
addl %eax, %eax
addl %edi, %eax
addl %r11d, %eax
movb %ah, (%rcx,%rdx)
movb 0x3(%r8,%rdx,2), %al
movb %al, 0x1(%rcx,%rdx)
decl %esi
addq $0x2, %rdx
testl %esi, %esi
jg 0x11740
jmp 0x119ae
cmpl $0x0, 0x4(%rsp)
js 0x119ae
addq 0x18(%rsp), %rsi
movl %r14d, %ecx
movb (%r11), %al
movb %al, (%rsi)
movb %al, -0x1(%rsi)
movb %al, -0x2(%rsi)
addq $0x2, %r11
decl %ecx
addq $0x3, %rsi
testl %ecx, %ecx
jg 0x11799
jmp 0x119ae
cmpl $0x0, 0x4(%rsp)
js 0x119ae
xorl %ecx, %ecx
movl %r14d, %edx
movb (%r8,%rcx), %al
movb %al, -0x1(%rdi,%rcx,2)
movb %al, -0x2(%rdi,%rcx,2)
movb %al, -0x3(%rdi,%rcx,2)
movb 0x1(%r8,%rcx), %al
movb %al, (%rdi,%rcx,2)
decl %edx
addq $0x2, %rcx
testl %edx, %edx
jg 0x117c7
jmp 0x119ae
cmpl $0x0, 0x4(%rsp)
js 0x119ae
xorl %edx, %edx
movl %r14d, %eax
movb (%r8,%rdx,2), %sil
movb %sil, (%rcx,%rdx)
decl %eax
incq %rdx
testl %eax, %eax
jg 0x117fe
jmp 0x119ae
cmpl $0x0, 0x4(%rsp)
js 0x119ae
xorl %ecx, %ecx
movl %r14d, %edx
movb (%r8,%rcx), %al
movb %al, -0x1(%rdi,%rcx,4)
movb %al, -0x2(%rdi,%rcx,4)
movb %al, -0x3(%rdi,%rcx,4)
movb $-0x1, (%rdi,%rcx,4)
decl %edx
incq %rcx
testl %edx, %edx
jg 0x11824
jmp 0x119ae
cmpl $0x0, 0x4(%rsp)
js 0x119ae
addq 0x18(%rsp), %rsi
movl %r14d, %ecx
movb (%r11), %al
movb %al, (%rsi)
movb %al, -0x1(%rsi)
movb %al, -0x2(%rsi)
incq %r11
decl %ecx
addq $0x3, %rsi
testl %ecx, %ecx
jg 0x11859
jmp 0x119ae
movl %r14d, %ecx
cmpl $0x0, 0x4(%rsp)
js 0x119ae
movzbl (%r11), %esi
movzbl 0x1(%r11), %edi
movzbl 0x2(%r11), %eax
imull $0x4d, %esi, %esi
imull $0x96, %edi, %edi
addl %esi, %edi
leal (%rax,%rax,8), %esi
leal (%rsi,%rsi,2), %esi
addl %eax, %eax
addl %esi, %eax
addl %edi, %eax
movb %ah, (%rdx)
addq $0x3, %r11
incq %rdx
decl %ecx
testl %ecx, %ecx
jg 0x11884
jmp 0x119ae
movl %r14d, %ecx
cmpl $0x0, 0x4(%rsp)
js 0x119ae
movzbl (%r11), %esi
movzbl 0x1(%r11), %edi
movzbl 0x2(%r11), %eax
imull $0x4d, %esi, %esi
imull $0x96, %edi, %edi
addl %esi, %edi
leal (%rax,%rax,8), %esi
leal (%rsi,%rsi,2), %esi
addl %eax, %eax
addl %esi, %eax
addl %edi, %eax
movb %ah, (%rdx)
movb $-0x1, 0x1(%rdx)
addq $0x3, %r11
addq $0x2, %rdx
decl %ecx
testl %ecx, %ecx
jg 0x118cb
jmp 0x119ae
cmpl $0x0, 0x4(%rsp)
js 0x119ae
xorl %edx, %edx
movl %r14d, %esi
movzbl (%r8,%rdx,4), %edi
movzbl 0x1(%r8,%rdx,4), %r11d
movzbl 0x2(%r8,%rdx,4), %eax
imull $0x4d, %edi, %edi
imull $0x96, %r11d, %r11d
addl %edi, %r11d
leal (%rax,%rax,8), %edi
leal (%rdi,%rdi,2), %edi
addl %eax, %eax
addl %edi, %eax
addl %r11d, %eax
movb %ah, (%rcx,%rdx)
decl %esi
incq %rdx
testl %esi, %esi
jg 0x11919
jmp 0x119ae
movl %r14d, %ecx
cmpl $0x0, 0x4(%rsp)
js 0x119ae
movb (%r11), %al
movb %al, (%rdx)
movb 0x1(%r11), %al
movb %al, 0x1(%rdx)
movb 0x2(%r11), %al
movb %al, 0x2(%rdx)
movb $-0x1, 0x3(%rdx)
addq $0x3, %r11
addq $0x4, %rdx
decl %ecx
testl %ecx, %ecx
jg 0x1195c
jmp 0x119ae
movl %r14d, %ecx
cmpl $0x0, 0x4(%rsp)
js 0x119ae
movb (%r11), %al
movb %al, (%rdx)
movb 0x1(%r11), %al
movb %al, 0x1(%rdx)
movb 0x2(%r11), %al
movb %al, 0x2(%rdx)
addq $0x4, %r11
addq $0x3, %rdx
decl %ecx
testl %ecx, %ecx
jg 0x1198d
incq %r9
addl 0x14(%rsp), %ebp
addl 0x10(%rsp), %r10d
cmpq 0x30(%rsp), %r9
movq 0x20(%rsp), %rcx
jne 0x116be
movq %rbx, %rdi
callq 0x21e0
movq %r12, %rbx
jmp 0x119ef
movq %rbx, %rdi
callq 0x21e0
leaq 0x6113(%rip), %rax      # 0x17af9
movq %rax, 0xa83b(%rip)      # 0x1c228
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6539(%rip), %rdi      # 0x17f41
leaq 0x5f77(%rip), %rsi      # 0x17986
leaq 0x654a(%rip), %rcx      # 0x17f60
movl $0x633, %edx            # imm = 0x633
callq 0x2100
leaq 0x696a(%rip), %rdi      # 0x18391
leaq 0x5f58(%rip), %rsi      # 0x17986
leaq 0x652b(%rip), %rcx      # 0x17f60
movl $0x650, %edx            # imm = 0x650
callq 0x2100