// File: /workspace/github_cpp_makefile_star2_O2/drummyfish[P]flowchart/src/bitmap_image.hpp
// Function: bitmap_image::save_image(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
bool save_image(const std::string& file_name)
   {
      std::ofstream stream(file_name.c_str(),std::ios::binary);

      if (!stream)
      {
         //std::cout << "bitmap_image::save_image(): Error - Could not open file "  << file_name << " for writing!" << std::endl;
         return false;
      }

      bitmap_file_header bfh;
      bitmap_information_header bih;

      bih.width            = width_;
      bih.height           = height_;
      bih.bit_count        = static_cast<unsigned short>(bytes_per_pixel_ << 3);
      bih.clr_important    =  0;
      bih.clr_used         =  0;
      bih.compression      =  0;
      bih.planes           =  1;
      bih.size             = 40;
      bih.x_pels_per_meter =  0;
      bih.y_pels_per_meter =  0;
      bih.size_image       = (((bih.width * bytes_per_pixel_) + 3) & 0x0000FFFC) * bih.height;

      bfh.type      = 19778;
      bfh.size      = 55 + bih.size_image;
      bfh.reserved1 = 0;
      bfh.reserved2 = 0;
      bfh.off_bits  = bih.struct_size() + bfh.struct_size();

      write_bfh(stream,bfh);
      write_bih(stream,bih);

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

      for (unsigned int i = 0; i < height_; ++i)
      {
         unsigned char* data_ptr = data_ + (row_increment_ * (height_ - i - 1));
         stream.write(reinterpret_cast<char*>(data_ptr),sizeof(unsigned char) * bytes_per_pixel_ * width_);
         stream.write(padding_data,padding);
      }

      stream.close();

      return true;
   }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x248, %rsp            # imm = 0x248
movq %rdi, %rbx
movq (%rsi), %rsi
leaq 0x48(%rsp), %r14
pushq $0x4
popq %rdx
movq %r14, %rdi
callq 0x21d0
movq (%r14), %rax
movq -0x18(%rax), %rax
movl 0x68(%rsp,%rax), %eax
testb $0x5, %al
jne 0xb75c
movl %eax, 0x8(%rsp)
movl 0x30(%rbx), %eax
movl %eax, 0x14(%rsp)
movl 0x34(%rbx), %ecx
movl %ecx, 0x18(%rsp)
movl 0x28(%rbx), %esi
leal (,%rsi,8), %edx
movw %dx, 0x1e(%rsp)
andl $0x0, 0x20(%rsp)
movw $0x1, 0x1c(%rsp)
movl $0x28, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rsp)
imull %eax, %esi
addl $0x3, %esi
andl $0xfffc, %esi           # imm = 0xFFFC
imull %ecx, %esi
movl %esi, 0x24(%rsp)
leaq 0x38(%rsp), %rdx
movw $0x4d42, (%rdx)         # imm = 0x4D42
addl $0x37, %esi
movl %esi, 0x4(%rdx)
movabsq $0x3600000000, %rax     # imm = 0x3600000000
movq %rax, 0x8(%rdx)
leaq 0x48(%rsp), %rsi
movq %rbx, %rdi
callq 0xba78
leaq 0x48(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0xbae6
movl 0x30(%rbx), %r14d
leaq 0xc(%rsp), %r15
andl $0x0, (%r15)
andl $0x3, %r14d
xorl %r13d, %r13d
pushq $-0x1
popq %rbp
leaq 0x48(%rsp), %r12
movl 0x34(%rbx), %esi
cmpl %esi, %r13d
jae 0xb74e
addl %ebp, %esi
imull 0x38(%rbx), %esi
addq 0x20(%rbx), %rsi
movl 0x28(%rbx), %eax
movl 0x30(%rbx), %edx
imulq %rax, %rdx
movq %r12, %rdi
callq 0x2250
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x2250
incl %r13d
decl %ebp
jmp 0xb715
leaq 0x48(%rsp), %rdi
callq 0x22a0
movl 0x8(%rsp), %eax
testb $0x5, %al
sete %bl
leaq 0x48(%rsp), %rdi
callq 0x22c0
movl %ebx, %eax
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xb783
jmp 0xb783
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x22c0
movq %rbx, %rdi
callq 0x2330