// File: /workspace/github_c_makefile_star2_O3/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 %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq 0xb8(%rdi), %rdx
movq 0xc0(%rdi), %rax
cmpq %rax, %rdx
jae 0x13804
leaq 0x1(%rdx), %rcx
movq %rcx, 0xb8(%rbx)
movb (%rdx), %dl
jmp 0x13850
cmpl $0x0, 0x30(%rbx)
je 0x139cc
movq 0x28(%rbx), %rdi
leaq 0x38(%rbx), %r15
movl 0x34(%rbx), %edx
movq %r15, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x1382d
cltq
addq %r15, %rax
movb (%r15), %dl
jmp 0x1383e
movl $0x0, 0x30(%rbx)
leaq 0x39(%rbx), %rax
movb $0x0, 0x38(%rbx)
xorl %edx, %edx
movq %rax, 0xc0(%rbx)
leaq 0x39(%rbx), %rcx
movq %rcx, 0xb8(%rbx)
cmpb $0x42, %dl
jne 0x139cc
cmpq %rax, %rcx
jae 0x1386d
leaq 0x1(%rcx), %rax
movq %rax, 0xb8(%rbx)
movb (%rcx), %al
jmp 0x138ba
cmpl $0x0, 0x30(%rbx)
je 0x139cc
movq 0x28(%rbx), %rdi
leaq 0x38(%rbx), %r15
movl 0x34(%rbx), %edx
movq %r15, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x13897
movslq %eax, %rcx
addq %r15, %rcx
movb (%r15), %al
jmp 0x138a8
movl $0x0, 0x30(%rbx)
leaq 0x39(%rbx), %rcx
movb $0x0, 0x38(%rbx)
xorl %eax, %eax
movq %rcx, 0xc0(%rbx)
leaq 0x39(%rbx), %rcx
movq %rcx, 0xb8(%rbx)
cmpb $0x4d, %al
jne 0x139cc
movq %rbx, %rdi
callq 0x136e6
movq %rbx, %rdi
callq 0x136e6
movq %rbx, %rdi
callq 0x136e6
movq %rbx, %rdi
callq 0x136e6
movq %rbx, %rdi
callq 0x136e6
movl %eax, %ebp
movq %rbx, %rdi
callq 0x136e6
shll $0x10, %eax
orl %ebp, %eax
movl %eax, 0x4(%r14)
movq %rbx, %rdi
callq 0x136e6
movl %eax, %r15d
movq %rbx, %rdi
callq 0x136e6
movl %eax, %ebp
shll $0x10, %ebp
orl %r15d, %ebp
movl %ebp, 0x8(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0xc(%r14)
cmpl $0x37, %ebp
jle 0x139ef
cmpl $0x38, %ebp
je 0x13940
cmpl $0x6c, %ebp
je 0x13940
cmpl $0x7c, %ebp
jne 0x139fd
movq %rbx, %rdi
callq 0x136e6
movl %eax, %r15d
movq %rbx, %rdi
callq 0x136e6
shll $0x10, %eax
orl %r15d, %eax
movl %eax, (%rbx)
movq %rbx, %rdi
callq 0x136e6
movl %eax, %r15d
movq %rbx, %rdi
callq 0x136e6
shll $0x10, %eax
orl %r15d, %eax
movl %eax, 0x4(%rbx)
movq %rbx, %rdi
callq 0x136e6
cmpl $0x1, %eax
jne 0x13bb9
movq %rbx, %rdi
callq 0x136e6
movl %eax, (%r14)
movl $0x1, %r15d
cmpl $0xc, %ebp
je 0x139dd
movq %rbx, %rdi
callq 0x136e6
movl %eax, %r12d
movq %rbx, %rdi
callq 0x136e6
movl %eax, %r13d
shll $0x10, %r13d
leal (%r12,%r13), %eax
decl %eax
cmpl $0x1, %eax
ja 0x13a1d
leaq 0x5732(%rip), %rax      # 0x190fc
jmp 0x139d3
leaq 0x570d(%rip), %rax      # 0x190e0
movq %rax, 0x981e(%rip)      # 0x1d1f8
xorl %r15d, %r15d
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0xc, %ebp
je 0x13a06
cmpl $0x28, %ebp
je 0x13940
leaq 0x56e4(%rip), %rax      # 0x190e8
jmp 0x139d3
movq %rbx, %rdi
callq 0x136e6
movl %eax, (%rbx)
movq %rbx, %rdi
callq 0x136e6
jmp 0x13974
movq %rbx, %rdi
callq 0x136e6
movq %rbx, %rdi
callq 0x136e6
movq %rbx, %rdi
callq 0x136e6
movq %rbx, %rdi
callq 0x136e6
movq %rbx, %rdi
callq 0x136e6
movq %rbx, %rdi
callq 0x136e6
movq %rbx, %rdi
callq 0x136e6
movq %rbx, %rdi
callq 0x136e6
movq %rbx, %rdi
callq 0x136e6
movq %rbx, %rdi
callq 0x136e6
cmpl $0x6b, %ebp
jg 0x13ae9
cmpl $0x28, %ebp
je 0x13aa0
cmpl $0x38, %ebp
jne 0x13bb9
movq %rbx, %rdi
callq 0x136c5
movq %rbx, %rdi
callq 0x136c5
movq %rbx, %rdi
callq 0x136c5
movq %rbx, %rdi
callq 0x136c5
movl (%r14), %eax
cmpl $0x20, %eax
je 0x13ab1
cmpl $0x10, %eax
jne 0x139dd
orl %r12d, %r13d
cmpl $0x3, %r13d
je 0x13b81
testl %r13d, %r13d
jne 0x13bb9
cmpl $0x20, %eax
jne 0x13bc5
movaps 0x4749(%rip), %xmm0     # 0x18220
movups %xmm0, 0xc(%r14)
movl $0x0, 0x1c(%r14)
jmp 0x139dd
cmpl $0x6c, %ebp
je 0x13af7
cmpl $0x7c, %ebp
jne 0x13bb9
movq %rbx, %rdi
callq 0x136c5
movl %eax, 0xc(%r14)
movq %rbx, %rdi
callq 0x136c5
movl %eax, 0x10(%r14)
movq %rbx, %rdi
callq 0x136c5
movl %eax, 0x14(%r14)
movq %rbx, %rdi
callq 0x136c5
movl %eax, 0x18(%r14)
movq %rbx, %rdi
callq 0x136c5
movl $0xc, %r14d
movq %rbx, %rdi
callq 0x136e6
movq %rbx, %rdi
callq 0x136e6
decl %r14d
jne 0x13b35
cmpl $0x6c, %ebp
je 0x139dd
cmpl $0x7c, %ebp
jne 0x139da
movq %rbx, %rdi
callq 0x136c5
movq %rbx, %rdi
callq 0x136c5
movq %rbx, %rdi
callq 0x136c5
movq %rbx, %rdi
callq 0x136c5
jmp 0x139dd
movq %rbx, %rdi
callq 0x136c5
movl %eax, 0xc(%r14)
movq %rbx, %rdi
callq 0x136c5
movl %eax, 0x10(%r14)
movq %rbx, %rdi
callq 0x136c5
movl %eax, 0x14(%r14)
movl 0x10(%r14), %ecx
movl 0xc(%r14), %edx
xorl %ecx, %edx
xorl %eax, %ecx
orl %edx, %ecx
jne 0x139dd
leaq 0x5534(%rip), %rax      # 0x190f4
jmp 0x139d3
movabsq $0x3e000007c00, %rax    # imm = 0x3E000007C00
movq %rax, 0xc(%r14)
movl $0x1f, 0x14(%r14)
jmp 0x139dd