// File: /workspace/github_cpp_makefile_star2_O2/rapirent[P]JPEG/./bitmap_image.hpp
// Function: bitmap_image::load_bitmap()
void load_bitmap()
   {
      std::ifstream stream(file_name_.c_str(),std::ios::binary);

      if (!stream)
      {
         std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - file " << file_name_ << " not found!" << std::endl;
         return;
      }

      width_  = 0;
      height_ = 0;

      bitmap_file_header bfh;
      bitmap_information_header bih;

      bfh.clear();
      bih.clear();

      read_bfh(stream,bfh);
      read_bih(stream,bih);

      if (bfh.type != 19778)
      {
         bfh.clear();
         bih.clear();

         stream.close();

         std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - Invalid type value " << bfh.type << " expected 19778." << std::endl;
         return;
      }

      if (bih.bit_count != 24)
      {
         bfh.clear();
         bih.clear();

         stream.close();

         std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - Invalid bit depth " << bih.bit_count << " expected 24." << std::endl;

         return;
      }

      if (bih.size != bih.struct_size())
      {
         bfh.clear();
         bih.clear();

         stream.close();

         std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - Invalid BIH size " << bih.size << " expected " << bih.struct_size() << std::endl;

         return;
      }

      width_  = bih.width;
      height_ = bih.height;

      bytes_per_pixel_ = bih.bit_count >> 3;

      unsigned int padding = (4 - ((3 * width_) % 4)) % 4;
      char padding_data[4] = {0,0,0,0};

      std::size_t bitmap_file_size = file_size(file_name_);

      std::size_t bitmap_logical_size = (height_ * width_ * bytes_per_pixel_) +
                                        (height_ * padding)                   +
                                         bih.struct_size()                    +
                                         bfh.struct_size()                    ;

      if (bitmap_file_size != bitmap_logical_size)
      {
         bfh.clear();
         bih.clear();

         stream.close();

         std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - Mismatch between logical and physical sizes of bitmap. " <<
                      "Logical: "  << bitmap_logical_size << " " <<
                      "Physical: " << bitmap_file_size    << std::endl;

         return;
      }

      create_bitmap();

      for (unsigned int i = 0; i < height_; ++i)
      {
         unsigned char* data_ptr = row(height_ - i - 1); // read in inverted row order

         stream.read(reinterpret_cast<char*>(data_ptr), sizeof(char) * bytes_per_pixel_ * width_);
         stream.read(padding_data,padding);
      }
   }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x248, %rsp            # imm = 0x248
movq %rdi, %rbx
movq (%rdi), %rsi
leaq 0x40(%rsp), %r14
pushq $0x4
popq %rdx
movq %r14, %rdi
callq 0x5270
movq (%r14), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x60(%rsp,%rax)
je 0x63bd
movq 0x3c66(%rip), %rdi      # 0x9ff0
leaq 0x15cf(%rip), %rsi      # 0x7960
callq 0x5150
movq %rax, %rdi
movq %rbx, %rsi
callq 0x5140
leaq 0x15f0(%rip), %rsi      # 0x7998
movq %rax, %rdi
callq 0x5150
movq %rax, %rdi
callq 0x50c0
jmp 0x655b
andq $0x0, 0x20(%rbx)
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, (%rsp)
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
leaq 0x40(%rsp), %rsi
movq %rbx, %rdi
callq 0x6674
leaq 0x40(%rsp), %rsi
movq %rsp, %rdx
movq %rbx, %rdi
callq 0x66e2
cmpw $0x4d42, 0x30(%rsp)     # imm = 0x4D42
jne 0x64b9
cmpw $0x18, 0xe(%rsp)
jne 0x6503
cmpl $0x28, (%rsp)
jne 0x6577
movq 0x4(%rsp), %r12
movq %r12, 0x20(%rbx)
movl $0x3, 0x2c(%rbx)
andl $0x0, 0x2c(%rsp)
movq %rbx, %rdi
movq %rbx, %rsi
callq 0x67aa
movq %rax, %r14
andl $0x3, %r12d
movl 0x2c(%rbx), %r15d
imull 0x20(%rbx), %r15d
addl %r12d, %r15d
imull 0x24(%rbx), %r15d
addl $0x36, %r15d
cmpq %r15, %rax
jne 0x65d2
movq %rbx, %rdi
callq 0x6820
movl %r12d, %r14d
xorl %ebp, %ebp
pushq $-0x1
popq %r13
leaq 0x40(%rsp), %r15
leaq 0x2c(%rsp), %r12
movl 0x24(%rbx), %esi
cmpl %esi, %ebp
jae 0x655b
addl %r13d, %esi
imull 0x28(%rbx), %esi
addq 0x38(%rbx), %rsi
movl 0x20(%rbx), %edx
movl 0x2c(%rbx), %eax
imulq %rax, %rdx
movq %r15, %rdi
callq 0x51c0
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x51c0
incl %ebp
decl %r13d
jmp 0x647c
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, (%rsp)
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
leaq 0x40(%rsp), %rdi
callq 0x5040
movq 0x3b0f(%rip), %rdi      # 0x9ff0
leaq 0x14bc(%rip), %rsi      # 0x79a4
callq 0x5150
movzwl 0x30(%rsp), %esi
movq %rax, %rdi
callq 0x5230
leaq 0x14e9(%rip), %rsi      # 0x79ea
jmp 0x654b
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, (%rsp)
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
leaq 0x40(%rsp), %rdi
callq 0x5040
movq 0x3ac5(%rip), %rdi      # 0x9ff0
leaq 0x14c9(%rip), %rsi      # 0x79fb
callq 0x5150
movzwl 0xe(%rsp), %esi
movq %rax, %rdi
callq 0x5230
leaq 0x14f5(%rip), %rsi      # 0x7a40
movq %rax, %rdi
callq 0x5150
movq %rax, %rdi
callq 0x50c0
leaq 0x40(%rsp), %rdi
callq 0x5050
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, (%rsp)
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
leaq 0x40(%rsp), %rdi
callq 0x5040
movq 0x3a51(%rip), %rdi      # 0x9ff0
leaq 0x14a8(%rip), %rsi      # 0x7a4e
callq 0x5150
movl (%rsp), %esi
movq %rax, %rdi
callq 0x5100
leaq 0x14d5(%rip), %rsi      # 0x7a92
movq %rax, %rdi
callq 0x5150
pushq $0x28
popq %rsi
movq %rax, %rdi
callq 0x5100
jmp 0x6553
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, (%rsp)
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
leaq 0x40(%rsp), %rdi
callq 0x5040
movq 0x39f6(%rip), %rdi      # 0x9ff0
leaq 0x149c(%rip), %rsi      # 0x7a9d
callq 0x5150
leaq 0x14fa(%rip), %rsi      # 0x7b07
movq %rax, %rdi
callq 0x5150
movq %rax, %rdi
movq %r15, %rsi
callq 0x5100
leaq 0x14de(%rip), %rsi      # 0x7b05
movq %rax, %rdi
callq 0x5150
leaq 0x14db(%rip), %rsi      # 0x7b11
movq %rax, %rdi
callq 0x5150
movq %rax, %rdi
movq %r14, %rsi
callq 0x5100
movq %rax, %rdi
callq 0x50c0
jmp 0x655b
jmp 0x665e
jmp 0x665e
jmp 0x665e
jmp 0x665e
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x5050
movq %rbx, %rdi
callq 0x5250
nop