// File: /workspace/github_c_makefile_star2_O2/zhiyb[P]png2tlg/./stb_image.h
// Function: stbi__bmp_parse_header(stbi__context*, stbi__bmp_data*)
static void *stbi__bmp_parse_header(stbi__context *s, stbi__bmp_data *info)
{
   int hsz;
   if (stbi__get8(s) != 'B' || stbi__get8(s) != 'M') return stbi__errpuc("not BMP", "Corrupt BMP");
   stbi__get32le(s); // discard filesize
   stbi__get16le(s); // discard reserved
   stbi__get16le(s); // discard reserved
   info->offset = stbi__get32le(s);
   info->hsz = hsz = stbi__get32le(s);
   info->mr = info->mg = info->mb = info->ma = 0;

   if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108 && hsz != 124) return stbi__errpuc("unknown BMP", "BMP type not supported: unknown");
   if (hsz == 12) {
      s->img_x = stbi__get16le(s);
      s->img_y = stbi__get16le(s);
   } else {
      s->img_x = stbi__get32le(s);
      s->img_y = stbi__get32le(s);
   }
   if (stbi__get16le(s) != 1) return stbi__errpuc("bad BMP", "bad BMP");
   info->bpp = stbi__get16le(s);
   if (hsz != 12) {
      int compress = stbi__get32le(s);
      if (compress == 1 || compress == 2) return stbi__errpuc("BMP RLE", "BMP type not supported: RLE");
      stbi__get32le(s); // discard sizeof
      stbi__get32le(s); // discard hres
      stbi__get32le(s); // discard vres
      stbi__get32le(s); // discard colorsused
      stbi__get32le(s); // discard max important
      if (hsz == 40 || hsz == 56) {
         if (hsz == 56) {
            stbi__get32le(s);
            stbi__get32le(s);
            stbi__get32le(s);
            stbi__get32le(s);
         }
         if (info->bpp == 16 || info->bpp == 32) {
            if (compress == 0) {
               if (info->bpp == 32) {
                  info->mr = 0xffu << 16;
                  info->mg = 0xffu <<  8;
                  info->mb = 0xffu <<  0;
                  info->ma = 0xffu << 24;
                  info->all_a = 0; // if all_a is 0 at end, then we loaded alpha channel but it was all 0
               } else {
                  info->mr = 31u << 10;
                  info->mg = 31u <<  5;
                  info->mb = 31u <<  0;
               }
            } else if (compress == 3) {
               info->mr = stbi__get32le(s);
               info->mg = stbi__get32le(s);
               info->mb = stbi__get32le(s);
               // not documented, but generated by photoshop and handled by mspaint
               if (info->mr == info->mg && info->mg == info->mb) {
                  // ?!?!?
                  return stbi__errpuc("bad BMP", "bad BMP");
               }
            } else
               return stbi__errpuc("bad BMP", "bad BMP");
         }
      } else {
         int i;
         if (hsz != 108 && hsz != 124)
            return stbi__errpuc("bad BMP", "bad BMP");
         info->mr = stbi__get32le(s);
         info->mg = stbi__get32le(s);
         info->mb = stbi__get32le(s);
         info->ma = stbi__get32le(s);
         stbi__get32le(s); // discard color space
         for (i=0; i < 12; ++i)
            stbi__get32le(s); // discard color space parameters
         if (hsz == 124) {
            stbi__get32le(s); // discard rendering intent
            stbi__get32le(s); // discard offset of profile data
            stbi__get32le(s); // discard size of profile data
            stbi__get32le(s); // discard reserved
         }
      }
   }
   return (void *) 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
callq 0xae91
cmpb $0x42, %al
jne 0xdb96
movq %rbx, %rdi
callq 0xae91
cmpb $0x4d, %al
jne 0xdb96
movq %rbx, %rdi
callq 0xda76
movq %rbx, %rdi
callq 0xda97
movq %rbx, %rdi
callq 0xda97
movq %rbx, %rdi
callq 0xda76
movl %eax, 0x4(%r14)
movq %rbx, %rdi
callq 0xda76
movl %eax, %ebp
movl %eax, 0x8(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0xc(%r14)
cmpl $0xc, %eax
je 0xdbbc
cmpl $0x28, %ebp
je 0xdb3e
cmpl $0x38, %ebp
je 0xdb3e
cmpl $0x6c, %ebp
je 0xdb3e
cmpl $0x7c, %ebp
jne 0xdbb3
movq %rbx, %rdi
callq 0xda76
movl %eax, (%rbx)
movq %rbx, %rdi
callq 0xda76
movl %eax, 0x4(%rbx)
movq %rbx, %rdi
callq 0xda97
cmpl $0x1, %eax
jne 0xdd2e
movq %rbx, %rdi
callq 0xda97
movl %eax, (%r14)
pushq $0x1
popq %r15
cmpl $0xc, %ebp
je 0xdba7
movq %rbx, %rdi
callq 0xda76
movl %eax, %r12d
leal -0x1(%r12), %eax
cmpl $0x1, %eax
ja 0xdbd0
leaq 0x3498(%rip), %rax      # 0x1102c
jmp 0xdb9d
leaq 0x3473(%rip), %rax      # 0x11010
movq %rax, 0x7674(%rip)      # 0x15218
xorl %r15d, %r15d
movq %r15, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x345e(%rip), %rax      # 0x11018
jmp 0xdb9d
movq %rbx, %rdi
callq 0xda97
movl %eax, (%rbx)
movq %rbx, %rdi
callq 0xda97
jmp 0xdb50
movq %rbx, %rdi
callq 0xda76
movq %rbx, %rdi
callq 0xda76
movq %rbx, %rdi
callq 0xda76
movq %rbx, %rdi
callq 0xda76
movq %rbx, %rdi
callq 0xda76
cmpl $0x28, %ebp
je 0xdc30
cmpl $0x7c, %ebp
je 0xdc73
cmpl $0x6c, %ebp
je 0xdc73
cmpl $0x38, %ebp
jne 0xdd2e
movq %rbx, %rdi
callq 0xda76
movq %rbx, %rdi
callq 0xda76
movq %rbx, %rdi
callq 0xda76
movq %rbx, %rdi
callq 0xda76
movl (%r14), %eax
cmpl $0x20, %eax
je 0xdc41
cmpl $0x10, %eax
jne 0xdba7
cmpl $0x3, %r12d
je 0xdcf6
testl %r12d, %r12d
jne 0xdd2e
cmpl $0x20, %eax
jne 0xdd3a
movaps 0x24fc(%rip), %xmm0     # 0x10160
movups %xmm0, 0xc(%r14)
andl $0x0, 0x1c(%r14)
jmp 0xdba7
movq %rbx, %rdi
callq 0xda76
movl %eax, 0xc(%r14)
movq %rbx, %rdi
callq 0xda76
movl %eax, 0x10(%r14)
movq %rbx, %rdi
callq 0xda76
movl %eax, 0x14(%r14)
movq %rbx, %rdi
callq 0xda76
movl %eax, 0x18(%r14)
movq %rbx, %rdi
callq 0xda76
pushq $0xc
popq %r14
subl $0x1, %r14d
jb 0xdcbf
movq %rbx, %rdi
callq 0xda76
jmp 0xdcaf
cmpl $0x6c, %ebp
je 0xdba7
cmpl $0x7c, %ebp
jne 0xdba4
movq %rbx, %rdi
callq 0xda76
movq %rbx, %rdi
callq 0xda76
movq %rbx, %rdi
callq 0xda76
movq %rbx, %rdi
callq 0xda76
jmp 0xdba7
movq %rbx, %rdi
callq 0xda76
movl %eax, 0xc(%r14)
movq %rbx, %rdi
callq 0xda76
movl %eax, 0x10(%r14)
movq %rbx, %rdi
callq 0xda76
movl %eax, 0x14(%r14)
movl 0x10(%r14), %ecx
movl 0xc(%r14), %edx
xorl %ecx, %edx
xorl %eax, %ecx
orl %edx, %ecx
jne 0xdba7
leaq 0x32ef(%rip), %rax      # 0x11024
jmp 0xdb9d
movabsq $0x3e000007c00, %rax    # imm = 0x3E000007C00
movq %rax, 0xc(%r14)
movl $0x1f, 0x14(%r14)
jmp 0xdba7